There are cases when you don't want your class to be copied. Classes that are very expensive to copy are one example. Another would be those subject to error due to slicing. In the past, a common way to prevent such objects from copying was by using the non-copyable idiom:
struct Noncopyable { Noncopyable() = default; Noncopyable(const Noncopyable&) = delete; Noncopyable& operator=(const Noncopyable&) = delete; }; class MyType : NonCopyable {};
Note, however, that such a class is also not movable, although it's easy to not notice it when reading the class definition. A better approach would be to just add the two missing members (the move constructor and move assignment operator) explicitly. As a rule of thumb, when declaring such special member functions, always declare all of them. This means that from C++11 onward, the preferred way would be to write the following:
struct MyTypeV2 { MyTypeV2() = default; MyTypeV2(const...