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();

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

variant(variant const& original) = default;

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

variant(variant&& original) = default;

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

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

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

template<class t_TYPE>
variant(t_TYPE&& t);

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

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

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

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

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

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

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

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

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

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

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

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

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

Parameters

Name

Description

original

variant to copy

t

value used to initialize the selected alternative

allocatorArg

tag selecting the allocator‐extended overload

allocator

allocator used to supply memory

inPlaceIndex

tag selecting the t_INDEX alternative

args

arguments used to construct the selected alternative

inPlaceType

tag selecting the t_TYPE alternative

il

initializer list used to construct the selected alternative

Created with MrDocs