How come a tuple, being a generalisation of a pair, cannot be constructed from one? I mean something along the lines make_tuple (pair const &p) { return make_tuple (p.first, p_second); } Would be good to have.
Krzysztof Żelechowski wrote:
How come a tuple, being a generalisation of a pair, cannot be constructed from one?
I mean something along the lines
make_tuple (pair const &p) { return make_tuple (p.first, p_second); }
Would be good to have.
It turns out that TR1 supports constructing a tuple directly from a pair, so Boost should catch up. IMHO, Chris
On Wed, Oct 05, 2011 at 09:07:56PM +0200, Krzysztof Żelechowski wrote:
Krzysztof Żelechowski wrote:
How come a tuple, being a generalisation of a pair, cannot be constructed from one?
I mean something along the lines
make_tuple (pair const &p) { return make_tuple (p.first, p_second); }
Would be good to have.
It turns out that TR1 supports constructing a tuple directly from a pair, so Boost should catch up. --
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
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
when invoking make_tuple with a pair.
What I mean is this:
#include
----------------------------------------
To: boost-users@lists.boost.org From: giecrilj@stegny.2a.pl 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
when invoking make_tuple with a pair. What I mean is this:
#include
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
::tuple(const std::pair &)’ Compare:
#include
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
On 10/6/2011 3:07 AM, Krzysztof Żelechowski wrote:
Krzysztof Żelechowski wrote:
How come a tuple, being a generalisation of a pair, cannot be constructed from one?
I mean something along the lines
make_tuple (pair const &p) { return make_tuple (p.first, p_second); }
Would be good to have.
It turns out that TR1 supports constructing a tuple directly from a pair, so Boost should catch up.
Boost, is at the forefront of C++ dev and in fact spearheaded the
development of many std libraries, including tuple. FYI, there's
a more powerful tuples library called boost.fusion that includes a
(simple) TR1 tuple implementation.
Here's how you do it in fusion:
#include
participants (4)
-
Joel de Guzman
-
Krzysztof Żelechowski
-
Lars Viklund
-
Nathan Ridge