Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-05-05 19:48:26


Jaakko Jarvi <jajarvi_at_[hidden]> writes:

> On May 5, 2004, at 1:26 PM, David Abrahams wrote:
>
>> Jaakko Jarvi <jajarvi_at_[hidden]> writes:
>>
>>> On May 4, 2004, at 7:56 PM, Fredrik Blomqvist wrote:
>>>
>>>> I think it would be convenient if one could treat std::pair as a
>>>> boost
>>>> two-tuple.
>>>> Both tuples::tie and tuple assignment already work with std::pair
>>>> but I've
>>>> noticed that the get<> accessor doesn't.
>>>>
>>>> So, I propose a simple extension to tuples::get<> with the obvious
>>>> semantics:
>>>> boost::get<0>(p) == p.first
>>>> boost::get<1>(p) == p.second
>>>>
>>>
>>> The trouble with get is that pairs live in namespace std, so if pair
>>> get's are not
>>> in std, they won't get found by ADL. But if we are willing to live
>>> with not having ADL,
>>> adding gets for pairs would be fine.
>>
>> Isn't there another problem? Are references legal arguments for
>> std::pair?
>>
>
> No, they aren't and thus we can't make pairs and 2-tuples have
> equivalent behavior in
> all cases. However, it seems that adding the get functions for pairs
> would not be
> problematic in this sense.
>
> OTOH, what Thorsten suggested, that 2-tuples would inherit from pairs,
> would
> not work.

tuple<int&,char> could be derived from
pair<reference_wrapper<int>,char>, no?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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