On 4/4/2015 9:31 PM, Larry Evans wrote:
On 04/04/2015 05:49 PM, Steven Watanabe wrote:
AMDG
On 04/04/2015 04:33 PM, Larry Evans wrote:
On 04/04/2015 05:08 PM, Matt Calabrese wrote:
On Sat, Apr 4, 2015 at 3:06 PM, Matt Calabrese
wrote: You need to use a recursive union if you are to get some constexpr support.
Well, let me rephrase, you can expand it out by preprocessor to a certain limit and get that too, but you can't just use aligned storage. At some point you need to hit a recursive case.
Could you please elaborate on why recursion cannot be avoided?
Variadic parameter packs can't be expanded on class (or in this case union) members.
template
union variant_storage { T t;... // illegal }; Why not:
template
struct variant_storage : std::aligned_union < 0 //Let aligned_union decide the size needed. , char //handle case where size_of...(T) == 0. , T... > { }; This provides the storage needed. No constexpr functions yet. The egg code mentioned by gonzalobg88@gmail.com:
https://github.com/eggs-cpp/variant/blob/master/include/eggs/variant/detail/...
had several constexpr( or at least EGGS_CXX11_CONSTEXPR) functions. Are one of those requiring a recursive union for implementation?
Yes, pretty much all of them require a recursive union for constexpr support. The details can be found here http://talesofcpp.fusionfenix.com/post-20/eggs.variant---part-ii-the-constex... and here https://akrzemi1.wordpress.com/2012/12/13/constexpr-unions/ Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com