Termsslug: trivial-type

Trivial Type

平凡类型

A C++ type that can be trivially constructed, copied and destroyed, allowing whole-object zero-initialization.

Curated Intelligence

1 items · Page 1/1
Hacker News AIT2·Tools
42 pts
In C++, = default and {} Constructors Differ in Semantics

Daniel Lemire explains that writing an empty default constructor as `= default` versus `{}` in C++ yields very different semantics and performance: the former keeps the type trivial so value-initialization zeroes the whole object including padding, while the latter is user-provided and no longer zeroes members. The distinction directly affects initialization cost and correctness for lightweight structs like span.