C++ Library Extensions 2022.12.09
To help learn modern C++ programming
tpf::types::any< ElementTypes > Class Template Reference

#include <tpf_any.hpp>

Public Types

using element_types_t = unique_types_t< ElementTypes... >
 
using variant_t = types::to_variant_t< element_types_t >
 
using pointer_types_t = unique_types_t< std::add_pointer_t< ElementTypes >... >
 
using element_pointer_types_t = union_type_t< element_types_t, pointer_types_t >
 
using index_vector_t = types::index_tuple_vector_t< param_count >
 

Public Member Functions

 any ()
 
bool has_value () const noexcept
 
void reset () noexcept
 
void swap (any &other) noexcept
 
const std::type_info & type () const noexcept
 
template<class ValueType , class... Args, typename = std::enable_if_t< std::is_constructible_v<ValueType, remove_cv_ref_t<Args>...>>>
enable_if_in_list_t< ValueType, element_types_t, std::decay_t< ValueType > & > emplace (Args &&... args)
 
template<class ValueType , class U , class... Args>
enable_if_in_list_t< ValueType, element_types_t, std::decay_t< ValueType > & > emplace (std::initializer_list< U > il, Args &&... args)
 
std::string current_type () const noexcept
 
std::any & std () noexcept
 
const std::any & std () const noexcept
 
constexpr auto allowed_types () const noexcept
 
variant_t to_variant () const noexcept
 
template<typename Type , typename = enable_if_in_list_t<decay_remove_cv_ref_t<Type>, element_types_t>>
 any (Type &&arg)
 
 any (const any &)=default
 
 any (any &&rhs)=default
 
anyoperator= (const any &)=default
 
anyoperator= (any &&)=default
 
template<typename Type , typename = enable_if_in_list_t<decay_remove_cv_ref_t<Type>, element_types_t>>
anyoperator= (Type &&arg)
 
anyoperator= (const std::variant< ElementTypes... > &v)
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_pointer_types_t>>
Type get ()
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_pointer_types_t>>
Type get () const
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
 operator Type & ()
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
 operator const Type & () const
 
template<typename CurrentType , typename CallbackType , typename... ArgTypes, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool if_any_type (CallbackType &&callback, ArgTypes &&... args)
 
template<typename CurrentType , typename CallbackType , typename... ArgTypes, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool if_any_type (CallbackType &&callback, ArgTypes &&... args) const
 
template<auto TypeIndex, typename CallbackType , typename... ArgTypes, typename any_type = types::any<ElementTypes...>, typename element_types = typename any_type::element_types_t, typename CurrentType = select_nth_type_t<TypeIndex, element_types>, typename = enable_if_in_list_t<CurrentType, element_types_t>>
void if_any_index (CallbackType &&callback, ArgTypes &&... args)
 
template<auto TypeIndex, typename CallbackType , typename... ArgTypes, typename any_type = types::any<ElementTypes...>, typename element_types = typename any_type::element_types_t, typename CurrentType = select_nth_type_t<TypeIndex, element_types>, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool if_any_index (CallbackType &&callback, ArgTypes &&... args) const
 
virtual ~any ()
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
anyoperator+= (Type &&arg)
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
anyoperator-= (Type &&arg)
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
anyoperator*= (Type &&arg)
 
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
anyoperator/= (Type &&arg)
 

Static Public Attributes

static constexpr auto param_count = type_count_v<element_types_t>
 

Protected Attributes

std::any m_any
 
int m_dummy {}
 

Detailed Description

template<typename... ElementTypes>
class tpf::types::any< ElementTypes >

Definition at line 64 of file tpf_any.hpp.

Member Typedef Documentation

◆ element_pointer_types_t

template<typename... ElementTypes>
using tpf::types::any< ElementTypes >::element_pointer_types_t = union_type_t<element_types_t, pointer_types_t>

Definition at line 77 of file tpf_any.hpp.

◆ element_types_t

template<typename... ElementTypes>
using tpf::types::any< ElementTypes >::element_types_t = unique_types_t<ElementTypes...>

Definition at line 67 of file tpf_any.hpp.

◆ index_vector_t

template<typename... ElementTypes>
using tpf::types::any< ElementTypes >::index_vector_t = types::index_tuple_vector_t<param_count>

Definition at line 80 of file tpf_any.hpp.

◆ pointer_types_t

template<typename... ElementTypes>
using tpf::types::any< ElementTypes >::pointer_types_t = unique_types_t< std::add_pointer_t<ElementTypes>... >

Definition at line 74 of file tpf_any.hpp.

◆ variant_t

template<typename... ElementTypes>
using tpf::types::any< ElementTypes >::variant_t = types::to_variant_t<element_types_t>

Definition at line 69 of file tpf_any.hpp.

Constructor & Destructor Documentation

◆ any() [1/4]

template<typename... ElementTypes>
tpf::types::any< ElementTypes >::any ( )
inline

Definition at line 88 of file tpf_any.hpp.

◆ any() [2/4]

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<decay_remove_cv_ref_t<Type>, element_types_t>>
tpf::types::any< ElementTypes >::any ( Type &&  arg)
inline

Definition at line 139 of file tpf_any.hpp.

◆ any() [3/4]

template<typename... ElementTypes>
tpf::types::any< ElementTypes >::any ( const any< ElementTypes > &  )
default

◆ any() [4/4]

template<typename... ElementTypes>
tpf::types::any< ElementTypes >::any ( any< ElementTypes > &&  rhs)
default

◆ ~any()

template<typename... ElementTypes>
virtual tpf::types::any< ElementTypes >::~any ( )
inlinevirtual

Definition at line 257 of file tpf_any.hpp.

Member Function Documentation

◆ allowed_types()

template<typename... ElementTypes>
constexpr auto tpf::types::any< ElementTypes >::allowed_types ( ) const
inlineconstexprnoexcept

Definition at line 130 of file tpf_any.hpp.

◆ current_type()

template<typename... ElementTypes>
std::string tpf::types::any< ElementTypes >::current_type
noexcept

Definition at line 567 of file tpf_any.hpp.

Here is the call graph for this function:

◆ emplace() [1/2]

template<typename... ElementTypes>
template<class ValueType , class... Args, typename = std::enable_if_t< std::is_constructible_v<ValueType, remove_cv_ref_t<Args>...>>>
enable_if_in_list_t< ValueType, element_types_t, std::decay_t< ValueType > & > tpf::types::any< ElementTypes >::emplace ( Args &&...  args)
inline

Definition at line 113 of file tpf_any.hpp.

◆ emplace() [2/2]

template<typename... ElementTypes>
template<class ValueType , class U , class... Args>
enable_if_in_list_t< ValueType, element_types_t, std::decay_t< ValueType > & > tpf::types::any< ElementTypes >::emplace ( std::initializer_list< U >  il,
Args &&...  args 
)
inline

Definition at line 120 of file tpf_any.hpp.

◆ get() [1/2]

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_pointer_types_t>>
Type tpf::types::any< ElementTypes >::get ( )
inline

Definition at line 179 of file tpf_any.hpp.

◆ get() [2/2]

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_pointer_types_t>>
Type tpf::types::any< ElementTypes >::get ( ) const
inline

Definition at line 190 of file tpf_any.hpp.

◆ has_value()

template<typename... ElementTypes>
bool tpf::types::any< ElementTypes >::has_value ( ) const
inlinenoexcept

Definition at line 90 of file tpf_any.hpp.

Here is the caller graph for this function:

◆ if_any_index() [1/2]

template<typename... ElementTypes>
template<auto TypeIndex, typename CallbackType , typename... ArgTypes, typename any_type = types::any<ElementTypes...>, typename element_types = typename any_type::element_types_t, typename CurrentType = select_nth_type_t<TypeIndex, element_types>, typename = enable_if_in_list_t<CurrentType, element_types_t>>
void tpf::types::any< ElementTypes >::if_any_index ( CallbackType &&  callback,
ArgTypes &&...  args 
)
inline

Definition at line 240 of file tpf_any.hpp.

◆ if_any_index() [2/2]

template<typename... ElementTypes>
template<auto TypeIndex, typename CallbackType , typename... ArgTypes, typename any_type = types::any<ElementTypes...>, typename element_types = typename any_type::element_types_t, typename CurrentType = select_nth_type_t<TypeIndex, element_types>, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool tpf::types::any< ElementTypes >::if_any_index ( CallbackType &&  callback,
ArgTypes &&...  args 
) const
inline

Definition at line 251 of file tpf_any.hpp.

◆ if_any_type() [1/2]

template<typename... ElementTypes>
template<typename CurrentType , typename CallbackType , typename... ArgTypes, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool tpf::types::any< ElementTypes >::if_any_type ( CallbackType &&  callback,
ArgTypes &&...  args 
)
inline

Definition at line 215 of file tpf_any.hpp.

◆ if_any_type() [2/2]

template<typename... ElementTypes>
template<typename CurrentType , typename CallbackType , typename... ArgTypes, typename = enable_if_in_list_t<CurrentType, element_types_t>>
bool tpf::types::any< ElementTypes >::if_any_type ( CallbackType &&  callback,
ArgTypes &&...  args 
) const
inline

Definition at line 226 of file tpf_any.hpp.

◆ operator const Type &()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
tpf::types::any< ElementTypes >::operator const Type & ( ) const
inline

Definition at line 208 of file tpf_any.hpp.

◆ operator Type &()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
tpf::types::any< ElementTypes >::operator Type & ( )
inline

Definition at line 201 of file tpf_any.hpp.

◆ operator*=()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
any & tpf::types::any< ElementTypes >::operator*= ( Type &&  arg)
inline

Definition at line 280 of file tpf_any.hpp.

Here is the call graph for this function:

◆ operator+=()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
any & tpf::types::any< ElementTypes >::operator+= ( Type &&  arg)
inline

Definition at line 262 of file tpf_any.hpp.

Here is the call graph for this function:

◆ operator-=()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
any & tpf::types::any< ElementTypes >::operator-= ( Type &&  arg)
inline

Definition at line 271 of file tpf_any.hpp.

Here is the call graph for this function:

◆ operator/=()

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<remove_cv_ref_t<Type>, element_types_t>>
any & tpf::types::any< ElementTypes >::operator/= ( Type &&  arg)
inline

Definition at line 289 of file tpf_any.hpp.

Here is the call graph for this function:

◆ operator=() [1/4]

template<typename... ElementTypes>
any & tpf::types::any< ElementTypes >::operator= ( any< ElementTypes > &&  )
default

◆ operator=() [2/4]

template<typename... ElementTypes>
any & tpf::types::any< ElementTypes >::operator= ( const any< ElementTypes > &  )
default

◆ operator=() [3/4]

template<typename... ElementTypes>
any & tpf::types::any< ElementTypes >::operator= ( const std::variant< ElementTypes... > &  v)
inline

Definition at line 156 of file tpf_any.hpp.

◆ operator=() [4/4]

template<typename... ElementTypes>
template<typename Type , typename = enable_if_in_list_t<decay_remove_cv_ref_t<Type>, element_types_t>>
any & tpf::types::any< ElementTypes >::operator= ( Type &&  arg)
inline

Definition at line 150 of file tpf_any.hpp.

◆ reset()

template<typename... ElementTypes>
void tpf::types::any< ElementTypes >::reset ( )
inlinenoexcept

Definition at line 95 of file tpf_any.hpp.

◆ std() [1/2]

template<typename... ElementTypes>
const std::any & tpf::types::any< ElementTypes >::std ( ) const
inlinenoexcept

Definition at line 128 of file tpf_any.hpp.

◆ std() [2/2]

template<typename... ElementTypes>
std::any & tpf::types::any< ElementTypes >::std ( )
inlinenoexcept

Definition at line 127 of file tpf_any.hpp.

Here is the caller graph for this function:

◆ swap()

template<typename... ElementTypes>
void tpf::types::any< ElementTypes >::swap ( any< ElementTypes > &  other)
inlinenoexcept

Definition at line 100 of file tpf_any.hpp.

◆ to_variant()

template<typename... ElementTypes>
any< ElementTypes... >::variant_t tpf::types::any< ElementTypes >::to_variant
noexcept

Definition at line 504 of file tpf_any.hpp.

Here is the call graph for this function:

◆ type()

template<typename... ElementTypes>
const std::type_info & tpf::types::any< ElementTypes >::type ( ) const
inlinenoexcept

Definition at line 105 of file tpf_any.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_any

template<typename... ElementTypes>
std::any tpf::types::any< ElementTypes >::m_any
protected

Definition at line 83 of file tpf_any.hpp.

◆ m_dummy

template<typename... ElementTypes>
int tpf::types::any< ElementTypes >::m_dummy {}
protected

Definition at line 85 of file tpf_any.hpp.

◆ param_count

template<typename... ElementTypes>
constexpr auto tpf::types::any< ElementTypes >::param_count = type_count_v<element_types_t>
staticconstexpr

Definition at line 71 of file tpf_any.hpp.


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