bsl::get

Return a reference to the alternative at index t_INDEX in obj.

Synopsis

Declared in <bslstl_variant.h>

template<
    std::size_t t_INDEX,
    class t_HEAD,
    class... t_TAIL>
variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...>>::type&
get(variant<t_HEAD, t_TAIL...>& obj);

Description

Return a reference to the alternative object at index (template parameter) t_INDEX in the specified obj. If t_INDEX is not the index of the currently active alternative, throw an exception of type bad_variant_access. t_INDEX shall be a valid index for the variant type of obj.

Return Value

reference to the alternative at index t_INDEX

Parameters

NameDescription
objvariant whose alternative is accessed