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
Let x be either the parameter of the constructor or, for the move constructor, an xvalue referring to the parameter. Each base or non-static data member is copied/moved in the manner appropriate to its type:
if the member is an array, each element is direct-initialized with the corresponding subobject of x;
if a member m has rvalue reference type T&&, it is direct-initialized with static_cast<T&&>(x.m);
otherwise, the base or member is direct-initialized with the corresponding base or member of x.
Although, we mentioned that x is an xvalue referring to the parameter for move constructor, however, the corresponding subobject used in the initialization cannot transitive that property. The value category directly impacts which function is selected in overload resolution(i.e., the constructor). Only expressions have a value category, objects do not have such a property. The relevant issue is #4917. It makes no sense to clarify an object can have a value category. So, the improvement to these issues might be:
Let x be either an id-expression naming the parameter of type lvalue reference to type cv C of the copy constructor or, for the move constructor, if the parameter P is of type rvalue reference to type C, an xvalue static_cast<C&&>(P). Each base or non-static data member is copied/moved in the manner appropriate to its type:
if the member m is an array, let x.m designate the member, each i element is direct-initialized from x.m[i] designating the i element of x.m.
if a member m has rvalue reference type T&&, it is direct-initialized with static_cast<T&&>(x.m);
otherwise
if the base class has type T, the base subobject is direct-initialized from static_cast<cv T&>(x) if x is an lvalue, or from static_cast<T&&>(x) otherwise.
otherwise, the non-static member m is direct-initialized from x.m
Since [expr.ref] p6 and [expr.sub] p2 have defined the value category
If E1 is an lvalue, then E1.E2 is an lvalue; otherwise E1.E2 is an xvalue.
the result is an lvalue if that operand is an lvalue and an xvalue otherwise.
The explicitly defined type and the value category for x and the member or base thereof will be helpful to select the constructor for the member or base. [class.copy.assign] p12 has the same issue, which should be fixed with a similar approach.
The text was updated successfully, but these errors were encountered:
xmh0511
changed the title
[class.copy.ctor] Clarify the valute category of the initializer in the implicit defined function
[class.copy.ctor] Clarify the value category of the initializer in the implicit defined function
May 6, 2022
[class.copy.ctor] p14 says
Although, we mentioned that
x
is an xvalue referring to the parameter for move constructor, however, the corresponding subobject used in the initialization cannot transitive that property. The value category directly impacts which function is selected in overload resolution(i.e., the constructor). Only expressions have a value category, objects do not have such a property. The relevant issue is #4917. It makes no sense to clarify an object can have a value category. So, the improvement to these issues might be:Since [expr.ref] p6 and [expr.sub] p2 have defined the value category
The explicitly defined type and the value category for
x
and the member or base thereof will be helpful to select the constructor for the member or base. [class.copy.assign] p12 has the same issue, which should be fixed with a similar approach.The text was updated successfully, but these errors were encountered: