Boost logo

Boost Users :

Subject: Re: [Boost-users] a tuple from a pair?
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-10-07 19:45:35


----------------------------------------
> To: boost-users_at_[hidden]
> From: giecrilj_at_[hidden]
> Date: Fri, 7 Oct 2011 11:18:24 +0200
> Subject: Re: [Boost-users] a tuple from a pair?
>
> Lars Viklund wrote:
>
> > Are you sure you're not misunderstanding what your implementation does?
> > VC10 and GCC 4.4.5 makes (rightfully so) a 1-tuple with an element of
> > type pair<T1,T2> when invoking make_tuple with a pair.
> >
>
> What I mean is this:
>
> #include <boost/tuple/tuple.hpp>
> void trigger (::std:: pair < int, int > const &p)
> { ::boost:: get < 0 > (::boost:: tuple < int, int > (p)) == p. first; }
>
> error:
> no matching function for call
> to ‘boost::tuples::tuple<int, int>::tuple(const std::pair<int, int>&)’
>
> Compare:
>
> #include <tr1/tuple>
> void trigger (::std:: pair < int, int > const &p)
> {
> ::std:: tr1:: get < 0 > (::std:: tr1:: tuple < int, int > (p)) == p. first;
> }
>
> I guess this, and Joel’s comment about boost fusion, means boost tuple
> should be deprecated.
>
> Chris

If you use boost::fusion::at_c<0> rather than std::get<0> or boost::get<0>,
you don't even need to convert to a tuple<int, int> - it "just works" on
std::pair, boost::tuple, std::tuple, or any other random-access Fusion sequence.

Regards,
Nate
                                               


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