Types without a move constructor, but with a copy constructor that accepts const T&
arguments, satisfy std::is_move_constructible
. For example, in the following code:
#include <type_traits>
struct T {
T(const T&) {}
//T(T&&) = delete;
};
int main() {
static_assert(std::is_move_constructible<T>::value, "not move constructible");
return 0;
}
T
will have no implicit move constructor as it has a user-defined copy constructor.
However, if we uncomment the explicit delete of the move constructor, the code no longer compiles. Why is this? I would have expected that the explicit copy constructor would still satisfy std::is_move_constructible
.
Does overload play a role, choosing the declared move constructor and then failing because it is deleted?
Aucun commentaire:
Enregistrer un commentaire