join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Variant< Ts > Class Template Reference

variant class. More...

#include <variant.hpp>

Inheritance diagram for join::Variant< Ts >:
Collaboration diagram for join::Variant< Ts >:

Public Types

using Base = details::VariantStorage <Ts...>
 
using DefaultEnabler
 

Public Member Functions

constexpr Variant ()=default
 default constructor.
 
constexpr Variant (const Variant &)=default
 copy constructor.
 
constexpr Variant (Variant &&)=default
 move constructor.
 
template<typename T , typename Match = match_t <T&&, Ts...>, typename = std::enable_if_t <is_unique <Match, Ts...>::value && std::is_constructible <Match, T&&>::value>>
constexpr Variant (T &&t) noexcept
 constructs a Variant holding the alternative selected by overload resolution.
 
template<typename T , typename... Args, typename = std::enable_if_t <is_unique <T, Ts...>::value && std::is_constructible <T, Args&&...>::value>>
constexpr Variant (in_place_type_t< T >, Args &&... args)
 constructs a Variant with the specified alternative T.
 
template<typename T , typename Up , typename... Args, typename = std::enable_if_t <is_unique <T, Ts...>::value && std::is_constructible <T, std::initializer_list <Up>&, Args&&...>::value>>
constexpr Variant (in_place_type_t< T >, std::initializer_list< Up > il, Args &&... args)
 constructs a Variant with the specified alternative T.
 
template<std::size_t I, typename... Args, typename = std::enable_if_t <std::is_constructible < find_element_t <I, Ts...>, Args&&...>::value>>
constexpr Variant (in_place_index_t< I >, Args &&... args)
 constructs a variant with the alternative T specified by the index I.
 
template<std::size_t I, typename Up , typename... Args, typename = std::enable_if_t <std::is_constructible < find_element_t <I, Ts...>, std::initializer_list <Up>&, Args&&...>::value>>
constexpr Variant (in_place_index_t< I >, std::initializer_list< Up > il, Args &&... args)
 constructs a variant with the alternative T specified by the index I.
 
virtual ~Variant ()=default
 destroy the Variant instance.
 
constexpr Variantoperator= (const Variant &other)=default
 copy assignment.
 
constexpr Variantoperator= (Variant &&other)=default
 move assignment.
 
template<typename T , typename Match = match_t <T&&, Ts...>>
constexpr std::enable_if_t< is_unique< Match, Ts... >::value &&std::is_constructible< Match, T && >::value, Variant & > operator= (T &&t) noexcept
 assign a Variant holding the alternative selected by overload resolution.
 
template<typename T >
constexpr std::enable_if_t< is_unique< T, Ts... >::value, bool > is () const
 check that the member type in use is the same than the one specified.
 
template<std::size_t I>
constexpr std::enable_if_t< is_index< I, Ts... >::value, bool > is () const
 check that the index in use is the same than the one specified.
 
template<typename T , typename... Args>
constexpr std::enable_if_t< is_unique< T, Ts... >::value &&std::is_constructible< T, Args &&... >::value, T & > set (Args &&...args)
 set the variable type of the object identified by type and assign it a value.
 
template<typename T , typename Up , typename... Args>
constexpr std::enable_if_t< is_unique< T, Ts... >::value &&std::is_constructible< T, std::initializer_list< Up > &, Args &&... >::value, T & > set (std::initializer_list< Up > il, Args &&... args)
 set the variable type of the object identified by type and assign it a value.
 
template<std::size_t I, typename... Args>
constexpr std::enable_if_t< std::is_constructible< find_element_t< I, Ts... >, Args &&... >::value, find_element_t< I, Ts... > & > set (Args &&...args)
 set the variable type of the object identified by index and assign it a value.
 
template<std::size_t I, class Up , class... Args>
constexpr std::enable_if_t< std::is_constructible< find_element_t< I, Ts... >, std::initializer_list< Up > &, Args &&... >::value, find_element_t< I, Ts... > & > set (std::initializer_list< Up > il, Args &&... args)
 set the variable type of the object identified by index and assign it a value.
 
template<typename T >
constexpr std::enable_if_t< is_unique< T, Ts... >::value, T & > get ()
 get the variable value of the object type identified by type.
 
template<typename T >
constexpr std::enable_if_t< is_unique< T, Ts... >::value, const T & > get () const
 get the variable value of the object type identified by type.
 
template<std::size_t I>
constexpr std::enable_if_t< is_index< I, Ts... >::value, find_element_t< I, Ts... > & > get ()
 get the variable value of the object type identified by index.
 
template<std::size_t I>
constexpr std::enable_if_t< is_index< I, Ts... >::value, const find_element_t< I, Ts... > & > get () const
 get the variable value of the object type identified by index.
 
template<typename T >
constexpr std::enable_if_t< is_unique< T, Ts... >::value, T * > getIf ()
 get the variable value address of the object type identified by type.
 
template<typename T >
constexpr std::enable_if_t< is_unique< T, Ts... >::value, const T * > getIf () const
 get the variable value address of the object type identified by type.
 
template<std::size_t I>
constexpr std::enable_if_t< is_index< I, Ts... >::value, find_element_t< I, Ts... > * > getIf ()
 get the variable value address of the object type identified by index.
 
template<std::size_t I>
constexpr std::enable_if_t< is_index< I, Ts... >::value, const find_element_t< I, Ts... > * > getIf () const
 get the variable value address of the object type identified by index.
 
constexpr std::size_t index () const noexcept
 return the index of the alternative that is currently held by the variant.
 

Protected Member Functions

constexpr bool equal (const Variant &rhs) const
 check if equal.
 
constexpr bool lower (const Variant &rhs) const
 check if lower than.
 

Friends

template<typename... _Ts>
constexpr bool operator== (const Variant< _Ts... > &lhs, const Variant< _Ts... > &rhs)
 
template<typename... _Ts>
constexpr bool operator< (const Variant< _Ts... > &lhs, const Variant< _Ts... > &rhs)
 

Detailed Description

template<typename... Ts>
class join::Variant< Ts >

variant class.

Member Typedef Documentation

◆ Base

template<typename... Ts>
using join::Variant< Ts >::Base = details::VariantStorage <Ts...>

◆ DefaultEnabler

template<typename... Ts>
using join::Variant< Ts >::DefaultEnabler
Initial value:
EnableDefault <
details::is_first_default_constructible <Ts...>::value,
Variant <Ts...>>
constexpr Variant()=default
default constructor.

Constructor & Destructor Documentation

◆ Variant() [1/8]

template<typename... Ts>
join::Variant< Ts >::Variant ( )
constexprdefault

default constructor.

◆ Variant() [2/8]

template<typename... Ts>
join::Variant< Ts >::Variant ( const Variant< Ts > & )
constexprdefault

copy constructor.

Parameters
otherobject to copy.

◆ Variant() [3/8]

template<typename... Ts>
join::Variant< Ts >::Variant ( Variant< Ts > && )
constexprdefault

move constructor.

Parameters
otherobject to move.

◆ Variant() [4/8]

template<typename... Ts>
template<typename T , typename Match = match_t <T&&, Ts...>, typename = std::enable_if_t <is_unique <Match, Ts...>::value && std::is_constructible <Match, T&&>::value>>
join::Variant< Ts >::Variant ( T && t)
inlineconstexprnoexcept

constructs a Variant holding the alternative selected by overload resolution.

Parameters
tValue convertible to one of the variant's alternatives

◆ Variant() [5/8]

template<typename... Ts>
template<typename T , typename... Args, typename = std::enable_if_t <is_unique <T, Ts...>::value && std::is_constructible <T, Args&&...>::value>>
join::Variant< Ts >::Variant ( in_place_type_t< T > ,
Args &&... args )
inlineexplicitconstexpr

constructs a Variant with the specified alternative T.

Parameters
argsarguments to initialize the contained value with.

◆ Variant() [6/8]

template<typename... Ts>
template<typename T , typename Up , typename... Args, typename = std::enable_if_t <is_unique <T, Ts...>::value && std::is_constructible <T, std::initializer_list <Up>&, Args&&...>::value>>
join::Variant< Ts >::Variant ( in_place_type_t< T > ,
std::initializer_list< Up > il,
Args &&... args )
inlineexplicitconstexpr

constructs a Variant with the specified alternative T.

Parameters
argsarguments to initialize the contained value with.

◆ Variant() [7/8]

template<typename... Ts>
template<std::size_t I, typename... Args, typename = std::enable_if_t <std::is_constructible < find_element_t <I, Ts...>, Args&&...>::value>>
join::Variant< Ts >::Variant ( in_place_index_t< I > ,
Args &&... args )
inlineexplicitconstexpr

constructs a variant with the alternative T specified by the index I.

Parameters
argsarguments to initialize the contained value with.

◆ Variant() [8/8]

template<typename... Ts>
template<std::size_t I, typename Up , typename... Args, typename = std::enable_if_t <std::is_constructible < find_element_t <I, Ts...>, std::initializer_list <Up>&, Args&&...>::value>>
join::Variant< Ts >::Variant ( in_place_index_t< I > ,
std::initializer_list< Up > il,
Args &&... args )
inlineexplicitconstexpr

constructs a variant with the alternative T specified by the index I.

Parameters
argsarguments to initialize the contained value with.

◆ ~Variant()

template<typename... Ts>
virtual join::Variant< Ts >::~Variant ( )
virtualdefault

destroy the Variant instance.

Member Function Documentation

◆ equal()

template<typename... Ts>
bool join::Variant< Ts >::equal ( const Variant< Ts > & rhs) const
inlineconstexprprotected

check if equal.

Parameters
rhsvalue to compare to.
Returns
true if equal, false otherwise.

◆ get() [1/4]

template<typename... Ts>
template<typename T >
std::enable_if_t< is_unique< T, Ts... >::value, T & > join::Variant< Ts >::get ( )
inlineconstexpr

get the variable value of the object type identified by type.

Returns
the object value.

◆ get() [2/4]

template<typename... Ts>
template<std::size_t I>
std::enable_if_t< is_index< I, Ts... >::value, find_element_t< I, Ts... > & > join::Variant< Ts >::get ( )
inlineconstexpr

get the variable value of the object type identified by index.

Returns
the object value.

◆ get() [3/4]

template<typename... Ts>
template<typename T >
std::enable_if_t< is_unique< T, Ts... >::value, const T & > join::Variant< Ts >::get ( ) const
inlineconstexpr

get the variable value of the object type identified by type.

Returns
the object value.

◆ get() [4/4]

template<typename... Ts>
template<std::size_t I>
std::enable_if_t< is_index< I, Ts... >::value, const find_element_t< I, Ts... > & > join::Variant< Ts >::get ( ) const
inlineconstexpr

get the variable value of the object type identified by index.

Returns
the object value.

◆ getIf() [1/4]

template<typename... Ts>
template<typename T >
std::enable_if_t< is_unique< T, Ts... >::value, T * > join::Variant< Ts >::getIf ( )
inlineconstexpr

get the variable value address of the object type identified by type.

Returns
the object value address if type is correct, nullptr otherwise.

◆ getIf() [2/4]

template<typename... Ts>
template<std::size_t I>
std::enable_if_t< is_index< I, Ts... >::value, find_element_t< I, Ts... > * > join::Variant< Ts >::getIf ( )
inlineconstexpr

get the variable value address of the object type identified by index.

Returns
the object value address if index is correct, nullptr otherwise.

◆ getIf() [3/4]

template<typename... Ts>
template<typename T >
std::enable_if_t< is_unique< T, Ts... >::value, const T * > join::Variant< Ts >::getIf ( ) const
inlineconstexpr

get the variable value address of the object type identified by type.

Returns
the object value address if type is correct, nullptr otherwise.

◆ getIf() [4/4]

template<typename... Ts>
template<std::size_t I>
std::enable_if_t< is_index< I, Ts... >::value, const find_element_t< I, Ts... > * > join::Variant< Ts >::getIf ( ) const
inlineconstexpr

get the variable value address of the object type identified by index.

Returns
the object value address if index is correct, nullptr otherwise.

◆ index()

template<typename... Ts>
std::size_t join::Variant< Ts >::index ( ) const
inlineconstexprnoexcept

return the index of the alternative that is currently held by the variant.

Returns
the index of the alternative that is currently held by the variant.

◆ is() [1/2]

template<typename... Ts>
template<typename T >
std::enable_if_t< is_unique< T, Ts... >::value, bool > join::Variant< Ts >::is ( ) const
inlineconstexpr

check that the member type in use is the same than the one specified.

Returns
true if the type is the same, false otherwise.

◆ is() [2/2]

template<typename... Ts>
template<std::size_t I>
std::enable_if_t< is_index< I, Ts... >::value, bool > join::Variant< Ts >::is ( ) const
inlineconstexpr

check that the index in use is the same than the one specified.

Returns
true if the index is the same, false otherwise.

◆ lower()

template<typename... Ts>
bool join::Variant< Ts >::lower ( const Variant< Ts > & rhs) const
inlineconstexprprotected

check if lower than.

Parameters
rhsvalue to compare to.
Returns
true if lower than, false otherwise.

◆ operator=() [1/3]

template<typename... Ts>
Variant & join::Variant< Ts >::operator= ( const Variant< Ts > & other)
constexprdefault

copy assignment.

Parameters
otherobject to copy.
Returns
a reference of the current object.

◆ operator=() [2/3]

template<typename... Ts>
template<typename T , typename Match = match_t <T&&, Ts...>>
std::enable_if_t< is_unique< Match, Ts... >::value &&std::is_constructible< Match, T && >::value, Variant & > join::Variant< Ts >::operator= ( T && t)
inlineconstexprnoexcept

assign a Variant holding the alternative selected by overload resolution.

Parameters
tValue convertible to one of the variant's alternatives
Returns
a reference of the current object.

◆ operator=() [3/3]

template<typename... Ts>
Variant & join::Variant< Ts >::operator= ( Variant< Ts > && other)
constexprdefault

move assignment.

Parameters
otherobject to move.
Returns
a reference of the current object.

◆ set() [1/4]

template<typename... Ts>
template<typename T , typename... Args>
std::enable_if_t< is_unique< T, Ts... >::value &&std::is_constructible< T, Args &&... >::value, T & > join::Variant< Ts >::set ( Args &&... args)
inlineconstexpr

set the variable type of the object identified by type and assign it a value.

Parameters
argsargument(s) to set.

◆ set() [2/4]

template<typename... Ts>
template<std::size_t I, typename... Args>
std::enable_if_t< std::is_constructible< find_element_t< I, Ts... >, Args &&... >::value, find_element_t< I, Ts... > & > join::Variant< Ts >::set ( Args &&... args)
inlineconstexpr

set the variable type of the object identified by index and assign it a value.

Parameters
argsargument(s) to set.

◆ set() [3/4]

template<typename... Ts>
template<typename T , typename Up , typename... Args>
std::enable_if_t< is_unique< T, Ts... >::value &&std::is_constructible< T, std::initializer_list< Up > &, Args &&... >::value, T & > join::Variant< Ts >::set ( std::initializer_list< Up > il,
Args &&... args )
inlineconstexpr

set the variable type of the object identified by type and assign it a value.

Parameters
argsargument(s) to set.

◆ set() [4/4]

template<typename... Ts>
template<std::size_t I, class Up , class... Args>
std::enable_if_t< std::is_constructible< find_element_t< I, Ts... >, std::initializer_list< Up > &, Args &&... >::value, find_element_t< I, Ts... > & > join::Variant< Ts >::set ( std::initializer_list< Up > il,
Args &&... args )
inlineconstexpr

set the variable type of the object identified by index and assign it a value.

Parameters
argsargument(s) to set.

Friends And Related Symbol Documentation

◆ operator<

template<typename... Ts>
template<typename... _Ts>
bool operator< ( const Variant< _Ts... > & lhs,
const Variant< _Ts... > & rhs )
friend

◆ operator==

template<typename... Ts>
template<typename... _Ts>
bool operator== ( const Variant< _Ts... > & lhs,
const Variant< _Ts... > & rhs )
friend

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