Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-08-27 10:00:18


Alexander Nasonov wrote:

> Fernando Cacciola wrote:
>
>> References are not objects; i.e., you can't really have a reference
>> _stored_ somewhere (even though most implementation do it behind the
>> scenes)
>
> what about reference_wrapper? ;-)

Sorry for posting that before reading the whole post.

> With a tuple<> the situation is different because tuple<T&> is just
> a class with a reference data member, and the language specifically allow
> data members to be references but by means of special rules.
> Since references are not objects, when you have a reference data member
> you're not necessarily adding the data member to the class storage
> (even though most implementations do just that).

You can think of tuple<int&,char&> as it were

struct tuple_int_char
{
    int& m0;
    char& m1;
    // ...
};

variant<int&,char&> would be

union variant_int_char
{
    int& m0; // compile error
    char& m1;
    // ...
};

Despite this analogy I think variant<int&,char&> would be nice. I'm not
insisting though because you can always use reference_wrapper.

-- 
Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

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