|
Boost Users : |
From: Themistoklis Bourdenas (themis_at_[hidden])
Date: 2006-08-01 06:52:09
Thanks for the reply. I will use the workaround for the time being until
the new boost release comes up.
JOAQUIN LOPEZ MU?Z wrote:
> ----- Mensaje original -----
> De: Themistoklis Bourdenas <themis_at_[hidden]>
> Fecha: Lunes, Julio 31, 2006 4:47 pm
> Asunto: [Boost-users] [multi_index] illegal indirection compile error
>
>> 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<A, const
>> std::string&, &A::ID>
>> >
>> >
>>> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net