I'm having trouble getting multi_index's key extractors to play nicely
with shared_ptr objects. I'm trying to eliminate my custom hash and
equality objects in this code:
class screenshot_cache_entry : /* ... */
{
/* ... */
public:
const screenshot_key &get_key() const;
/* ... */
};
class hash_cache_entry
{
public:
size_t operator()(const boost::shared_ptr
cache_map;
Note that all my custom hash and equality comparisons do is invoke
get_key() and pass through to the corresponding operation on it. I've
been back and forth over the documentation and past mailing list posts,
and it seems like this "should" work:
typedef multi_index_container<
boost::shared_ptr
cache_map;
However, when I compile this, I get an error indicating that the index
is attempting to apply hash() to the *shared pointer* rather than to
the key object (at least it didn't just hash the pointer silently!)
(...)
screenshot_cache.cc:526: instantiated from here
/usr/include/boost/multi_index/hashed_index.hpp:439: error: no match for call to ‘(const boost::hash<const aptitude::screenshot_key>) (const boost::shared_ptr