
----- Mensaje original -----
De: Themistoklis Bourdenas
Could you help me understand what I'm doing wrong in the code below? I'm trying to setup a multi_index structure of class B.
class A { const std::string& ID(void) const; ... };
class B : public A { ... };
typedef boost::multi_index::multi_index_container< B*, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::const_mem_fun >
BSet;
However when I compile VS2005 returns me an "illegal indirection" compile error. Any thoughts?
Hello Themistoklis, You've found a limitation in Boost.MultiIndex (as of Boost 1.33.1) by which one cannot specifiy a key in a given base class and pass derived classes as elements. This is solved in what will become Boost 1.34, please read bullet 3 of Boost.MultiIndex release notes at: http://boost- consulting.com/boost/libs/multi_index/doc/release_notes.html#boost_1_34 Until this release is out, you can use the following workarond: simply define a custom key extractor like this (warning, I haven't compiled it, beware typos): struct pB_ID_extractor { typedef std::string result_type; const std::string& operator()(const B* pb)const { return pb->ID(); } }; typedef boost::multi_index::multi_index_container< B*, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< pB_ID_extractor >
BSet;
Does this help? Thank you for using Boost.MultiIndex, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo