Freigeben über


<variant> -Funktionen

get

Ruft die Variante eines Objekts ab.

template <size_t I, class... Types>
    constexpr variant_alternative_t<I, variant<Types...>>& get(variant<Types...>&);
template <size_t I, class... Types>
    constexpr variant_alternative_t<I, variant<Types...>>&& get(variant<Types...>&&);
template <size_t I, class... Types>
    constexpr const variant_alternative_t<I, variant<Types...>>& get(const variant<Types...>&);
template <size_t I, class... Types>
    constexpr const variant_alternative_t<I, variant<Types...>>&& get(const variant<Types...>&&);
template <class T, class... Types>
    constexpr T& get(variant<Types...>&);
template <class T, class... Types>
    constexpr T&& get(variant<Types...>&&);
template <class T, class... Types>
    constexpr const T& get(const variant<Types...>&);
template <class T, class... Types>
    constexpr const T&& get(const variant<Types...>&&);

get_if

Ruft die Variante eines Objekts ab, wenn es vorhanden ist.

template <size_t I, class... Types>
    constexpr add_pointer_t<variant_alternative_t<I, variant<Types...>>> get_if(variant<Types...>*) noexcept;
template <size_t I, class... Types>
    constexpr add_pointer_t<const variant_alternative_t<I, variant<Types...>>> get_if(const variant<Types...>*) noexcept;
template <class T, class... Types>
    constexpr add_pointer_t<T> get_if(variant<Types...>*) noexcept;
template <class T, class... Types>
    constexpr add_pointer_t<const T> get_if(const variant<Types...>*) noexcept;

holds_alternative

Gibt zurück true , wenn eine Variante vorhanden ist.

template <class T, class... Types>
    constexpr bool holds_alternative(const variant<Types...>&) noexcept;

swap

template <class... Types>
    void swap(variant<Types...>&, variant<Types...>&) noexcept(see below);

variant_npos

namespace std {
    inline constexpr size_t variant_npos = -1;
}

Besuch

Wechselt zur nächsten Variante.

template <class Visitor, class... Variants>
    constexpr see below
        visit(Visitor&&, Variants&&...);