Subject: [boost] [variant]compile-time-checked boost::get<T>?
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-12-10 05:59:35
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.
-- Dr. Arno Schoedl · aschoedl_at_[hidden] Technical Director think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany http://www.think-cell.com · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229