Namespaces
Variants
Views
Actions

Talk:cpp/language/value initialization

From cppreference.com

The "T object{};" syntax is not guaranteed to give value initialization: if T has an initializer-list constructor but no default constructor, it will be list-initialized.

Edited, thank you for pointing that out. --Cubbi 03:31, 26 July 2013 (PDT)

"In all cases, if the empty pair of braces {} is used and T is an aggregate type that is not a class type with a default constructor (until C++14), aggregate-initialization is performed instead of value-initialization." Surely "an aggregate type that is not a class type with a default constructor" must be an array? To have no default constructor (not even a deleted one), T would need a user-defined constructor and therefore would not be aggregate type...? --124.168.32.191 02:33, 24 December 2014 (PST)

The example in CWG 1324 (which changed this wording after C++11) is:
struct B {
   B(const B&) = default;
};
B b{};
--Cubbi (talk) 06:57, 24 December 2014 (PST)