Boost logo

Boost :

Subject: Re: [boost] [variant]compile-time-checked boost::get<T>?
From: Joe Gottman (jgottman_at_[hidden])
Date: 2008-12-11 00:07:33

Steven Watanabe wrote:
> Joe Gottman wrote:
>> Mathias Gaunard wrote:
>>> Arno Schödl wrote:
>>>> As a further extension, boost::get<S> where S is a base class of a T
>>>> contained in the variant, should also work. I believe this would
>>>> also be implementable with enable_if/disable_if, but we have not
>>>> done it, so no guarantee.
>>> Actually, it should work with all types that are convertible from any
>>> of the types of the variant.
>> Would it work for a type that is convertible from two or more of
>> the types of the variant?
> It had better not compile in that case, unless one of the types is a
> better match
> than the rest.

    What's so dangerous about it compiling in that case? What's wrong
with having get<S> convert the actual underlying object of the current
Variant to S& (or possibly const S &) if possible, and throwing an
exception otherwise?

Joe Gottman

Boost list run by bdawes at, gregod at, cpdaniel at, john at