Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::variant< Types > Class Template Reference

Inherits AZStd::variant_detail::make_constructor_overloads< conjunction_v< is_copy_constructible< Types >... >, conjunction_v< is_move_constructible< Types >... > >, and AZStd::variant_detail::make_assignment_overloads< conjunction_v< is_copy_assignable< Types >... >, conjunction_v< is_move_assignable< Types >... > >.

Public Member Functions

 variant (const variant &)=default
 
 variant (variant &&)=default
 
template<class T , enable_if_t<!is_same< remove_cvref_t< T >, variant >::value, int > = 0, enable_if_t<!is_same< remove_cvref_t< T >, in_place_type_t< remove_cvref_t< T > > >::value, int > = 0, enable_if_t<!is_same< remove_cvref_t< T >, Internal::is_in_place_index_t< remove_cvref_t< T > > >::value, int > = 0, enable_if_t< variant_size< variant >::value !=0, int > = 0, class Alternative = variant_detail::best_alternative_t<T, Types...>, size_t Index = find_type::find_exactly_one_alternative_v<Alternative, Types...>, enable_if_t< is_constructible< Alternative, T >::value, int > = 0>
constexpr variant (T &&arg)
 
template<class T , class... Args, size_t Index = find_type::find_exactly_one_alternative_v<T, Types...>, enable_if_t< is_constructible< T, Args... >::value, int > = 0>
constexpr variant (in_place_type_t< T >, Args &&... args)
 
template<class T , class U , class... Args, size_t Index = find_type::find_exactly_one_alternative_v<T, Types...>, enable_if_t< is_constructible< T, std::initializer_list< U > &, Args... >::value, int > = 0>
constexpr variant (in_place_type_t< T >, std::initializer_list< U > il, Args &&... args)
 
template<size_t Index, class... Args, class = enable_if_t<(Index < variant_size_v<variant>), int>, class Alternative = variant_alternative_t<Index, variant>, enable_if_t< is_constructible< Alternative, Args... >::value, int > = 0>
constexpr variant (in_place_index_t< Index >, Args &&... args)
 
template<size_t Index, class U , class... Args, enable_if_t<(Index< variant_size< variant >::value), int > = 0, class Alternative = variant_alternative_t<Index, variant>, enable_if_t< is_constructible< Alternative, std::initializer_list< U > &, Args... >::value, int > = 0>
constexpr variant (in_place_index_t< Index >, std::initializer_list< U > il, Args &&... args)
 
constexpr variantoperator= (const variant &)=default
 
constexpr variantoperator= (variant &&)=default
 
template<class T , enable_if_t<!is_same< remove_cvref_t< T >, variant >::value, int > = 0, class Alternative = variant_detail::best_alternative_t<T, Types...>, size_t Index = find_type::find_exactly_one_alternative_v<Alternative, Types...>, enable_if_t< is_assignable< Alternative &, T >::value &&is_constructible< Alternative, T >::value, int > = 0>
constexpr auto operator= (T &&arg) -> variant &
 
template<class T , class... Args, size_t Index = find_type::find_exactly_one_alternative_v<T, Types...>, enable_if_t< is_constructible< T, Args... >::value, int > = 0>
constexpr T & emplace (Args &&... args)
 
template<class T , class U , class... Args, size_t Index = find_type::find_exactly_one_alternative_v<T, Types...>, enable_if_t< is_constructible< T, std::initializer_list< U > &, Args... >::value, int > = 0>
constexpr T & emplace (std::initializer_list< U > il, Args &&... args)
 
template<size_t Index, class... Args, enable_if_t<(Index< variant_size< variant >::value), int > = 0, class Alternative = variant_alternative_t<Index, variant>, enable_if_t< is_constructible< Alternative, Args... >::value, int > = 0>
constexpr Alternative & emplace (Args &&... args)
 
template<size_t Index, class U , class... Args, enable_if_t<(Index< variant_size< variant >::value), int > = 0, class Alternative = variant_alternative_t<Index, variant>, enable_if_t< is_constructible< Alternative, std::initializer_list< U > &, Args... >::value, int > = 0>
constexpr Alternative & emplace (std::initializer_list< U > il, Args &&... args)
 
constexpr bool valueless_by_exception () const
 Returns false if and only if the variant holds a value.
 
constexpr size_t index () const
 
template<bool Placeholder = true, enable_if_t< conjunction< bool_constant< Placeholder &&is_swappable< Types >::value &&is_move_constructible< Types >::value >... >::value, bool > = false>
constexpr void swap (variant &other)
 Overloads the std::swap algorithm for std::variant. Effectively calls lhs.swap(rhs).
 

Friends

struct variant_detail::visitor::variant
 
struct variant_detail::get_alternative::variant
 

Member Function Documentation

◆ index()

template<class... Types>
constexpr size_t AZStd::variant< Types >::index
inlineconstexpr

Returns the zero-based index of the alternative that is currently held by the variant. If the variant is valueless_by_exception, returns variant_npos.


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