- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to specify the comparator of tbb::concurrent_priority_queue in runtime, as in std::priority_queue?
In std::priority_queue, you can pass the comparator as an argument of the constructor. For example, see 'sixth' of the following example. http://www.cplusplus.com/reference/queue/priority_queue/priority_queue/
However, it seems like tbb::concurrent_priority_queue does not receive comparator as an argument, and creates one itself using the default constructor. Is there any way to specify it in runtime?
Thanks,
Hyokun Yun
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is correct that the comparator cannot be dynamically specified. We can take this as a feature request. In order to more clearly understand the decision, would you be able to share a bit more about what you would like to do with that ability? I.e. why is it importatnt, what's your use case?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two threads about the same subject: this must be important...
I've already officially submitted a possible contribution to address this (just a matter of introducing a new set of constructors).
BTW, the C++ templates that use comparators apparently store ((ordered) associative containers, priority_queue) or even accept (sorting and related operations) them only by value (do tell if I overlooked anything), not by reference, but I don't see a need to second-guess that in TBB. Not to say that it was the right choice, but if you're in control of what comparator class to use, there's always embedding as a workaround against object slicing, and otherwise I would be curious about a use case that would run into this general limitation.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page