Search code examples
c++c++11constructorcopy-constructormove-constructor

Could a object be moved if this is no `copy constructor` for the class?


Could a object be moved if this is no copy constructor for the class?In another word, is it legal that a class has move constructor whereas its copy constructor is marked as deleted.If it's ok, does it go againt the rule of three, rule of five?


Solution

  • Yes it's perfectly legal.

    Think about e.g. std::unique_ptr, which is indeed movable but not copyable.