[Multi-Index] Chained Ptr misunderstanding
From the doc, it seems that shared_ptr would be considered a Chained Pointer, and as such should work as-is, which by that I mean that I
Hi. I'm trying to use a shared_ptr as the value_type of a
multi_index_container, but I'm not having any success with the key
extractors (VS2005, 1.38).
think I should be able to use the built-in key extractors whether
value_type is a value or a shared_ptr. But I'm not having any luck. I
found [1] which is very similar and which Joaquín answered, but I have
other key extractors I want to use in different indexes, so I don't
think using identity<> is applicable to my case in general, although
it would be in this one. I'm trying to avoid having to write dumb
custom key extractors for Foo, which would basically replicate what
the built-in ones do in the first place.
It's most likely an error an my part, but I can't spot it. Can someone
please help? Thanks, --DD
[1] http://www.nabble.com/-multiindex--custom-key-extractor-problem-td20839161.h...
#include
FooIndex;
int main() { FooIndex index; shared_ptr<Foo> p_foo(new Foo); BOOST_ASSERT(index.insert(p_foo).second); return 0; }
Dominique Devienne escribió:
Hi. I'm trying to use a shared_ptr as the value_type of a multi_index_container, but I'm not having any success with the key extractors (VS2005, 1.38).
[...] ordered_unique< BOOST_MULTI_INDEX_CONST_MEM_FUN( shared_ptr<Foo>, const Uid&, uid ) >
Replace the declaration above with ordered_unique< BOOST_MULTI_INDEX_CONST_MEM_FUN( Foo, const Uid&, uid )
That is, you must specifiy keys as if there weren't any intervening pointers --dereferencing is taken care of automatically by Boost.MultiIndex predefined extractors. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Dominique Devienne
-
joaquin@tid.es