[Patch] Implement std::experimental::variant
Tim Shen
timshen@google.com
Sat Aug 6 01:57:00 GMT 2016
On Fri, Aug 5, 2016 at 6:24 PM, Tim Shen <timshen@google.com> wrote:
> Preprocessed files attached.
I got error messages using g++ (GCC) 6.0.0 20160326 (experimental)
with -std=c++1z, so it's probably not the sharpest version.
I noticed that C++17 requires a union to have at least one literal
type member to make itself literal type:
"for unions, at least one non-static data member is of non-volatile
literal type, "
from http://en.cppreference.com/w/cpp/concept/LiteralType. This should
be sufficient to implement the constexpr variant we want.
I'm not sure about the compiler support though. I have this example:
struct literal { constexpr literal() = default; };
struct nonliteral { nonliteral() {} };
union A { literal a; nonliteral b; };
constexpr A a;
But neither Clang r277552 nor gcc 20160326 compiles it.
I'll try gcc trunk later.
--
Regards,
Tim Shen
More information about the Libstdc++
mailing list