Boost logo

Boost :

Subject: Re: [boost] [variant] Warning: variadic templates in boost::variant
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-12-09 09:52:12


AMDG

On 12/09/2013 04:16 AM, Andrey Semashev wrote:
> On Monday 09 December 2013 14:02:12 Peter Dimov wrote:
>> Antony Polukhin вроте:
>>> However this:
>>> * breaks ABI (now variant is declared as `template <typename T0,
>>> typename... TN> class variant`)
>>
>> Why not just template<class... TN> class variant? It's true that the
>> degenerate case of variant<> isn't particularly useful, but then again,
>> neither is the singular case of variant<X>. Is there a good reason to
>> prohibit variant<>?
>
> What should be the storage for such a variant then? Also, most of the
> interface of variant<> becomes invalid (e.g. type(), which(), assignment from
> elements, apply_visitor()). With such drastic interface differences, there
> should be a compelling reason to have such a specialization, and I don't see
> one.
>

Boost.Variant explicitly guarantees that it always
holds one of the variant types. variant<> doesn't
really make sense, because it's impossible to satisfy
this invariant. variant<X> isn't very useful, but it
does have a sensible meaning.

In Christ,
Steven Watanabe


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