Boost logo

Boost :

Subject: Re: [boost] [variant]compile-time-checked boost::get<T>?
From: David Abrahams (dave_at_[hidden])
Date: 2008-12-10 13:57:27

on Wed Dec 10 2008, Arno Schödl <> wrote:

> Hello,
> I just replaced our own union implementation by boost::variant and was surprised that
> boost::get<T> does not compile-time check T. IMHO, boost::get<T> should only compile
> if T is a possible member of the variant. We implemented this with an enable_if
> without much difficulty.
> 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.

I agree with you, FWIW

Dave Abrahams
BoostPro Computing

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