Multi Index Container - key extractor on a member of a member

View: New views
5 Messages — Rating Filter:   Alert me  

Multi Index Container - key extractor on a member of a member

by Avi Revivo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

Is it possible/exist a key extractor that can extract a member of a member of the base type stored by the Multi Index container. I tried to do this with the standard member extractor but failed to do so.

Thanks in advnace,
Avi Revivo

Re: Multi Index Container - key extractor on a member of a member

by Avi Revivo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

BTW: I am currently doing this by creating a member function that expose the value of the inner member of the member and use BOOST_MULTI_INDEX_CONST_MEM_FUN.

Thanks

Avi Revivo wrote:
Hi All,

Is it possible/exist a key extractor that can extract a member of a member of the base type stored by the Multi Index container. I tried to do this with the standard member extractor but failed to do so.

Thanks in advnace,
Avi Revivo

Re: Multi Index Container - key extractor on a member of a member

by JOAQUIN M. LOPEZ MUÑOZ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Avi,

----- Mensaje original -----
De: Avi Revivo <revivoavi@...>
Fecha: Domingo, Diciembre 23, 2007 2:01 pm
Asunto: [boost] Multi Index Container - key extractor on a member of a
member
Para: boost@...
>
> Hi All,
>
> Is it possible/exist a key extractor that can extract a member of
> a member of the base type stored by the Multi Index container.
> I tried to do this with the standard member extractor but failed
> to do so.

You must write your own custom extractor to do so. The tutorial
section on this issue (http://tinyurl.com/39shzv ) shows precisely
how to write an extractor that provides as the key a member of a
member of the element. Please come back if you have problems
writing your key extractor after the instructions on the afore-
mentioned docs section.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: Multi Index Container - key extractor on a member of a member

by Avi Revivo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you very much for the fast reply,

If i have no problem adding a function that returns the value to sort by (e.g. long GetClientId) and i use BOOST_MULTI_INDEX_CONST_MEM_FUN define key extractor.

Would you suggest i use BOOST_MULTI_INDEX_CONST_MEM_FUN,write my own custom key extractor or it does not matter in terms of performance (or anything else)?

Thanks Again,
Avi

Joaquin M Lopez Munoz wrote:
Hi Avi,

----- Mensaje original -----
De: Avi Revivo <revivoavi@hotmail.com>
Fecha: Domingo, Diciembre 23, 2007 2:01 pm
Asunto: [boost] Multi Index Container - key extractor on a member of a
member
Para: boost@lists.boost.org
>
> Hi All,
>
> Is it possible/exist a key extractor that can extract a member of
> a member of the base type stored by the Multi Index container.
> I tried to do this with the standard member extractor but failed
> to do so.

You must write your own custom extractor to do so. The tutorial
section on this issue (http://tinyurl.com/39shzv ) shows precisely
how to write an extractor that provides as the key a member of a
member of the element. Please come back if you have problems
writing your key extractor after the instructions on the afore-
mentioned docs section.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: Multi Index Container - key extractor on a member of a member

by JOAQUIN M. LOPEZ MUÑOZ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



----- Mensaje original -----
De: Avi Revivo <revivoavi@...>
Fecha: Martes, Diciembre 25, 2007 7:47 am
Asunto: Re: [boost] Multi Index Container - key extractor on a member
of a member
Para: boost@...

>
> Thank you very much for the fast reply,
>
> If i have no problem adding a function that returns the value to
> sort by (e.g. long GetClientId) and i use
> BOOST_MULTI_INDEX_CONST_MEM_FUN define key extractor.
>
> Would you suggest i use BOOST_MULTI_INDEX_CONST_MEM_FUN,write my
> own custom key extractor or it does not matter in terms of
> performance (or anythingelse)?

>From the point of view of performance there shouldn't be
any difference between both approaches. So I guess it's a
matter of taste; I'd go for the custom extractor if
using BOOST_MULTI_INDEX_CONST_MEM_FUN somehow forces you
to change the design of your class or looks forced.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost