I think the answer is : yes.
first the static_assert forces the constructor from "definition" to a declaration.
I am not sure exactly about the template nature of the static_assert with regard to the the 12.8 section below either...
(I apologize for the formatting...)
c
©
ISO/IEC
N3242=11-0012
7 Declarations [dcl.dcl]
2.
A declaration is a definition unless it declares a function without specifying the function’s body (8.4), it contains the extern specifier (7.1.1) or a linkage-specification 25(7.5) and neither an initializer nor a function-body, it declares a static data member in a class definition (9.4), it is a class name declaration (9.1), it is an opaque-enum-declaration(7.2), or it is a typedef declaration (7.1.3), a using-declaration(7.3.3), a static_assert-declaration(Clause 7), an attribute-declaration (Clause 7), an empty-declaration (Clause 7), or a using-directive (7.3.4)
12.8 Copying and moving class objects [class.copy]
7 A member function template is never instantiated to perform the copy of a class object to an object of its class type. [Example:
struct S {
template<typename T> S(T);
template<typename T> S(T&&);
S();
};
S f();
const S g;
void h() {
S a( f() );// does not instantiate member template;
// uses the implicitly generated move constructor
S b(g);// does not instantiate the member template;
// uses the implicitly generated copy constructor
}
— end example
]
32 When certain criteria are met, an implementation is allowed to omit the copy/move construction of a class object, even if the copy/move constructor and/or destructor for the object have side effects. In such cases, the implementation treats the source and target of the omitted copy/move operation as simply two different ways of referring to the same object, and the destruction of that object occurs at the later of the times when the two objects would have been destroyed without the optimization.
123 - This elision of copy/move operations, called copy elision, is permitted in the following circumstances (which may be combined to eliminate multiple copies):
— in a return statement in a function with a class return type, when the expression is the name of a non-volatile automatic object (other than a function or catch-clause parameter) with the same cv-unqualified type as the function return type, the copy/move operation can be omitted by constructing the automatic object directly into the function’s return value
T
that would not trigger thestatic_assert
, so no valid specialization can be generated forX
. – Carnahan2
instead of1
? – Razzledazzlestd::is_same<void, T>::value
. I changed the text accordingly. Also,X<int>
is a valid type. Just the move constructor is armed with thestatic_assert
. – Katharinekatharsis