libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Namespaces | Typedefs | Functions | Variables
Variant.hpp File Reference
#include <cassert>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <functional>
#include <initializer_list>
#include <memory>
#include <new>
#include <optional>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

struct  donut::Monostate
 Unit type for representing an empty alternative in Variant. More...
 
class  std::hash< donut::Monostate >
 Specialization of std::hash for donut::Monostate. More...
 
struct  donut::BadVariantAccess
 Exception type that is thrown on an attempt to erroneously access an inactive alternative of a Variant when using a safe access function such as Variant::get(). More...
 
class  donut::Variant< Ts >
 Tagged union value type that holds a value of one of the given types. More...
 
class  std::hash< donut::Variant< Ts... > >
 Specialization of std::hash for donut::Variant. More...
 

Namespaces

 donut
 

Typedefs

template<std::size_t Index, typename V >
using donut::variant_alternative_t = typename variant_alternative< Index, V >::type
 Get the type of the variant alternative with a given index in a variant type. More...
 

Functions

constexpr bool donut::operator== (Monostate, Monostate) noexcept
 Compare two monostates for equality. More...
 
constexpr std::strong_ordering donut::operator<=> (Monostate, Monostate) noexcept
 Compare two monostates. More...
 
template<typename Visitor , detail::derived_from_template_specialization_of< Variant > V>
constexpr decltype(auto) donut::visit (Visitor &&visitor, V &&variant)
 Call a visitor functor with the currently active underlying value of a variant. More...
 
template<typename T , typename... Ts>
constexpr bool donut::holds_alternative (const Variant< Ts... > &variant) noexcept
 Check if a variant currently holds the alternative with the given type. More...
 
template<typename T , typename... Ts>
constexpr T & donut::get (Variant< Ts... > &variant)
 Access the underlying value with the given type of a variant. More...
 
template<typename T , typename... Ts>
constexpr const T & donut::get (const Variant< Ts... > &variant)
 Access the underlying value with the given type of a variant. More...
 
template<std::size_t Index, typename... Ts>
constexpr variant_alternative_t< Index, Variant< Ts... > > & donut::get (Variant< Ts... > &variant)
 Access the underlying value with the given index of a variant. More...
 
template<std::size_t Index, typename... Ts>
constexpr const variant_alternative_t< Index, Variant< Ts... > > & donut::get (const Variant< Ts... > &variant)
 Access the underlying value with the given index of a variant. More...
 
template<typename T , typename... Ts>
constexpr T * donut::get_if (Variant< Ts... > *variant) noexcept
 Access the underlying value with the given type of a variant if it is the currently active alternative. More...
 
template<typename T , typename... Ts>
constexpr const T * donut::get_if (const Variant< Ts... > *variant) noexcept
 Access the underlying value with the given type of a variant if it is the currently active alternative. More...
 
template<std::size_t Index, typename... Ts>
constexpr variant_alternative_t< Index, Variant< Ts... > > * donut::get_if (Variant< Ts... > *variant) noexcept
 Access the underlying value with the given index of a variant if it is the currently active alternative. More...
 
template<std::size_t Index, typename... Ts>
constexpr const variant_alternative_t< Index, Variant< Ts... > > * donut::get_if (const Variant< Ts... > *variant) noexcept
 Access the underlying value with the given index of a variant if it is the currently active alternative. More...
 
template<typename... Ts>
constexpr bool donut::operator== (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Compare two variants for equality. More...
 
template<typename... Ts>
constexpr bool donut::operator!= (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Compare two variants for inequality. More...
 
template<typename... Ts>
constexpr bool donut::operator< (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Check if a variant is less than another variant. More...
 
template<typename... Ts>
constexpr bool donut::operator<= (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Check if a variant is less than or equal to another variant. More...
 
template<typename... Ts>
constexpr bool donut::operator> (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Check if a variant is greater than another variant. More...
 
template<typename... Ts>
constexpr bool donut::operator>= (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Check if a variant is greater than or equal to another variant. More...
 
template<typename... Ts>
constexpr std::common_comparison_category_t< std::compare_three_way_result_t< Ts >... > donut::operator<=> (const Variant< Ts... > &a, const Variant< Ts... > &b)
 Compare two variants. More...
 
template<typename V >
constexpr detail::Matcher< V > donut::match (V &&variant)
 Choose a function overload to execute based on the active alternative of a variant. More...
 

Variables

template<typename T , typename V >
constexpr bool donut::variant_has_alternative_v = variant_has_alternative<T, V>::value
 Check if a variant type has a given type as one of its possible alternatives. More...
 
template<typename T , typename V >
constexpr std::size_t donut::variant_index_v = variant_index<T, V>::value
 Get the index of the variant alternative with a given type in a variant type. More...
 
template<typename V >
constexpr std::size_t donut::variant_size_v = variant_size<V>::value
 Get the number of alternative types of a variant type. More...