我想在boost::multi_map中引用一些索引对我的对象进行排序。但是我存储的不是纯对象,而是包装到boost::shared_ptr中。代码如下:
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;但它在以下位置失败:&boost::shared_ptr<Object>::getIndex。从逻辑上讲,该类型没有getIndex函数。但是如何以这种方式引用该函数呢?
我用简单的Object::getIndex试过了
could not convert template argument ‘&Object::getIndex’ to ‘int (boost::shared_ptr<Object>::*)()’发布于 2011-04-10 16:29:57
变化
boost::multi_index::mem_fun<boost::shared_ptr<Object>, int, &boost::shared_ptr<Object>::getIndex>至
boost::multi_index::mem_fun<Object, int, &Object::getIndex>根据documentation的说法,它应该可以工作。
https://stackoverflow.com/questions/5610562
复制相似问题