Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] How to use a class instead of a struct with the boost:multi_index_container? (addendum)
From: joaquin_at_[hidden]
Date: 2010-11-15 01:57:17


jamaj escribió:
> Hi All,
>
> Since I posted the previous message, I made some experiments. First, I
> changed the employee from struct to class:
>
> [...]
>
> I got some errors
>
> /home/jamaj/src/wxTestes/multiindexsample/main.cpp|31|error: ‘int
> employee::id’ is private
>
> [...]
> So, I had to change the scope of index class members to public, and it
> worked:
>
> [...]
>
> The question is: is there any other way to do it without exposing all
> class members?
>

You can expose the data you want to index by through some member
function, check the
examples at:

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

HTH,

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