Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2005-02-14 20:48:03


On Feb 14, 2005, at 7:40 PM, Edward Diener wrote:

> Howard Hinnant wrote:
>> On Feb 14, 2005, at 7:06 AM, John Maddock wrote:
>>
>>> The following simple patch to tuple_basic.hpp allows tuples to be
>>> constructed from std::pairs (there is already an assignment operator,
>>> but the copy constructor is missing for some reason, and is required
>>> for TR1 conformity).
>>>
>>> RCS file: /cvsroot/boost/boost/boost/tuple/detail/tuple_basic.hpp,v
>>> retrieving revision 1.28
>>> diff -r1.28 tuple_basic.hpp
>>> 627a628,636
>>>> template <class T, class U>
>>>> tuple(const std::pair<T, U>& p)
>>>> : inherited(p.first, p.second, detail::cnull(), detail::cnull(),
>>>> detail::cnull(), detail::cnull(), detail::cnull(),
>>>> detail::cnull(), detail::cnull(), detail::cnull())
>>>> {
>>>> BOOST_STATIC_ASSERT(length<tuple>::value == 2);// check_length
>>>> = 2 }
>>>>
>>>
>>> Is it acceptable to add this?
>>
>> I think we could do better, but it would be stretching TR1 (which I
>> think is good).
>>
>> I think any compatible tuple-like type should be convertible to tuple
>> (pair, array, maybe complex?, anything else that declares itself
>> tuple-like and implements the tuple interface).
>
> What is the technical definition of a tuple-like type ?

See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1382.pdf
and search for is_tuple_like.

There's a nicely written compact definition. In a nutshell, it
implements the tuple interface, and registers itself with the
is_tuple_like trait.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk