Boost logo

Boost Users :

Subject: Re: [Boost-users] [MultiIndex] more on key extractor issues
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2013-01-19 12:47:19


John M. Dlugosz <mpbecey7gu <at> snkmail.com> writes:

>
> I think my problem stems from the use of 'const' in the underlying element
> with pointer
> traversal.
>
> Consider:
>
> typedef multi_index_container<
> shared_ptr< const ItemBase >,
> indexed_by<
>
> ordered_non_unique<
> member<
> const ItemBase, // <<--- here
> const unsigned long, // <<--- here
> &ItemBase::some_member
> >
> >, // ordered_non_unique
>
> ordered_unique<
> tag<S2>,
> member<
> ItemBase,
> const S2,
> &ItemBase::another_member
> >
> > // ordered_unique
>
> > // indexed_by
> > ItemList_type_base;

Have you taken a look at the table in:

http://www.boost.org/libs/multi_index/doc/tutorial/
key_extraction.html#advanced_key_extractors

Regardless of whether the indexed-by member is const or not, when using
pointers to const elements the proper way of declaring the extractors is:

  member<
   ItemBase,
   const unsigned long,
   &ItemBase::some_member
>

  member<
    ItemBase,
    const S2,
    &ItemBase::another_member
>

This should clear problems away both in VS and Clang (please report
otherwise.)

Joaquín M López Muñoz
Telefónica Digital


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