Boost logo

Boost :

Subject: Re: [boost] Variant2 review
From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-04-08 17:53:46


Andrzej Krzemienski wrote:

> Such thing could be achieved if the behavior of variant's assignment and
> emplacement was controlled by a type trait. The default implementation for
> unfriendly types would be compile-time error; but users would be able to
> specialize it for their instantiations of variant in order to assign
> different semantics: double buffering, or setting the
> valueless_by_exception state.

This can't work in general. If you have

template<class... T> class lib1::X
{
private:

    variant<T...> state_;
};

and

template<class... T> class lib2::Y
{
private:

    variant<T...> state_;
};

it's not possible for lib1 and lib2 to choose their preferred variant
behaviors independently of one another.


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