[Boost-users] [tuples, multi-index] tuples::get as key extractor

68 views
Skip to first unread message

Igor R

unread,
Aug 8, 2010, 4:27:51 PM8/8/10
to boost...@lists.boost.org
Hello,

Consider the following types:

typedef tuple<std::string, int> Item;
typedef multi_index_container<
Item,
indexed_by<
ordered_non_unique<global_fun<const Item &, int, &tuples::get<1> > >
>
> Items;

The above types don't compile (MSVC10) because of &tuples::get<1>:
C2440: 'specialization' : cannot convert from 'overloaded-function' to
'int (__cdecl *)(boost::tuples::tuple<T0,T1> &)'
It seems there're several overloaded function templates "tuples::get"...

So, what's the correct type of the appropriate function? Or -- is
there a more "robust" way to extract the key (without defining
explicit function-object)?

Thanks!
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

joa...@tid.es

unread,
Aug 9, 2010, 1:54:48 AM8/9/10
to boost...@lists.boost.org
Igor R escribió:

> Hello,
>
> Consider the following types:
>
> typedef tuple<std::string, int> Item;
> typedef multi_index_container<
> Item,
> indexed_by<
> ordered_non_unique<global_fun<const Item &, int, &tuples::get<1> > >
> >
>
>> Items;
>>
>
> The above types don't compile (MSVC10) because of &tuples::get<1>:
> C2440: 'specialization' : cannot convert from 'overloaded-function' to
> 'int (__cdecl *)(boost::tuples::tuple<T0,T1> &)'
> It seems there're several overloaded function templates "tuples::get"...
>
> So, what's the correct type of the appropriate function? Or -- is
> there a more "robust" way to extract the key (without defining
> explicit function-object)?
>

There can be a number of problems in trying to reference Boost.Tuple
extractors
directly. Have a look at

http://lists.boost.org/boost-users/2005/12/16088.php

for a discussion and a proposed solution (search for
tuple_member_extractor at the
bottom of the post).

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Igor R

unread,
Aug 9, 2010, 4:20:58 AM8/9/10
to boost...@lists.boost.org
> There can be a number of problems in trying to reference Boost.Tuple
> extractors
> directly. Have a look at
>
> http://lists.boost.org/boost-users/2005/12/16088.php
>
> for a discussion and a proposed solution (search for tuple_member_extractor
> at the
> bottom of the post).

Oh I see...

Thanks!

Reply all
Reply to author
Forward
0 new messages