It is said in construction of a priority queue , option (12):
template< class InputIt >
priority_queue( InputIt first, InputIt last,
const Compare& compare = Compare(),
Container&& cont = Container() );
But I don't know how ot use this. I have a non-empty std::unordered_set<std::shared_ptr<MyStruct>> mySet
, and I want to convert it to a priority queue. I also create a comparator struct MyComparator
:
struct MyComparator {
bool operator()(const std::shared_ptr<myStruct>& a,
const std::shared_ptr<myStruct>& b){...}
};
Now how can I construct a new priority_queue myQueue
? I used the following but can't get compiled:
std::priority_queue<std::shared_ptr<MyStruct>, std::vector<std::shared_ptr<MyStruct>, MyComparator>
myQueue(mySet.begin(), mySet.end());
Aucun commentaire:
Enregistrer un commentaire