C ++ 11 brings new generic initializers that can be nice. Question. Is any old syntax for initializing objects considered deprecated. In C ++ 03, an object can be initialized as
Option (1) is preferred since it does not include a copy. There are several more ways in C ++ 11:
Foo bar{x}auto bar=Foo{x}
Using move constructors and assignment operators, parameter (4) must also be accurate. Is (1) obsolete in favor of (3) or (4)?
In addition, in C ++ 03, the rule is that all constructors that take one argument must be explicit (except copy ctor). Other constructors are always explicit. With generic initializers, any ctor can be implicit. Is the new rule then explicit in all places or just where the conversion will mean side effects (allocation of a bunch of memory, creating a file ...) or be lossy (double to float)?
source
share