3.8.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
fcppt::variant Namespace Reference

Contains fcppt::variant::object and helper types/functions for it. More...

Classes

struct  is_object
 
struct  is_object< fcppt::variant::object< Types... > >
 
class  object
 A class that can hold any object from a fixed set of types. More...
 

Typedefs

template<typename Types >
using dynamic_cast_types = ::metal::transform<::metal::lambda< fcppt::reference >, Types >
 The variant element types used for fcppt::variant::dynamic_cast_. More...
 
template<typename Types >
using from_list = fcppt::metal::as< fcppt::variant::object, Types >
 Declares a variant using a metal::list. More...
 
using size_type = std::size_t
 An integer type used to describe a type index. More...
 
template<typename Variant >
using types_of = typename fcppt::variant::detail::types_of< Variant >::type
 The types of a variant. More...
 

Functions

template<typename Function , typename... Variants>
decltype(auto) apply (Function const &_function, Variants &&..._variants)
 
template<typename... Types, typename Compare >
bool compare (fcppt::variant::object< Types... > const &_left, fcppt::variant::object< Types... > const &_right, Compare const &_compare)
 Compares two variants using a Compare function. More...
 
template<typename... Types>
bool operator== (fcppt::variant::object< Types... > const &_left, fcppt::variant::object< Types... > const &_right)
 Compares two variants for equality. More...
 
template<typename... Types>
bool operator!= (fcppt::variant::object< Types... > const &_a, fcppt::variant::object< Types... > const &_b)
 Compares two variants for inequality. More...
 
template<typename... Types>
bool operator< (fcppt::variant::object< Types... > const &_left, fcppt::variant::object< Types... > const &_right)
 Tests if one variant is less than another. More...
 
template<typename... Elements>
std::string current_type_name (fcppt::variant::object< Elements... > const &_variant)
 Returns the type name of the current type. More...
 
template<typename Types , typename Cast , typename Base >
fcppt::optional::object< fcppt::variant::from_list< fcppt::variant::dynamic_cast_types< Types > > > dynamic_cast_ (Base &_base)
 Tries several dynamic casts. More...
 
template<typename Type , typename... Elements>
Type & get_unsafe (fcppt::variant::object< Elements... > &_object)
 Free get function. More...
 
template<typename Type , typename... Elements>
Type const & get_unsafe (fcppt::variant::object< Elements... > const &_object)
 Free get function. More...
 
template<typename Type , typename... Elements>
bool holds_type (fcppt::variant::object< Elements... > const &_variant)
 Checks if a type is held by a variant. More...
 
template<typename Variant , typename... Functions, typename Enable = fcppt::variant::is_object<fcppt::type_traits::remove_cv_ref_t<Variant>>>
decltype(auto) match (Variant &&_variant, Functions const &..._functions)
 Matches a variant with a function for each element type. More...
 
template<typename... Types, typename Ch , typename Traits >
std::basic_ostream< Ch, Traits > & operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::variant::object< Types... > const &_object)
 Outputs the value held by the variant to a basic_ostream. More...
 
template<typename Type , typename Variant >
fcppt::optional::object< Type > to_optional (Variant &&_variant)
 Converts a variant and a type to an optional. More...
 
template<typename Type , typename Variant >
fcppt::optional::reference< Type > to_optional_ref (Variant &_variant)
 Converts a variant and a type to an optional reference. More...
 
template<typename... Types>
std::type_info const & type_info (fcppt::variant::object< Types... > const &_variant)
 Returns an std::type_info of the held type. More...
 

Detailed Description

Contains fcppt::variant::object and helper types/functions for it.

Function Documentation

◆ apply()

template<typename Function , typename... Variants>
decltype(auto) fcppt::variant::apply ( Function const &  _function,
Variants &&...  _variants 
)