Reputation: 597
What happens if std::move()
is called on a user defined object, that defines no move constructor? Is it simply copied?
Upvotes: 5
Views: 1349
Reputation:
Yes, move will fall back to copy. This is how standard containers like std::vector can implement resizing in terms of move, but remain compatible with classes which can only be copied.
However, the class may have an implicitly defined move constructor - see this guidance. http://en.cppreference.com/w/cpp/language/move_constructor#Implicitly-declared_move_constructor
Upvotes: 5