According to cppreference, deriving from a non-movable class should make a derived class non-movable, too. Then why does std::is_move_constructible_v
return true for the derived class?
class NonMovable{
public:
NonMovable(const NonMovable&) = default;
NonMovable(NonMovable&&) = delete;
NonMovable& operator = (const NonMovable&) = default;
NonMovable& operator = (NonMovable&&) = delete;
NonMovable() = default;
};
class Derived : public NonMovable{};
int main(){
std::cout << std::is_move_constructible_v<NonMovable> << "\n"; // 0
std::cout << std::is_move_constructible_v<Derived> << "\n"; // 1
}
Aucun commentaire:
Enregistrer un commentaire