Default move constructor that accepts a const parameter

When defining a class, the following is valid:

T(const T&&) = default;

I read about move constructors here , and it explains how the default can still be declared implicitly:

A class can have several move constructors, for example. both T::T(const T&&)and T::T(T&&). If there are certain custom move constructors, the user can still force the constructor with the default keyword to generate an implicitly declared move.

The bottom of the page mentions the CWG 2171 defect report:

CWG 2171 C ++ 14
X(const X&&) = defaultwas nontrivial, made trivial.

Perhaps the wiki entry has only an error and the CWG 2171 refers only to the copy constructor, and not to the move constructor?

+4
source share
1 answer

From draft n4296:

8.4.2.1 Explicit default functions:

The function explicitly set by default should

(1.1) is a special member function,

(1.2) - have the same type of function declared (with the possible exception of different ref-qualifiers, and with the exception that, in the case of a copy, the constructor or copy assignment operator, the parameter type can be "reference to non-constant T", where T is the name of the member function class) as if it were declared implicitly , and

(1.3) - .

12.8.10 :

X :: ( & &)


, :

T(const T&&) = default;

, :

T(T&&)
+2

Source: https://habr.com/ru/post/1666273/


All Articles