Boost logo

Boost :

From: Giovanni Bajo (giovannibajo_at_[hidden])
Date: 2002-07-16 09:47:46


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, July 16, 2002 4:07 PM
Subject: Re: [boost] Re: boost::variant 0.2 (was: Yet another ...)

> From: "Giovanni Bajo" <giovannibajo_at_[hidden]>
> > > Even if there were such a solution, you'd get ODR violations that way,
> > since
> > > the same T may be complete at one point and incomplete at another.
> AFAICS.
> >
> > Can you please explain why a simple Select<is_incomplete<T>,
> incomplete<T>,
> > T> should not work in this situation? Isn't there a is_incomplete trait
> > somewhere?
>
> class X;
>
> variant<X, int> v1;
>
> class X
> {
> };
>
> variant<X, int> v2;
>
> Would this work as expected (i.e. not lead to ODR violations or some other
> undesired behavior) under the implementation you envision?

Good question, this is what I was thinking of:

----------snip---------
template <typename T1, ...>
class Variant
{
        // bla bla bla
};

template <typename T1, ...>
class VariantFactory
{
    typedef Variant
    <
        typename CT_IF<is_incomplete<T1>::result, incomplete<T1>,
T1>::result,
        ....
> type;
};

class X;
VariantFactory<X, int>::type v1;

class X {};
VariantFactory<X, int>::type v2;
----------snip---------

I can't see anything wrong here, but again there might well be something.

Giovanni Bajo


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