Termsslug: value-initialization

Value Initialization

值初始化

C++ initialization triggered by empty braces or parentheses, which zero-initializes trivial types.

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.