r...@zedat.fu-berlin.de (Stefan Ram) wrote in news:initialization-
2015042...@ram.dialup.fu-berlin.de:
> People told me that
>
>::std::string s( ... )
>
> was »direct initialization« and
>
>::std::string s = ...
>
> was »copy initialization«.
>
> Herb Sutter wrote »Copy initialization means the object is
> initialized using the copy constructor«.
So what? From a sentence like "Car washing is using water" you cannot
infer "Any usage of water means car washing".
>
> I believe that in the case
>
>::std::string t;
>::std::string s( t );
>
> , the object »s« is initialized using the copy constructor.
> So then this is copy initialization, even if it uses
> parentheses?
This is terminology nitpicking; it boils down to whether you like to
think about the copy constructor in this case as a "single constructor
needed for constructing s from t" or "a copy initialization stage after
skipping the unneeded conversion of t into type of s". I guess logically
it could mean both. Fortunately, it seems latest C++ standards have given
up logical reasoning in this area and only talk about the *form* of the
statement (8.5/16, [dcl.init]):
"The initialization that occurs in the forms
T x(a);
T x{a};
as well as in new expressions (5.3.4), static_cast expressions (5.2.9),
functional notation type conversions (5.2.3), and base and member
initializers (12.6.2) is called direct-initialization."
So this is direct initialization, full stop.
Cheers
Paavo