|
Boost Users : |
From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2006-01-22 10:20:42
----- Mensaje original -----
De: François Duranleau <duranlef_at_[hidden]>
Fecha: Domingo, Enero 22, 2006 6:08 am
Asunto: Re: [Boost-users] [tuple] no easy access to get function
> On Sat, 21 Jan 2006, JOAQUIN LOPEZ MU?Z wrote:
>
> > ----- Mensaje original -----
> > De: Frank Birbacher <bloodymir.crap_at_[hidden]>
> > Fecha: Sábado, Enero 21, 2006 2:29 am
> > Asunto: [Boost-users] [tuple] no easy access to get function
> >
> >> Today I wanted to std::transform a range of tuples into a
> sequence of
> >> one element. I thought I could just take the address of some
> >> tuple::get<N> function. Maybe also specify the Tuple type as
> template>> parameter [...]
> >> I'd rather want to take the address of boost::tuple::get<N,Tuple>,
> >> but the template parameters won't match.
> >
> > Maybe you forgot the final s in "tuples" when
> > writing
> >
> > boost::tuples::get<N,Tuple>
>
> There is a thin wrapper declared in the boost namespace as well.
> The
> probleme is elsewhere. The argument to the get function is not a
> boost::tuple<>, but some base class template. Thus the template
> arguments
> of the function are not and an integer and a tuple, but an integer
> and
> something else (actually, a cons<HT,TT> if you look in the code).
> To take
> the address of such a function, you need to bind the integer, as
> well as
> HT and TT, not a tuple.
Yep, I see. You're right. Well, you can refer to get<> as follows
boost::tuples::get<N,typename Tuple::inherited>
Note that this is not relying on undocumented implementation,
so called "const lists" are explained and made public at
http://boost.org/libs/tuple/doc/tuple_advanced_interface.html
So I'd say you can use the former reference to get safely.
>
> However, I am wondering if there would be a problem to declare the
> thin
> wrapper simply like this (example with the const version):
>
> template< int N ,
> typename Tuple >
> inline
> typename tuples::access_traits<
> typename tuples::element< N , Tuples >::type
> >::const_type
> get( const Tuple& t )
> {
> return tuples::get< N >( c ) ;
> }
>
> ?
That would also work, but my proposal above is simpler.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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