[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:54:23 PST 2018


On Thu, Jan 25, 2018 at 7:35 AM, Gabriel Charette <gab at chromium.org> wrote:

>
>
> On Thu, Jan 25, 2018 at 4:32 PM James Dennett <james.dennett at gmail.com>
> wrote:
>
>> 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*.
>>
>
> Right... What I want is way to tell if the compiler will evaluate this at
> compile-time (e.g. to guarantee no static initializer for globals of
> trivial types with only zero-initialized POD members).
>

`constexpr` (or the [[clang::require_constant_initialization]] attribute)
is what you want to ensure compile-time initialization.  Happily it can do
a lot more than zero-initialization.

-- James

p.s. This isn't really the right list for general questions about C++.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180125/60f8b78c/attachment.html>


More information about the cfe-dev mailing list