mitteLib
Loading...
Searching...
No Matches
mlab::any_of< Enum, T, Default > Class Template Reference

#include <any_of.hpp>

Public Types

template<Enum E>
using value_type = T<E>
 
using enum_type = Enum
 

Public Member Functions

 any_of ()
 
template<enum_type E>
 any_of (T< E > obj)
 
 any_of (any_of &&other) noexcept
 
any_ofoperator= (any_of &&other) noexcept
 
 any_of (any_of const &)=delete
 
any_ofoperator= (any_of const &)=delete
 
 ~any_of ()
 
enum_type type () const
 
template<enum_type E>
T< E > const & get () const
 
template<enum_type E>
T< E > & get ()
 
template<enum_type E>
any_ofoperator= (T< E > obj)
 
template<Enum E>
T< E > const & get () const
 
template<Enum E>
any_of< Enum, T, Default > & operator= (T< E > obj)
 

Static Public Attributes

static constexpr enum_type default_type = Default
 

Protected Member Functions

 any_of (enum_type e)
 
template<enum_type E, class U >
void set (U &&obj)
 

Private Types

using deleter_type = void (*)(void *)
 

Private Member Functions

bool holds_memory () const
 
void assert_type_is (enum_type e) const
 
void assert_holds_memory () const
 
void free ()
 
void const * storage_allocated () const
 
void *& storage_allocated ()
 
void const * storage_in_place () const
 
void * storage_in_place ()
 

Static Private Member Functions

template<enum_type E>
static void default_deleter_fn (void *ptr)
 
template<enum_type E>
static constexpr deleter_type get_default_deleter ()
 

Private Attributes

enum_type _active
 
std::uintptr_t _storage {}
 
deleter_type _deleter {}
 

Static Private Attributes

template<enum_type E>
static constexpr bool can_be_stored_in_place_v
 

Member Typedef Documentation

◆ deleter_type

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
using mlab::any_of< Enum, T, Default >::deleter_type = void (*)(void *)
private

Pointer to a ''void delete_this_pointer(void *)'' function.

◆ enum_type

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
using mlab::any_of< Enum, T, Default >::enum_type = Enum

◆ value_type

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<Enum E>
using mlab::any_of< Enum, T, Default >::value_type = T<E>

Constructor & Destructor Documentation

◆ any_of() [1/5]

template<class Enum , template< Enum > class T, Enum Default>
mlab::any_of< Enum, T, Default >::any_of ( )

◆ any_of() [2/5]

template<class Enum , template< Enum > class T, Enum Default>
template<Enum E>
mlab::any_of< Enum, T, Default >::any_of ( T< E > obj)

◆ any_of() [3/5]

template<class Enum , template< Enum > class T, Enum Default>
mlab::any_of< Enum, T, Default >::any_of ( any_of< Enum, T, Default > && other)
noexcept

◆ any_of() [4/5]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
mlab::any_of< Enum, T, Default >::any_of ( any_of< Enum, T, Default > const & )
delete

◆ ~any_of()

template<class Enum , template< Enum > class T, Enum Default>
mlab::any_of< Enum, T, Default >::~any_of ( )

◆ any_of() [5/5]

template<class Enum , template< Enum > class T, Enum Default>
mlab::any_of< Enum, T, Default >::any_of ( enum_type e)
explicitprotected

Create uninitialized any_of with type set as e. No memory is allocated and in-place storages are zero-initialized. This is suitable to be called as a base constructor when the type is know only at runtime but assignment is just about to take place, e.g. for implementing copy constructors in subclasses.

enum struct bar { a, b };
template <bar> struct foo {};
struct any_of_foo : public any_of<bar, foo> {
// Implement custom copy cctor. Requires full enumeration of bar, which is not possible at compile time.
any_of_foo(any_of_foo const &other) : any_of<bar, foo>{other.type()} {
switch (other.type()) {
case bar::a: set<bar::a>(other.get<bar::a>()); break;
case bar::b: set<bar::b>(other.get<bar::b>()); break;
}
}
}
any_of()
Definition any_of.hpp:189

Member Function Documentation

◆ assert_holds_memory()

template<class Enum , template< Enum > class T, Enum Default>
void mlab::any_of< Enum, T, Default >::assert_holds_memory ( ) const
private

◆ assert_type_is()

template<class Enum , template< Enum > class T, Enum Default>
void mlab::any_of< Enum, T, Default >::assert_type_is ( enum_type e) const
private

◆ default_deleter_fn()

template<class Enum , template< Enum > class T, Enum Default>
template<Enum E>
void mlab::any_of< Enum, T, Default >::default_deleter_fn ( void * ptr)
staticprivate

◆ free()

template<class Enum , template< Enum > class T, Enum Default>
void mlab::any_of< Enum, T, Default >::free ( )
private

Invokes once the deleter for the pointer storage, if necessary, thus releasing the memory. Afterwards the storage is set to a nullptr with no deleter.

◆ get() [1/3]

template<class Enum , template< Enum > class T, Enum Default>
template<Enum E>
T< E > & mlab::any_of< Enum, T, Default >::get ( )
nodiscard

◆ get() [2/3]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<enum_type E>
T< E > const & mlab::any_of< Enum, T, Default >::get ( ) const
nodiscard

◆ get() [3/3]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<Enum E>
T< E > const & mlab::any_of< Enum, T, Default >::get ( ) const

◆ get_default_deleter()

template<class Enum , template< Enum > class T, Enum Default>
template<Enum E>
any_of< Enum, T, Default >::deleter_type mlab::any_of< Enum, T, Default >::get_default_deleter ( )
staticnodiscardconstexprprivate

◆ holds_memory()

template<class Enum , template< Enum > class T, Enum Default>
bool mlab::any_of< Enum, T, Default >::holds_memory ( ) const
nodiscardprivate

True if there is any memory in the heap associated to this object.

◆ operator=() [1/4]

template<class Enum , template< Enum > class T, Enum Default>
any_of< Enum, T, Default > & mlab::any_of< Enum, T, Default >::operator= ( any_of< Enum, T, Default > && other)
noexcept

◆ operator=() [2/4]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
any_of & mlab::any_of< Enum, T, Default >::operator= ( any_of< Enum, T, Default > const & )
delete

◆ operator=() [3/4]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<enum_type E>
any_of & mlab::any_of< Enum, T, Default >::operator= ( T< E > obj)

◆ operator=() [4/4]

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<Enum E>
any_of< Enum, T, Default > & mlab::any_of< Enum, T, Default >::operator= ( T< E > obj)

◆ set()

template<class Enum , template< Enum > class T, Enum Default>
template<Enum E, class U >
void mlab::any_of< Enum, T, Default >::set ( U && obj)
protected

◆ type()

template<class Enum , template< Enum > class T, Enum Default>
Enum mlab::any_of< Enum, T, Default >::type ( ) const
nodiscard

Member Data Documentation

◆ can_be_stored_in_place_v

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
template<enum_type E>
bool mlab::any_of< Enum, T, Default >::can_be_stored_in_place_v
staticconstexprprivate
Initial value:
=
sizeof(T<E>) <= sizeof(std::uintptr_t) and (alignof(std::uintptr_t) % alignof(T<E>)) == 0 and std::is_trivial_v<T<E>>

We store ''T<E>'' within a ''std::uintptr_t'' if and only of it fits, it's trivial (we do not call constructors or destructors in such a case) and it has a less strict align requirement.

◆ default_type

template<class Enum , template< Enum > class T, Enum Default = Enum{}>
enum_type mlab::any_of< Enum, T, Default >::default_type = Default
staticconstexpr

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