Consider the following classes.
struct with_copy {
with_copy() = default;
with_copy(with_copy const&) {}
with_copy& operator=(with_copy c
C++11, or rather n3485, [class.copy]/9:
If the definition of a class
Xdoes not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if
Xdoes not have a user-declared copy constructor,Xdoes not have a user-declared copy assignment operator,Xdoes not have a user-declared move assignment operator,Xdoes not have a user-declared destructor, and- the move constructor would not be implicitly defined as deleted.
and /11:
An implicitly-declared copy/move constructor is an
inline publicmember of its class. A defaulted copy/ move constructor for a classXis defined as deleted (8.4.3) ifXhas:
- [...]
- for the copy constructor, a non-static data member of rvalue reference type, or
- for the move constructor, a non-static data member or direct or virtual base class with a type that does not have a move constructor and is not trivially copyable.
As with_copy is not trivially copyable, foo will have no move-constructor (it would be defined as deleted, therefore it won't be implicitly declared).
C++1y, or rather github repo commit e31867c0 from 2013-11-12; incorporating DR1402:
/9:
If the definition of a class
Xdoes not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if
Xdoes not have a user-declared copy constructor,Xdoes not have a user-declared copy assignment operator,Xdoes not have a user-declared move assignment operator, andXdoes not have a user-declared destructor.
and /11:
An implicitly-declared copy/move constructor is an
inline publicmember of its class. A defaulted copy/ move constructor for a classXis defined as deleted (8.4.3) ifXhas:
- [...]
- for the copy constructor, a non-static data member of rvalue reference type.
A defaulted move constructor that is defined as deleted is ignored by overload resolution (13.3, 13.4).
Here, foo will have a move-constructor.