On 30/11/16 19:29 -0800, Tim Shen wrote:
On Wed, Nov 30, 2016 at 8:27 AM, Jonathan Wakely wrote:
On 26/11/16 21:38 -0800, Tim Shen wrote:
+  template<typename _Type, bool = std::is_literal_type_v<_Type>>
    struct _Uninitialized;



I'm still unsure that is_literal_type is the right trait here. If it's
definitely right then we should probably *not* deprecate it in C++17!

No it's not right. We need this only because [basic.types]p10.5.3 (in n4606):

 if it (a literal type) is a union, at least one of its non-static
data members is of non-volatile literal type, ...

is not implemented. In the current GCC implementation, however, all
non-static data members need to be literal types, in order to create a
literal union.

With the current GCC implementation, to keep our goal, which is to
make _Variadic_union literal type, we need to ensure that
_Uninitialized<T> is literal type, by specializing on T:
1) If is_literal_type_v<T>, store a T;
2) otherwise, store a raw buffer of T.

In the future, when [basic.types]p10.5.3 is implemented, we don't need
is_literal_type_v.

I'll add a comment here.

Thanks, that will stop me asking again and again in future ;-)

I think we want to get [basic.types] p10 implemented before we declare
C++17 support non-experimental, so we don't have to change
std::variant layout later.

I didn't check for other compilers.

That's fine, the current approach should work for them too.

Reply via email to