The rule of five says that a class needing special resource-handling should consider its destructor, copy constructor, copy assignment, move constructor, and move assignment together. A user-declared destructor, copy constructor, or copy assignment operator can prevent the compiler from implicitly providing move operations. section 6.1.4 section 6.3
The guideline connects several related choices:
- Before C++11, the rule of three grouped the destructor, copy constructor, and copy assignment operator. section 6.1.4
- Since C++11, move construction and move assignment must also be considered. section 6.1.4
- If a type cannot move, vector push_back may use copying instead, losing an optimization opportunity. section 6.1.4
- The rule of zero prefers leaving all six special member functions undeclared when the compiler-generated behavior is sufficient. section 6.3
Checking a polymorphic type
A Blob base class can be inspected with type traits rather than instantiated. Static assertions check whether it is default constructible, destructible, copy constructible, copy assignable, move constructible, and move assignable. section 6.1.4
Listing 6.10 Type traits to check for special member functions
#include <type_traits>
void check_properties()
{
... #1
static_assert(
!std::is_default_constructible_v<Race::Blob>
); #2
static_assert(
std::is_destructible_v<Race::Blob>
); #2
static_assert(
!std::is_copy_constructible_v<Race::Blob>
); #2
static_assert(
!std::is_copy_assignable_v<Race::Blob>
); #2
static_assert(
!std::is_move_constructible_v<Race::Blob>
); #2
static_assert(
!std::is_move_assignable_v<Race::Blob>
); #2
static_assert(
std::has_virtual_destructor_v<Race::Blob>
); #3
}
Inspect the compile-time assertions that reveal which special member operations Blob supports. section 6.1.4

