all. I'm trying to use a std::multiset
to have automatic ordering upon insertion. Its elements are std::shared_ptr
s to DataCell
objects. Here is the code in the header file:
typedef std::shared_ptr<DataCell> DataCellPtr;
inline bool operator<(const DataCellPtr &d1, const DataCellPtr &d2){
std::cout << "lalala" << std::endl;
return d1->_cartesianDistance < d2->_cartesianDistance;
}
typedef std::multiset<DataCellPtr, std::less<DataCellPtr>> DataCellPtrMultiset;
All works fine, except that my custom ordering does not take place, as I was supposed to get "lalala"
s printed to my std::out
, which is not happening. I imagine the multiset is using the shared_ptr
's default ordering. The _cartesianDistance
member is a double. Question: how do I override the default shared_ptr
ordering?
Aucun commentaire:
Enregistrer un commentaire