ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::enumops::bitwise Namespace Reference

Description:

Operators available to elements of enumerations if BitwiseTraits 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.

Function Index:

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
constexpr int CountElements (TEnum value)
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
constexpr bool HasBits (TEnum element, TEnum selection) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
constexpr bool HasOneOf (TEnum element, TEnum selection) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator& (TEnum lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator&= (TEnum &lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum operator+ (TEnum lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum operator+= (TEnum &lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum operator- (TEnum lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum operator-= (TEnum &lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator^ (TEnum lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator^= (TEnum &lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator| (TEnum lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator|= (TEnum &lhs, TEnum rhs) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum operator~ (TEnum op) noexcept
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
constexpr TEnum ToBitwiseEnumeration (typename std::underlying_type< TEnum >::type number)
 
template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
constexpr std::underlying_type< TEnum >::type ToSequentialEnumeration (TEnum element)
 

Function Details:

◆ CountElements()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
int alib::enumops::bitwise::CountElements ( TEnum value)
constexpr

Returns the number of bitwise enumeration elements set in the given value. In other words, the bits given in value are counted and the number is returned.

Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Parameters
valueA single or composite selection of bits.
Returns
The result of a call to alib::lang::BitCount().

Definition at line 373 of file bitwise.inl.

Here is the call graph for this function:

◆ HasBits()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
bool alib::enumops::bitwise::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 BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type. Deduced by the compiler.
Parameters
elementBitset to be tested.
selectionSecond operand.
Returns
true if all bits of selection are set in element.

Definition at line 336 of file bitwise.inl.

Here is the call graph for this function:

◆ HasOneOf()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
bool alib::enumops::bitwise::HasOneOf ( TEnum element,
TEnum selection )
constexprnoexcept

Tests if the integral value of the given enum element contains at least one of the bits set in selection. In other words, returns result of:

  ( element & selection ) != 0

Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type. Deduced by the compiler.
Parameters
elementBitset to be tested.
selectionSecond operand.
Returns
true if one of the bits of selection are set in element.

Definition at line 357 of file bitwise.inl.

Here is the call graph for this function:

◆ operator&()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator& ( TEnum lhs,
TEnum rhs )
constexprnoexcept

Bitwise and operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
The result of a bitwise and operation of the underlying enum values.

Definition at line 119 of file bitwise.inl.

◆ operator&=()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator&= ( TEnum & lhs,
TEnum rhs )
constexprnoexcept

Bitwise assignment operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
[in,out]lhsReference to the first operand. Receives the result.
rhsSecond operand.
Returns
The new value of lhs which is set to lhs & rhs.

Definition at line 136 of file bitwise.inl.

◆ operator+()

template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator+ ( TEnum lhs,
TEnum rhs )
constexprnoexcept

Alias to bitwise or operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type and if ArithmeticalTraits 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
TEnumEnumeration type.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
The result of a bitwise or operation of the underlying enum values.

Definition at line 245 of file bitwise.inl.

◆ operator+=()

template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator+= ( TEnum & lhs,
TEnum rhs )
constexprnoexcept

Alias for bitwise or assignment operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type and if ArithmeticalTraits 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
TEnumEnumeration type.
Parameters
[in,out]lhsReference to the first operand. Receives the result.
rhsSecond operand.
Returns
The new value of lhs which is set to lhs | rhs.

Definition at line 265 of file bitwise.inl.

◆ operator-()

template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::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 BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type and if ArithmeticalTraits 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
TEnumEnumeration type.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
The result of lhs & !rhs.

Definition at line 288 of file bitwise.inl.

◆ operator-=()

template<typename TEnum>
requires ( alib::enumops::IsBitwise <TEnum> && !alib::enumops::IsArithmetical<TEnum> )
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::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 BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type and if ArithmeticalTraits 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
TEnumEnumeration type.
Parameters
[in,out]lhsReference to the first operand. Receives the result.
rhsSecond operand.
Returns
The new value of lhs which is set to lhs & ( ~rhs ).

Definition at line 311 of file bitwise.inl.

◆ operator^()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator^ ( TEnum lhs,
TEnum rhs )
constexprnoexcept

Bitwise xor operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
The result of a bitwise xor operation of the underlying enum values.

Definition at line 187 of file bitwise.inl.

◆ operator^=()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator^= ( TEnum & lhs,
TEnum rhs )
constexprnoexcept

Bitwise xor assignment operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
[in,out]lhsReference to the first operand. Receives the result.
rhsSecond operand.
Returns
The new value of lhs which is set to lhs ^ rhs.

Definition at line 204 of file bitwise.inl.

◆ operator|()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator| ( TEnum lhs,
TEnum rhs )
constexprnoexcept

Bitwise or operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
The result of a bitwise or operation of the underlying enum values.

Definition at line 153 of file bitwise.inl.

◆ operator|=()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator|= ( TEnum & lhs,
TEnum rhs )
constexprnoexcept

Bitwise or assignment operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Template Parameters
TEnumEnumeration type.
Parameters
[in,out]lhsReference to the first operand. Receives the result.
rhsSecond operand.
Returns
The new value of lhs which is set to lhs | rhs.

Definition at line 170 of file bitwise.inl.

◆ operator~()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
ALIB_EXPORT constexpr TEnum alib::enumops::bitwise::operator~ ( TEnum op)
constexprnoexcept

Bitwise not operator usable with scoped enum types.
Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

Note
To remove one or more bits from a scoped enum value, operator &= with this operator applied to op can be used. A shortcut to this is given with operator-=.
Template Parameters
TEnumEnumeration type.
Parameters
opThe operand to be negated.
Returns
The result of a bitwise negation of op.

Definition at line 224 of file bitwise.inl.

◆ ToBitwiseEnumeration()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
TEnum alib::enumops::bitwise::ToBitwiseEnumeration ( typename std::underlying_type< TEnum >::type number)
constexpr

Returns the bitwise enumeration element of TEnum from a given sequential enumeration.

Selected by the compiler only if BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

See also
The reverse function ToSequentialEnumeration.
Template Parameters
TEnumAn enumeration type which is defined to be "bitwise".
Parameters
numberA sequentially enumerated number, for which the corresponding bitwise enumeration element is requested. bitwise enumeration.
Returns
Returns enum-element 1 << number.

Definition at line 30 of file bitwise_iterable_conversion.inl.

Here is the call graph for this function:

◆ ToSequentialEnumeration()

template<typename TEnum>
requires alib::enumops::IsBitwise<TEnum>
std::underlying_type< TEnum >::type alib::enumops::bitwise::ToSequentialEnumeration ( TEnum element)
constexpr

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 BitwiseTraits is specialized for template enum type TEnum to inherit std::true_type.

See also
The reverse function ToBitwiseEnumeration.
Template Parameters
TEnumA bitwise defined enumeration type. Deduced by the compiler.
Parameters
elementAn enumeration value.
Returns
The sequential number of an element of an enum type which is defined bitwise.

Definition at line 56 of file bitwise_iterable_conversion.inl.

Here is the call graph for this function: