neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
neolib::variant< Types > Class Template Reference

#include <variant.hpp>

Inheritance diagram for neolib::variant< Types >:
neolib::reference_counted< i_variant< abstract_t< Types >... > > neolib::i_variant< abstract_t< Types >... > neolib::i_reference_counted

Public Types

using abstract_type = i_variant< abstract_t< Types >... >
 
using std_type = std::variant< std::monostate, Types... >
 
- Public Types inherited from neolib::i_variant< abstract_t< Types >... >
typedef self_type abstract_type
 

Public Member Functions

 variant ()
 
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_copy_constructible_v, int > = 0>
 variant (T const &aOther)
 
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_move_constructible_v, int > = 0>
 variant (T &&aOther)
 
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_copy_constructible_v, int > = 0>
 variant (T const &aOther)
 
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_move_constructible_v, int > = 0>
 variant (abstract_type &&aOther)
 
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
 variant (T const &aValue)
 
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
 variant (T &&aValue)
 
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
 variant (T const &aValue)
 
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
 variant (T &&aValue)
 
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_copy_assignable_v, int > = 0>
self_type & operator= (T const &aOther)
 
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_move_assignable_v, int > = 0>
self_type & operator= (T &&aOther)
 
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_copy_assignable_v, int > = 0>
self_type & operator= (T const &aOther)
 
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_move_assignable_v, int > = 0>
self_type & operator= (T &&aOther)
 
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
self_type & operator= (T const &aValue)
 
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
self_type & operator= (T &&aValue)
 
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
self_type & operator= (T const &aValue)
 
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
self_type & operator= (T &&aValue)
 
std::size_t index () const override
 
- Public Member Functions inherited from neolib::reference_counted< i_variant< abstract_t< Types >... > >
 reference_counted () noexcept
 
 reference_counted (const reference_counted &aOther) noexcept
 
 ~reference_counted ()
 
reference_countedoperator= (const reference_counted &)
 
void add_ref () const noexcept override
 
void release () const override
 
int32_t use_count () const noexcept override
 
const base_typerelease_and_take_ownership () const override
 
base_typerelease_and_take_ownership () override
 
void pin () const noexcept override
 
void unpin () const override
 
i_ref_control_blockcontrol_block () override
 
- Public Member Functions inherited from neolib::i_variant< abstract_t< Types >... >
virtual ~i_variant ()=default
 
bool holds_alternative () const
 
T const * get_if () const
 
T * get_if ()
 
T const & get () const
 
T & get ()
 
- Public Member Functions inherited from neolib::i_reference_counted
virtual ~i_reference_counted ()=default
 

Static Public Attributes

static constexpr bool is_copy_constructible_v = (std::is_copy_constructible_v<Types> && ...)
 
static constexpr bool is_move_constructible_v = (std::is_move_constructible_v<Types> && ...)
 
static constexpr bool is_copy_assignable_v = (std::is_copy_assignable_v<Types> && ...)
 
static constexpr bool is_move_assignable_v = (std::is_move_assignable_v<Types> && ...)
 
template<typename T >
static constexpr bool is_alternative_v = (std::is_same_v<std::decay_t<T>, Types> || ...) || (std::is_same_v<std::decay_t<T>, abstract_t<Types>> || ...)
 

Detailed Description

template<typename... Types>
class neolib::variant< Types >

Definition at line 137 of file variant.hpp.

Member Typedef Documentation

◆ abstract_type

template<typename... Types>
using neolib::variant< Types >::abstract_type = i_variant<abstract_t<Types>...>

Definition at line 142 of file variant.hpp.

◆ std_type

template<typename... Types>
using neolib::variant< Types >::std_type = std::variant<std::monostate, Types...>

Definition at line 143 of file variant.hpp.

Constructor & Destructor Documentation

◆ variant() [1/9]

template<typename... Types>
neolib::variant< Types >::variant ( )
inline

Definition at line 153 of file variant.hpp.

◆ variant() [2/9]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_copy_constructible_v, int > = 0>
neolib::variant< Types >::variant ( T const aOther)
inline

Definition at line 158 of file variant.hpp.

◆ variant() [3/9]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_move_constructible_v, int > = 0>
neolib::variant< Types >::variant ( T &&  aOther)
inline

Definition at line 163 of file variant.hpp.

◆ variant() [4/9]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_copy_constructible_v, int > = 0>
neolib::variant< Types >::variant ( T const aOther)
inline

Definition at line 168 of file variant.hpp.

◆ variant() [5/9]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_move_constructible_v, int > = 0>
neolib::variant< Types >::variant ( abstract_type &&  aOther)
inline

Definition at line 173 of file variant.hpp.

◆ variant() [6/9]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
neolib::variant< Types >::variant ( T const aValue)
inline

Definition at line 178 of file variant.hpp.

◆ variant() [7/9]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
neolib::variant< Types >::variant ( T &&  aValue)
inline

Definition at line 183 of file variant.hpp.

◆ variant() [8/9]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
neolib::variant< Types >::variant ( T const aValue)
inline

Definition at line 188 of file variant.hpp.

◆ variant() [9/9]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
neolib::variant< Types >::variant ( T &&  aValue)
inline

Definition at line 193 of file variant.hpp.

Member Function Documentation

◆ index()

template<typename... Types>
std::size_t neolib::variant< Types >::index ( ) const
inlineoverridevirtual

Implements neolib::i_variant< abstract_t< Types >... >.

Definition at line 249 of file variant.hpp.

◆ operator=() [1/8]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_move_assignable_v, int > = 0>
self_type & neolib::variant< Types >::operator= ( T &&  aOther)
inline

Definition at line 206 of file variant.hpp.

◆ operator=() [2/8]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_move_assignable_v, int > = 0>
self_type & neolib::variant< Types >::operator= ( T &&  aOther)
inline

Definition at line 218 of file variant.hpp.

◆ operator=() [3/8]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
self_type & neolib::variant< Types >::operator= ( T &&  aValue)
inline

Definition at line 230 of file variant.hpp.

◆ operator=() [4/8]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
self_type & neolib::variant< Types >::operator= ( T &&  aValue)
inline

Definition at line 242 of file variant.hpp.

◆ operator=() [5/8]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_base_of_v< self_type, T > &&is_copy_assignable_v, int > = 0>
self_type & neolib::variant< Types >::operator= ( T const aOther)
inline

Definition at line 200 of file variant.hpp.

◆ operator=() [6/8]

template<typename... Types>
template<typename T , std::enable_if_t< std::is_same_v< T, abstract_type > &&is_copy_assignable_v, int > = 0>
self_type & neolib::variant< Types >::operator= ( T const aOther)
inline

Definition at line 212 of file variant.hpp.

◆ operator=() [7/8]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_base_of_v< self_type, T > &&!std::is_abstract_v< T >, int > = 0>
self_type & neolib::variant< Types >::operator= ( T const aValue)
inline

Definition at line 224 of file variant.hpp.

◆ operator=() [8/8]

template<typename... Types>
template<typename T , std::enable_if_t<!std::is_same_v< T, abstract_type > &&std::is_abstract_v< T >, int > = 0>
self_type & neolib::variant< Types >::operator= ( T const aValue)
inline

Definition at line 236 of file variant.hpp.

Member Data Documentation

◆ is_alternative_v

template<typename... Types>
template<typename T >
constexpr bool neolib::variant< Types >::is_alternative_v = (std::is_same_v<std::decay_t<T>, Types> || ...) || (std::is_same_v<std::decay_t<T>, abstract_t<Types>> || ...)
staticconstexpr

Definition at line 150 of file variant.hpp.

◆ is_copy_assignable_v

template<typename... Types>
constexpr bool neolib::variant< Types >::is_copy_assignable_v = (std::is_copy_assignable_v<Types> && ...)
staticconstexpr

Definition at line 146 of file variant.hpp.

◆ is_copy_constructible_v

template<typename... Types>
constexpr bool neolib::variant< Types >::is_copy_constructible_v = (std::is_copy_constructible_v<Types> && ...)
staticconstexpr

Definition at line 144 of file variant.hpp.

◆ is_move_assignable_v

template<typename... Types>
constexpr bool neolib::variant< Types >::is_move_assignable_v = (std::is_move_assignable_v<Types> && ...)
staticconstexpr

Definition at line 147 of file variant.hpp.

◆ is_move_constructible_v

template<typename... Types>
constexpr bool neolib::variant< Types >::is_move_constructible_v = (std::is_move_constructible_v<Types> && ...)
staticconstexpr

Definition at line 145 of file variant.hpp.


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