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

James Dennett via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 25 07:32:41 PST 2018


On Thu, Jan 25, 2018 at 4:11 AM, Gabriel Charette via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hello Clang/C++ experts!
>
> I'm confused on what it takes to be std::is_trivial_default_constructible?
>

To be trivially default constructible means to be default constructible
*without doing anything*.


>
> 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...?!
>
>
If you need to initialize something, that's not trivial.

-- James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180125/ac10ef15/attachment.html>


More information about the cfe-dev mailing list