OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::bitfield< Bit > Class Template Reference

Class for manipulating and testing a group of enumeration-based bits. More...

#include <eagine/bitfield.hpp>

Public Types

using bit_type = Bit
 The enumeration type specifying individual bit values.
 
using value_type = std::make_unsigned_t< std::underlying_type_t< bit_type > >
 The Integral type used to store the bits.
 

Public Member Functions

constexpr bitfield () noexcept=default
 Default constructor.
 
constexpr bitfield (value_type bits) noexcept
 Explicit construction from the underlying interger type value.
 
constexpr bitfield (bit_type _bit) noexcept
 Construction from the bit enumeration type value.
 
constexpr auto is_empty () const noexcept
 Indicates that none of the bits are set.
 
constexpr operator bool () const noexcept
 Indicates that some of the bits are set. More...
 
constexpr operator value_type () const noexcept
 Explicit conversion to the underlying integer value type. More...
 
constexpr auto bits () const noexcept -> value_type
 Returns the bits in the underlying integer value type.
 
constexpr auto has (bit_type bit) const noexcept
 Tests if the specified bit is set. More...
 
constexpr auto has_not (bit_type bit) const noexcept
 Tests if the specified bit is not set. More...
 
template<typename... B>
constexpr auto has_all (bit_type bit, B... bits) const noexcept -> std::enable_if_t< all_are_same_v< bit_type, B... >, bool >
 Tests if all of the specified bits are set. More...
 
template<typename... B>
constexpr auto has_any (bit_type bit, B... bits) const noexcept -> std::enable_if_t< all_are_same_v< bit_type, B... >, bool >
 Tests if any of the specified bits are set. More...
 
template<typename... B>
constexpr auto has_none (bit_type bit, B... bits) const noexcept -> std::enable_if_t< all_are_same_v< bit_type, B... >, bool >
 Tests if none of the specified bits are set. More...
 
constexpr auto has_only (bit_type bit) const noexcept
 Tests if only the specified bit is set. More...
 
constexpr auto has_at_most (bit_type bit) const noexcept
 Tests if at most the specified bit is set (or is empty). More...
 
auto operator|= (bitfield b) noexcept -> bitfield &
 Bitwise-or operator.
 
auto operator&= (bitfield b) noexcept -> bitfield &
 Bitwise-and operator.
 
auto clear (bit_type b) noexcept -> bitfield &
 Clears the specified bit.
 
auto clear () noexcept -> bitfield &
 Clears all bits. More...
 

Friends

constexpr friend auto operator== (bitfield a, bitfield b) noexcept
 Equality comparison.
 
constexpr friend auto operator!= (bitfield a, bitfield b) noexcept
 Nonequality comparison.
 
constexpr friend auto operator| (bitfield a, bitfield b) noexcept -> bitfield
 Bitwise-or operator.
 
constexpr friend auto operator& (bitfield a, bitfield b) noexcept -> bitfield
 Bitwise-and operator.
 
constexpr friend auto operator~ (bitfield b) noexcept -> bitfield
 Bit inversion operator.
 

Detailed Description

template<typename Bit>
class eagine::bitfield< Bit >

Class for manipulating and testing a group of enumeration-based bits.

Member Function Documentation

◆ clear()

template<typename Bit >
auto eagine::bitfield< Bit >::clear ( ) -> bitfield&
inlinenoexcept

Clears all bits.

Postcondition
is_empty()

◆ has()

template<typename Bit >
constexpr auto eagine::bitfield< Bit >::has ( bit_type  bit) const
inlineconstexprnoexcept

◆ has_all()

template<typename Bit >
template<typename... B>
constexpr auto eagine::bitfield< Bit >::has_all ( bit_type  bit,
B...  bits 
) const -> std::enable_if_t<all_are_same_v<bit_type, B...>, bool>
inlineconstexprnoexcept

Tests if all of the specified bits are set.

See also
has
has_not
has_only
has_any
has_none
has_at_most

◆ has_any()

template<typename Bit >
template<typename... B>
constexpr auto eagine::bitfield< Bit >::has_any ( bit_type  bit,
B...  bits 
) const -> std::enable_if_t<all_are_same_v<bit_type, B...>, bool>
inlineconstexprnoexcept

Tests if any of the specified bits are set.

See also
has
has_not
has_only
has_all
has_none
has_at_most

◆ has_at_most()

template<typename Bit >
constexpr auto eagine::bitfield< Bit >::has_at_most ( bit_type  bit) const
inlineconstexprnoexcept

Tests if at most the specified bit is set (or is empty).

See also
has
has_not
has_only
has_all
has_any
has_none

◆ has_none()

template<typename Bit >
template<typename... B>
constexpr auto eagine::bitfield< Bit >::has_none ( bit_type  bit,
B...  bits 
) const -> std::enable_if_t<all_are_same_v<bit_type, B...>, bool>
inlineconstexprnoexcept

Tests if none of the specified bits are set.

See also
has
has_not
has_only
has_all
has_any
has_at_most

◆ has_not()

template<typename Bit >
constexpr auto eagine::bitfield< Bit >::has_not ( bit_type  bit) const
inlineconstexprnoexcept

Tests if the specified bit is not set.

See also
has
has_all
has_any
has_only
has_none
has_at_most

◆ has_only()

template<typename Bit >
constexpr auto eagine::bitfield< Bit >::has_only ( bit_type  bit) const
inlineconstexprnoexcept

Tests if only the specified bit is set.

See also
has
has_not
has_all
has_any
has_none
has_at_most

◆ operator bool()

template<typename Bit >
constexpr eagine::bitfield< Bit >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Indicates that some of the bits are set.

See also
is_empty

◆ operator value_type()

template<typename Bit >
constexpr eagine::bitfield< Bit >::operator value_type ( ) const
inlineexplicitconstexprnoexcept

Explicit conversion to the underlying integer value type.

See also
bits

The documentation for this class was generated from the following file:

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).