bsl::variant::variant

Constructors

Synopses

Declared in <bslstl_variant.h>

Create a variant object holding a value-initialized 0th alternative.

template<class t_FIRST_ALT = t_HEAD>
requires std::is_default_constructible<t_FIRST_ALT>::value
variant();
» more...

Create a variant object holding a copy of original's alternative.

variant(variant const& original) = default;
» more...

Create a variant object holding a moved copy of original's alternative.

variant(variant&& original) = default;
» more...

Create a variant object from a std::variant original.

template<class t_STD_VARIANT>
explicit
variant(t_STD_VARIANT&& original);
» more...

Create a variant object whose contained value is initialized from t.

template<class t_TYPE>
variant(t_TYPE&& t);
» more...

Create a variant object holding a value-initialized 0th alternative using allocator.

template<class t_FIRST = t_HEAD>
requires std::is_default_constructible<t_FIRST>::value
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator);
» more...

Create a variant object holding the t_INDEX alternative from args.

template<
    std::size_t t_INDEX,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_index_t<t_INDEX> inPlaceIndex,
    t_ARGS&&... args);
» more...

Create a variant object holding a t_TYPE alternative from args.

template<
    class t_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE, t_ARGS...>::value
explicit
variant(
    bsl::in_place_type_t<t_TYPE> inPlaceType,
    t_ARGS&&... args);
» more...

Create a variant object holding a copy of original's alternative using allocator.

template<class t_FIRST = t_HEAD>
requires BloombergLP::bslstl::
                Variant_IsCopyConstructibleAll<t_FIRST, t_TAIL...>::value
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    variant const& original);
» more...

Create a variant object from a std::variant original using allocator.

template<class t_STD_VARIANT>
explicit
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    t_STD_VARIANT&& original);
» more...

Create a variant object whose contained value is initialized from t using allocator.

template<class t_TYPE>
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    t_TYPE&& t);
» more...

Create a variant object holding a moved copy of original's alternative using allocator.

template<class t_FIRST = t_HEAD>
requires BloombergLP::bslstl::
                Variant_IsMoveConstructibleAll<t_FIRST, t_TAIL...>::value
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    variant&& original);
» more...

Create a variant object holding the t_INDEX alternative from il and args.

template<
    std::size_t t_INDEX,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_index_t<t_INDEX> inPlaceIndex,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Create a variant object holding a t_TYPE alternative from il and args.

template<
    class t_TYPE,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE,
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_type_t<t_TYPE> inPlaceType,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Create a variant object holding the t_INDEX alternative from args using allocator.

template<
    std::size_t t_INDEX,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    bsl::in_place_index_t<t_INDEX> inPlaceIndex,
    t_ARGS&&... args);
» more...

Create a variant object holding a t_TYPE alternative from args using allocator.

template<
    class t_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE, t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    bsl::in_place_type_t<t_TYPE> inPlaceType,
    t_ARGS&&... args);
» more...

Create a variant object holding the t_INDEX alternative from il and args using allocator.

template<
    std::size_t t_INDEX,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    bsl::in_place_index_t<t_INDEX> inPlaceIndex,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Create a variant object holding a t_TYPE alternative from il and args using allocator.

template<
    class t_TYPE,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE,
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t allocatorArg,
    allocator_type allocator,
    bsl::in_place_type_t<t_TYPE> inPlaceType,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Parameters

NameDescription
originalvariant to copy
tvalue used to initialize the selected alternative
allocatorArgtag selecting the allocator-extended overload
allocatorallocator used to supply memory
inPlaceIndextag selecting the t_INDEX alternative
argsarguments used to construct the selected alternative
inPlaceTypetag selecting the t_TYPE alternative
ilinitializer list used to construct the selected alternative