4.4.1
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
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<fcppt::mpl::list::object_concept Types>
using dynamic_cast_types = fcppt::mpl::list::map< Types, fcppt::mpl::lambda< fcppt::reference > >
 The variant element types used for fcppt::variant::dynamic_cast_.
 
template<fcppt::mpl::list::object_concept Types>
using from_list = fcppt::mpl::list::as< fcppt::variant::object, Types >
 Declares a variant using an mpl::list.
 
template<fcppt::variant::object_concept Variant, typename Element >
using has_type = fcppt::mpl::list::contains< fcppt::variant::types_of< Variant >, Element >
 Checks if a variant has a specific type.
 
template<typename Container >
using partition_result = fcppt::mpl::list::as< fcppt::tuple::object, fcppt::mpl::list::map< fcppt::variant::types_of< fcppt::type_traits::value_type< Container > >, fcppt::mpl::lambda< std::vector > > >
 The result of fcppt::variant::partition.
 
using size_type = std::size_t
 An integer type used to describe a type index.
 
template<fcppt::variant::object_concept Variant>
using types_of = typename fcppt::variant::detail::types_of< std::remove_cvref_t< Variant > >::type
 The types of a variant.
 

Functions

template<typename Function , fcppt::variant::object_concept... Variants>
decltype(auto) apply (Function const &_function, Variants &&..._variants)
 Applies a function to the elements of several 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.
 
template<typename... Types>
bool operator== (fcppt::variant::object< Types... > const &_left, fcppt::variant::object< Types... > const &_right)
 Compares two variants for equality.
 
template<typename... Types>
bool operator!= (fcppt::variant::object< Types... > const &_a, fcppt::variant::object< Types... > const &_b)
 Compares two variants for inequality.
 
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.
 
template<typename... Elements>
std::string current_type_name (fcppt::variant::object< Elements... > const &_variant)
 Returns the type name of the current type.
 
template<fcppt::mpl::list::object_concept Types, fcppt::cast::dynamic_fun_concept Cast, typename Base >
fcppt::optional::object< fcppt::variant::from_list< fcppt::variant::dynamic_cast_types< Types > > > dynamic_cast_ (Base &_base)
 Tries several dynamic casts, returning a variant of their types.
 
template<typename Type , typename... Elements>
requires fcppt::variant::has_type_v<fcppt::variant::object<Elements...>,Type>
Type & get_unsafe (fcppt::variant::object< Elements... > &_object)
 Free get_unsafe function.
 
template<typename Type , typename... Elements>
requires fcppt::variant::has_type_v<fcppt::variant::object<Elements...>,Type>
Type const & get_unsafe (fcppt::variant::object< Elements... > const &_object)
 Free get_unsafe function.
 
template<typename Type , typename... Elements>
requires fcppt::variant::has_type_v<fcppt::variant::object<Elements...>, Type>
bool holds_type (fcppt::variant::object< Elements... > const &_variant)
 Checks if a type is held by a variant.
 
template<fcppt::variant::object_concept Variant, typename... Functions>
decltype(auto) match (Variant &&_variant, Functions const &..._functions)
 Matches a variant with a function for each element type.
 
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.
 
template<typename Container >
fcppt::variant::partition_result< Container > partition (Container &&_container)
 Partitions a container of variants into multiple containers.
 
template<typename Type , fcppt::variant::object_concept Variant>
requires fcppt::variant::has_type_v<Variant,Type>
fcppt::optional::object< Type > to_optional (Variant &&_variant)
 Converts a variant and a type to an optional.
 
template<typename Type , fcppt::variant::object_concept Variant>
requires fcppt::variant::has_type_v<Variant,std::remove_const_t<Type>>
fcppt::optional::reference< Type > to_optional_ref (Variant &_variant)
 Converts a variant and a type to an optional reference.
 
template<typename... Types>
std::type_info const & type_info (fcppt::variant::object< Types... > const &_variant)
 Returns an std::type_info of the held type.
 

Variables

template<fcppt::variant::object_concept Variant, typename Element >
constexpr bool has_type_v = fcppt::variant::has_type<Variant,Element>::value
 Checks if a variant has a specific type.
 
template<typename T >
constexpr bool is_object_v = fcppt::variant::is_object<T>::value
 Checks if a given type is an fcppt::variant::object.
 

Detailed Description

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