I want to sort my objects in boost::multi_map refer to some index. But I'm storing not pure objects, but wrapped into boost::shared_ptr. Here is the code:
typedef boost::multi_index_container<boost::shared_ptr<Object>,
boost::multi_index::indexed_by<
boost::multi_index:: ordered_non_unique<
boost::multi_index::mem_fun<boost::shared_ptr<Object>, int, &boost::shared_ptr<Object>::getIndex>
>
>
> ObjectWrapperSet;
But it fails at point: &boost::shared_ptr<Object>::getIndex. This is logically, that type doesn't have getIndex function. But how to refer to that function this way?
I tried it with simple Object::getIndex:
could not convert template argument ‘&Object::getIndex’ to ‘int (boost::shared_ptr<Object>::*)()’
Change
boost::multi_index::mem_fun<boost::shared_ptr<Object>, int, &boost::shared_ptr<Object>::getIndex>
to
boost::multi_index::mem_fun<Object, int, &Object::getIndex>
According to the documentation it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With