[cfe-dev] std::is_trivial_default_constructible<T>, what's required?!

Furkan Usta via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 25 04:43:55 PST 2018


> A default constructor is trivial if it is not user-provided and if ... no
non-static data member of its class has a default member initializer ...

http://eel.is/c++draft/class.ctor#6.2

2018-01-25 15:11 GMT+03:00 Gabriel Charette via cfe-dev <
cfe-dev at lists.llvm.org>:

> Hello Clang/C++ experts!
>
> I'm confused on what it takes to be std::is_trivial_default_constructible?
>
> This doesn't even compile (leaving x_ uninitialized compiles but I don't
> see why it's not trivial to initialize a POD member inline):
>
> class Test {
>  public:
>   int x_ = 0;
> };
>
> static_assert(std::is_trivially_default_constructible<Test>::value, "");
>
> -> error: static_assert failed due to requirement
> 'std::is_trivially_default_constructible<Test>::value' ""
>
> I also tried making a constexpr Test() = default; constructor but I can't
> get anything with POD members initialized inline to pass the
> std::is_trivially_default_constructible test...?!
>
> Thanks!
> Gab
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180125/621c4891/attachment.html>


More information about the cfe-dev mailing list