A deleted answer on this question about a deleted move constructor quotes cppreference.com as saying that the is_move_constructible
trait should succeed as long as a move constructor is "accessible", even if it's not "usable".
The standard in fact requires that move-construction of the argument type be well-formed, so the answer was not quite right.
Now, the standard repeatedly uses the term "accessible" in relation to constructors referring to actual constructibility. For example:
[C++11 8.5/6]:
To default-initialize an object of type T
means:
- if
T
is a (possibly cv-qualified) class type (Clause 9), the default constructor for T
is called (and the initialization is ill-formed if T
has no accessible default constructor);
- if
T
is an array type, each element is default-initialized;
- otherwise, no initialization is performed.
If a program calls for the default initialization of an object of a const-qualified type T
, T
shall be a class type with a user-provided default constructor.
However, I can't find anywhere in the standard that states categorically whether a delete
d, explicitly-defined constructor is "accessible" or not.
A different [non-normative] quote seems to suggest that delete
d-ness and accessibility are orthogonal:
[C++11: 12.2/1]:
[..] [ Note: even if there is no call to the destructor or copy/move constructor, all the semantic restrictions, such as accessibility (Clause 11) and whether the function is deleted (8.4.3), shall be satisfied. [..]
- Have I missed a passage?
- If not, should the cppreference.com page be corrected? Can you suggest a better wording?
- Should the standard be clearer about this either way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…