Operators available to elements of enumerations if T_EnumIsBitwise is specialized.
- Note
- This namespace exits only in the documentation to collect the operators. When parsed by a C++ compiler, the operators reside in the global namespace and functions HasBits , CountElements , ToBitwiseEnumeration and ToSequentialEnumeration reside in namespace alib.
As required, when parsed by a C++ compiler, the operators reside in the global namespace.
|
template<typename TEnum > |
static constexpr int | CountElements (TEnum value) |
|
template<typename TEnum > |
constexpr bool | HasBits (TEnum element, TEnum selection) noexcept |
|
template<typename TEnum > |
constexpr TEnum | operator& (TEnum lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator&= (TEnum &lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator+ (TEnum lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator+= (TEnum &lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator- (TEnum lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator-= (TEnum &lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator^ (TEnum lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator^= (TEnum &lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator| (TEnum lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr bool | operator|= (TEnum &lhs, TEnum rhs) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | operator~ (TEnum op) noexcept(true) |
|
template<typename TEnum > |
constexpr TEnum | ToBitwiseEnumeration (typename std::underlying_type< TEnum >::type number) |
|
template<typename TEnum > |
static constexpr std::underlying_type< TEnum >::type | ToSequentialEnumeration (TEnum element) |
|
template<typename TEnum >
constexpr bool HasBits |
( |
TEnum | element, |
|
|
TEnum | selection ) |
|
constexprnoexcept |
Tests if the integral value of the given enum element contains all bits set in selection . In other words, returns result of:
( element & selection ) == selection
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
.
- Template Parameters
-
TEnum | Enumeration type. Deduced by the compiler. |
- Parameters
-
element | Bitset to be tested. |
selection | Second operand. |
- Returns
true
if all bits of selection are set in element .
template<typename TEnum >
constexpr TEnum operator+ |
( |
TEnum | lhs, |
|
|
TEnum | rhs ) |
|
constexprnoexcept |
Alias to bitwise or operator useable with scoped enum types.
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
and if T_EnumIsArithmetical is not specialized to inherit std::true_type
. The latter is to avoid ambiguities in situations where an enum is both, arithmetical and bitwise.
- Template Parameters
-
- Parameters
-
lhs | First operand. |
rhs | Second operand. |
- Returns
- The result of a bitwise or operation of the underlying enum values.
Definition at line 346 of file bitwise.hpp.
template<typename TEnum >
constexpr TEnum operator+= |
( |
TEnum & | lhs, |
|
|
TEnum | rhs ) |
|
constexprnoexcept |
Alias for bitwise or assignment operator useable with scoped enum types.
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
and if T_EnumIsArithmetical is not specialized to inherit std::true_type
. The latter is to avoid ambiguities in situations where an enum is both, arithmetical and bitwise.
- Template Parameters
-
- Parameters
-
[in,out] | lhs | Reference to the first operand. Receives the result. |
| rhs | Second operand. |
- Returns
- The new value of lhs which is set to
lhs | rhs
.
Definition at line 373 of file bitwise.hpp.
template<typename TEnum >
constexpr TEnum operator- |
( |
TEnum | lhs, |
|
|
TEnum | rhs ) |
|
constexprnoexcept |
Removes bit(s) found in rhs from lhs an returns result. This is a shortcut to:
lhs & !rhs
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
and if T_EnumIsArithmetical is not specialized to inherit std::true_type
. The latter is to avoid ambiguities in situations where an enum is both, arithmetical and bitwise.
- Template Parameters
-
- Parameters
-
lhs | First operand. |
rhs | Second operand. |
- Returns
- The result of
lhs & !rhs
.
Definition at line 402 of file bitwise.hpp.
template<typename TEnum >
constexpr TEnum operator-= |
( |
TEnum & | lhs, |
|
|
TEnum | rhs ) |
|
constexprnoexcept |
Removes bit(s) found in rhs from lhs . This is a shortcut to:
lhs &= !rhs
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
and if T_EnumIsArithmetical is not specialized to inherit std::true_type
. The latter is to avoid ambiguities in situations where an enum is both, arithmetical and bitwise.
- Template Parameters
-
- Parameters
-
[in,out] | lhs | Reference to the first operand. Receives the result. |
| rhs | Second operand. |
- Returns
- The new value of lhs which is set to
lhs & ( ~rhs )
.
Definition at line 431 of file bitwise.hpp.
template<typename TEnum >
static constexpr std::underlying_type< TEnum >::type ToSequentialEnumeration |
( |
TEnum | element | ) |
|
|
inlinestaticconstexpr |
Returns the sequentially enumerated number derived from the given bitwise enumeration value. In other words, the positon of the most significant bit set in the underlying integral of the given enum element
is returned.
In debug-compilations an ALib assertion is raised in case that the given value is not a single enum element but a combination of bits.
Selected by the compiler only if T_EnumIsBitwise is specialized for template enum type TEnum to inherit std::true_type
.
- See also
- The reverse function ToBitwiseEnumeration.
- Template Parameters
-
TEnum | A bitwise defined enumeration type. Deduced by the compiler. |
- Parameters
-
element | An enumeration value. |
- Returns
- The sequential number of an element of an enum type which is defined bitwise.