C++ named requirements: BitmaskType

From cppreference.com
< cpp‎ | named req
C++ named requirements

Defines a type that can be used to represent a set of constant values or any combination of those values. This trait is typically implemented by integer types, std::bitset

Requirements

The bitmask type supports a finite number of bitmask elements, which are distinct non-zero values of the bitmask type, such that, for any pair Ci and Cj, Ci & Ci is nonzero and Ci & Cj is zero. In addition, the value 0

The bitwise operators operator&, operator|, operator^, operator~, operator&=, operator|=, and operator^=

The following expressions are well-formed and have the following meaning for any BitmaskType:

X |= Y sets the value Y in the object X
X &= ~Y clears the value Y in the object X
X & Y nonzero result indicates that the value Y is set in the object X

Each representable bitmask element is defined as an inline(since C++17) constexpr

Standard library

The following standard library types satisfy BitmaskType:

(since C++17)
(since C++11)
(since C++11)
(since C++11)
(since C++11)
(since C++17)
(since C++17)
(since C++17)
(since C++17)

Code that relies on some particular implementation option (e.g. int n = std::ios_base::hex ) is non-portable because std::ios_base::fmtflags is not necessarily implicitly convertible to int