CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Flags< Enum, Storage > Struct Template Reference

Wrapper around an enum that allows simple use of bitwise logic operations. More...

#include <CeresEngine/Foundation/Flags.hpp>

Public Member Functions

constexpr Flags () noexcept=default
 
constexpr Flags (Enum value) noexcept
 Creates a new Flags object from the given enum value.
 
constexpr Flagsoperator= (Enum value) noexcept
 Assigns the Flags object with the given enum value.
 
constexpr Flags (const std::initializer_list< Enum > &values) noexcept
 Creates a new Flags object from a list of values.
 
constexpr Flags (const Flags &value) noexcept
 
constexpr Flagsoperator= (const Flags &rhs) noexcept
 
constexpr Flags (Storage bits) noexcept
 
constexpr bool isSet (Enum value) const noexcept
 Checks whether all of the provided bits are set.
 
constexpr bool isSet (const Flags &value) const noexcept
 Checks whether all of the provided bits are set.
 
constexpr bool isSetAny (Enum value) const noexcept
 Checks whether any of the provided bits are set.
 
constexpr bool isSetAny (const Flags &value) const noexcept
 Checks whether any of the provided bits are set.
 
constexpr Flagsset (Enum value) noexcept
 Activates all of the provided bits.
 
constexpr Flagsset (Enum value, const bool state) noexcept
 Activates or deactives all of the provided bits.
 
constexpr Flagsunset (Enum value) noexcept
 Deactivates all of the provided bits.
 
constexpr Flagsunset (const Flags< Enum > value) noexcept
 Deactivates all of the provided bits.
 
constexpr bool setIfUnset (Enum value) noexcept
 Sets a set of bits only if any of it's bits were previously unset.
 
constexpr bool unsetIfSet (Enum value) noexcept
 Unsets a set of bits only if any of it's bits were previously set.
 
constexpr bool operator== (Enum rhs) const noexcept
 
constexpr bool operator== (const Flags &rhs) const noexcept
 
constexpr bool operator== (const bool rhs) const noexcept
 
constexpr bool operator!= (Enum rhs) const noexcept
 
constexpr bool operator!= (const Flags &rhs) const noexcept
 
constexpr Flagsoperator|= (Enum rhs) noexcept
 
constexpr Flagsoperator|= (const Flags &rhs) noexcept
 
constexpr Flags operator| (Enum rhs) const noexcept
 
constexpr Flags operator| (const Flags &rhs) const noexcept
 
constexpr Flagsoperator&= (Enum rhs) noexcept
 
constexpr Flagsoperator&= (const Flags &rhs) noexcept
 
constexpr Flags operator& (Enum rhs) const noexcept
 
constexpr Flags operator& (const Flags &rhs) const noexcept
 
constexpr Flagsoperator^= (Enum rhs) noexcept
 
constexpr Flagsoperator^= (const Flags &rhs) noexcept
 
constexpr Flags operator^ (Enum rhs) const noexcept
 
constexpr Flags operator^ (const Flags &rhs) const noexcept
 
constexpr Flags operator~ () const noexcept
 
constexpr operator Enum () const noexcept
 
constexpr operator Storage () const noexcept
 
constexpr operator bool () const noexcept
 

Public Attributes

Storage raw = 0
 

Friends

constexpr Flags operator& (Enum a, Flags &b) noexcept
 

Detailed Description

template<typename Enum, typename Storage = std::underlying_type_t<Enum>>
struct CeresEngine::Flags< Enum, Storage >

Wrapper around an enum that allows simple use of bitwise logic operations.

Constructor & Destructor Documentation

◆ Flags() [1/5]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::Flags ( )
constexprdefaultnoexcept

◆ Flags() [2/5]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::Flags ( Enum  value)
inlineconstexprnoexcept

Creates a new Flags object from the given enum value.

Parameters
valueThe enum value

◆ Flags() [3/5]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::Flags ( const std::initializer_list< Enum > &  values)
inlineconstexprnoexcept

Creates a new Flags object from a list of values.

Parameters
valuesThe list of values to create from

◆ Flags() [4/5]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::Flags ( const Flags< Enum, Storage > &  value)
inlineconstexprnoexcept

◆ Flags() [5/5]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::Flags ( Storage  bits)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ isSet() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::isSet ( const Flags< Enum, Storage > &  value) const
inlineconstexprnoexcept

Checks whether all of the provided bits are set.

◆ isSet() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::isSet ( Enum  value) const
inlineconstexprnoexcept

Checks whether all of the provided bits are set.

◆ isSetAny() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::isSetAny ( const Flags< Enum, Storage > &  value) const
inlineconstexprnoexcept

Checks whether any of the provided bits are set.

◆ isSetAny() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::isSetAny ( Enum  value) const
inlineconstexprnoexcept

Checks whether any of the provided bits are set.

◆ operator bool()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::operator bool ( ) const
inlineexplicitconstexprnoexcept

◆ operator Enum()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::operator Enum ( ) const
inlineexplicitconstexprnoexcept

◆ operator Storage()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr CeresEngine::Flags< Enum, Storage >::operator Storage ( ) const
inlineexplicitconstexprnoexcept

◆ operator!=() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::operator!= ( const Flags< Enum, Storage > &  rhs) const
inlineconstexprnoexcept

◆ operator!=() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::operator!= ( Enum  rhs) const
inlineconstexprnoexcept

◆ operator&() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator& ( const Flags< Enum, Storage > &  rhs) const
inlineconstexprnoexcept

◆ operator&() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator& ( Enum  rhs) const
inlineconstexprnoexcept

◆ operator&=() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator&= ( const Flags< Enum, Storage > &  rhs)
inlineconstexprnoexcept

◆ operator&=() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator&= ( Enum  rhs)
inlineconstexprnoexcept

◆ operator=() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator= ( const Flags< Enum, Storage > &  rhs)
inlineconstexprnoexcept

◆ operator=() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator= ( Enum  value)
inlineconstexprnoexcept

Assigns the Flags object with the given enum value.

Parameters
valueThe enum value
Returns
*this

◆ operator==() [1/3]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::operator== ( const bool  rhs) const
inlineconstexprnoexcept

◆ operator==() [2/3]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::operator== ( const Flags< Enum, Storage > &  rhs) const
inlineconstexprnoexcept

◆ operator==() [3/3]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::operator== ( Enum  rhs) const
inlineconstexprnoexcept

◆ operator^() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator^ ( const Flags< Enum, Storage > &  rhs) const
inlineconstexprnoexcept

◆ operator^() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator^ ( Enum  rhs) const
inlineconstexprnoexcept

◆ operator^=() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator^= ( const Flags< Enum, Storage > &  rhs)
inlineconstexprnoexcept

◆ operator^=() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator^= ( Enum  rhs)
inlineconstexprnoexcept

◆ operator|() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator| ( const Flags< Enum, Storage > &  rhs) const
inlineconstexprnoexcept

◆ operator|() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator| ( Enum  rhs) const
inlineconstexprnoexcept

◆ operator|=() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator|= ( const Flags< Enum, Storage > &  rhs)
inlineconstexprnoexcept

◆ operator|=() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::operator|= ( Enum  rhs)
inlineconstexprnoexcept

◆ operator~()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags CeresEngine::Flags< Enum, Storage >::operator~ ( ) const
inlineconstexprnoexcept

◆ set() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::set ( Enum  value)
inlineconstexprnoexcept

Activates all of the provided bits.

◆ set() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::set ( Enum  value,
const bool  state 
)
inlineconstexprnoexcept

Activates or deactives all of the provided bits.

◆ setIfUnset()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::setIfUnset ( Enum  value)
inlineconstexprnoexcept

Sets a set of bits only if any of it's bits were previously unset.

Parameters
valueThe bits to be set
Returns
true if any of the bits in value were previously unset.

◆ unset() [1/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::unset ( const Flags< Enum value)
inlineconstexprnoexcept

Deactivates all of the provided bits.

◆ unset() [2/2]

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags & CeresEngine::Flags< Enum, Storage >::unset ( Enum  value)
inlineconstexprnoexcept

Deactivates all of the provided bits.

◆ unsetIfSet()

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr bool CeresEngine::Flags< Enum, Storage >::unsetIfSet ( Enum  value)
inlineconstexprnoexcept

Unsets a set of bits only if any of it's bits were previously set.

Parameters
valueThe bits to be unset
Returns
true if any of the bits in value were previously set.

Friends And Related Symbol Documentation

◆ operator&

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
constexpr Flags operator& ( Enum  a,
Flags< Enum, Storage > &  b 
)
friend

Member Data Documentation

◆ raw

template<typename Enum , typename Storage = std::underlying_type_t<Enum>>
Storage CeresEngine::Flags< Enum, Storage >::raw = 0

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