I'm just not sure why trivial default constructibility is mentioned if it doesn't affect this property of initialization.
I initially misread the article as if it said that trivial-default-constructible = different behavior of T a; vs T b{};, but now I see you're not claiming that.
I had a lot of require statements that check if something can trivially construct (in which case it'll fill with 0's), and copyable (memcpy). But there's no way to avoid pointers and refs in them unfortunately. I just figure someone else has the same usecase and might be checking if something is trivial soon
Generally things check trivially constructible to avoid calling constructors and putting more work on the optimiser to remove them again.
Trivial doesn't imply that all-zeroes is some kind of null / default state. It just means the type has no invariants that need to be set by a constructor. Many things that check for trivial construction don't fill the memory with anything and just leave it uninitialised, or full it with a recogniseable pattern.
View all comments
Show parent comment
1
u/holyblackcat May 05 '26
I'm just not sure why trivial default constructibility is mentioned if it doesn't affect this property of initialization.
I initially misread the article as if it said that trivial-default-constructible = different behavior of
T a;vsT b{};, but now I see you're not claiming that.