regular types

A type is regular if it has following properties:

1- default constructible
2- copyable/movable
3- destructible
4- equality comparable

std::string is a regular type:

std::string a;
std::string b = a; // a and b are distinct copies, changes in a doesn't effect b
std::string c = std::move(a);

{
std::string b;
} // b destructed

bool comp = a == b;

std::thread is not because it’s designed to be not copyable.

Regular types and procedures are one of core concept of the STL. Most of the types are regular in STL, and designing yours so will make your type composable with them. Regular types are behave like the fundamental types, like an int, and doesn’t surprise the user. With object concepts regularity of the type can be checked on the fly:

#include <concepts>

class YourType {
public:
// ...
bool operator==(const YourType &) const = default;
bool operator!=(const YourType &) const = default;
};

static_assert(std::regular<YourType>); // <-- fails if it's not a regular type

More on: