You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[expr.new] p19.2 makes it clear that we perform direct-initialization, which means the copy constructor of T is not called in a case like this:
struct T { };
T f();
T * p = new T(f());
However, p21 then talks about "the constructor" in the class object case, which could lead to the misunderstanding that some constructor is always called. This is amplified because allocation/deallocation functions are mentioned in the same sentence, and accessibility to those is always checked, even if the allocation is elided.
Suggestion: add "(if any)" after "the constructor". (The "no constructor" case also arises for aggregate initialization, it seems.)
Do we have a good cross-reference target when we want to talk about "mandatory copy elision"?
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[expr.new] Can the constructor call be elided in a new-expression?
[expr.new] Is a copy constructor call elided in a new-expression?
Nov 16, 2018
[expr.new] p19.2 makes it clear that we perform direct-initialization, which means the copy constructor of T is not called in a case like this:
However, p21 then talks about "the constructor" in the class object case, which could lead to the misunderstanding that some constructor is always called. This is amplified because allocation/deallocation functions are mentioned in the same sentence, and accessibility to those is always checked, even if the allocation is elided.
Suggestion: add "(if any)" after "the constructor". (The "no constructor" case also arises for aggregate initialization, it seems.)
Do we have a good cross-reference target when we want to talk about "mandatory copy elision"?
The text was updated successfully, but these errors were encountered: