4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::container::bitfield::object< ElementType, InternalType > Class Template Reference

Detailed Description

template<typename ElementType, typename InternalType = fcppt::container::bitfield::default_internal_type>
class fcppt::container::bitfield::object< ElementType, InternalType >

A statically sized bitfield.

Template Parameters
ElementTypeAn enumeration type.
InternalTypeThe internal storage type. Must be unsigned. This is fcppt::container::bitfield::default_internal_type by default.

See fcppt.container.bitfield for more information.

Public Types

using element_type = ElementType
 
using internal_type
 The value type of the underlying array.
 
using static_size = fcppt::enum_::size<element_type>
 The number of array elements.
 
using array_type = fcppt::container::bitfield::array<static_size, internal_type>
 The internal array type.
 
using array_size = fcppt::array::size<array_type>
 The size of the underlying array.
 
using size_type = typename static_size::value_type
 The size type which is taken from static_size.
 
using value_type = fcppt::container::bitfield::value_type
 The value type, which is bool.
 
using reference = fcppt::container::bitfield::proxy<array_type>
 A type denoting a reference to a mask value (a reference to a boolean, basically).
 
using const_reference = fcppt::container::bitfield::proxy<array_type const>
 A type denoting a const reference to a mask value (a reference to a boolean, basically).
 
using initializer_list_type = std::initializer_list<ElementType>
 Initializer list type used to initialize a bitfield.
 

Public Member Functions

 object (fcppt::no_init const &)
 Constructs an uninitialized bitfield.
 
 object (initializer_list_type const &)
 Constructs a bitfield using an initializer list, setting every bit from the list to true.
 
 object (array_type const &)
 Constructs a bitfield from its internal array type.
 
const_reference operator[] (ElementType) const
 Returns a const reference to the specified bit.
 
reference operator[] (ElementType)
 Returns a reference to the specified bit.
 
void set (ElementType where, value_type value)
 Sets the specified bit to true/false.
 
value_type get (ElementType) const
 Returns if the specified bit is set.
 
array_typearray ()
 Accessor to the internal array.
 
array_type const & array () const
 Const accessor to the internal array.
 

Static Public Member Functions

static object null ()
 Returns the bitfield with all bits set to zero.
 

Member Typedef Documentation

◆ array_size

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::array_size = fcppt::array::size<array_type>

The size of the underlying array.

◆ array_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::array_type = fcppt::container::bitfield::array<static_size, internal_type>

The internal array type.

◆ const_reference

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::const_reference = fcppt::container::bitfield::proxy<array_type const>

A type denoting a const reference to a mask value (a reference to a boolean, basically).

Note that this is not a bool nor an internal_type, but a proxy class.

◆ element_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::element_type = ElementType

◆ initializer_list_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::initializer_list_type = std::initializer_list<ElementType>

Initializer list type used to initialize a bitfield.

◆ internal_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::internal_type
Initial value:
std::conditional_t<
std::is_same_v<fcppt::container::bitfield::default_internal_type, InternalType>,
fcppt::container::bitfield::detail::make_internal_type<ElementType>,
InternalType>

The value type of the underlying array.

◆ reference

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::reference = fcppt::container::bitfield::proxy<array_type>

A type denoting a reference to a mask value (a reference to a boolean, basically).

Note that this is not a bool nor an internal_type, but a proxy class.

◆ size_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::size_type = typename static_size::value_type

The size type which is taken from static_size.

◆ static_size

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::static_size = fcppt::enum_::size<element_type>

The number of array elements.

◆ value_type

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
using fcppt::container::bitfield::object< ElementType, InternalType >::value_type = fcppt::container::bitfield::value_type

The value type, which is bool.

Constructor & Destructor Documentation

◆ object() [1/3]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
fcppt::container::bitfield::object< ElementType, InternalType >::object ( fcppt::no_init const & )
explicit

Constructs an uninitialized bitfield.

◆ object() [2/3]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
fcppt::container::bitfield::object< ElementType, InternalType >::object ( initializer_list_type const & )

Constructs a bitfield using an initializer list, setting every bit from the list to true.

◆ object() [3/3]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
fcppt::container::bitfield::object< ElementType, InternalType >::object ( array_type const & )
explicit

Constructs a bitfield from its internal array type.

Member Function Documentation

◆ array() [1/2]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
array_type & fcppt::container::bitfield::object< ElementType, InternalType >::array ( )
nodiscard

Accessor to the internal array.

◆ array() [2/2]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
array_type const & fcppt::container::bitfield::object< ElementType, InternalType >::array ( ) const
nodiscard

Const accessor to the internal array.

◆ get()

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
value_type fcppt::container::bitfield::object< ElementType, InternalType >::get ( ElementType ) const
nodiscard

Returns if the specified bit is set.

◆ null()

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
static object fcppt::container::bitfield::object< ElementType, InternalType >::null ( )
staticnodiscard

Returns the bitfield with all bits set to zero.

◆ operator[]() [1/2]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
reference fcppt::container::bitfield::object< ElementType, InternalType >::operator[] ( ElementType )
nodiscard

Returns a reference to the specified bit.

◆ operator[]() [2/2]

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
const_reference fcppt::container::bitfield::object< ElementType, InternalType >::operator[] ( ElementType ) const
nodiscard

Returns a const reference to the specified bit.

◆ set()

template<typename ElementType , typename InternalType = fcppt::container::bitfield::default_internal_type>
void fcppt::container::bitfield::object< ElementType, InternalType >::set ( ElementType where,
value_type value )

Sets the specified bit to true/false.