【发布时间】:2011-04-10 08:19:24
【问题描述】:
我想对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>::*)()’
【问题讨论】:
标签: c++ boost function-pointers multi-index