The question is simple. Is it possible to construct such a type T, for which the following two variables declarations will produce different results?
T t1 = {};
T t2{};
I've been digging through the cppreference and the standard for more than an hour now, and I understood the following:
T t2{};
is a value initialization. No surprises here.T t1 = {}
is a list initialization with an empty braced-init-list.
But the last one is tricky since the "effects of list initialization" is an impressive... list. Which for classes, fundamental types and aggregates seems to boil down to value initialization. But I am not sure I haven't missed anything.
Maybe you can provide a context, in which the two declarations will have different effects?
UPD: Excellent answers about explicit
constructors! Next level: is it possible that both statements compile, but have different effects on compile/run time?