
El 07/09/2017 a las 21:25, Nick Gordon via Boost-users escribió:
I have a multi-index container that I'm using to fulfill two search cases. The objects are all derived from `Base`, which is a pure virtual class. To store the `Derived` objects I'm using unique_ptrs as the container value type. However, I need to store the objects uniquely on a composite of a member string, and an enum type used for runtime reflection without dynamic_cast-ing or typeid-ing. So, I want to use a composite key to be unique over both of these things. However, it doesn't compile (why else would I be posting) [...]
You're using boost::multi_index::composite_key< boost::multi_index::member<element, const int, &element::x>, boost::multi_index::member<element, const float, &element::y>
but composite_key requires that the first template argument be the type on which the (following) key extractors are applied onto: http://www.boost.org/libs/multi_index/doc/reference/key_extraction.html#comp... So, use boost::multi_index::composite_key< element, boost::multi_index::member<element, const int, &element::x>, boost::multi_index::member<element, const float, &element::y>
and you're done. Joaquín M López Muñoz