Partager via


fonctions<variant>

get

Obtient la variante d’un objet.

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

Obtient la variante d’un objet s’il existe.

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

Retourne true si une variante existe.

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;
}

visite

Passe à la variante suivante.

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