BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_variant.h
Go to the documentation of this file.
1/// @file bslstl_variant.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_variant.h -*-C++-*-
8
9#ifndef INCLUDED_BSLSTL_VARIANT
10#define INCLUDED_BSLSTL_VARIANT
11
12#include <bsls_ident.h>
13BSLS_IDENT("$Id: $")
14
15/// @defgroup bslstl_variant bslstl_variant
16/// @brief Provide a standard-compliant allocator aware variant type.
17/// @addtogroup bsl
18/// @{
19/// @addtogroup bslstl
20/// @{
21/// @addtogroup bslstl_variant
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#bslstl_variant-purpose"> Purpose</a>
26/// * <a href="#bslstl_variant-classes"> Classes </a>
27/// * <a href="#bslstl_variant-canonical-header"> Canonical Header </a>
28/// * <a href="#bslstl_variant-description"> Description </a>
29/// * <a href="#bslstl_variant-usage"> Usage </a>
30/// * <a href="#bslstl_variant-example-1-basic-variant-use"> Example 1: Basic Variant Use </a>
31/// * <a href="#bslstl_variant-example-2-variant-default-construction"> Example 2: Variant Default Construction </a>
32/// * <a href="#bslstl_variant-known-limitations"> Known limitations </a>
33///
34/// # Purpose {#bslstl_variant-purpose}
35/// Provide a standard-compliant allocator aware variant type.
36///
37/// # Classes {#bslstl_variant-classes}
38///
39/// - bsl::variant: allocator-aware implementation of `std::variant`
40/// - bsl::variant_alternative: metafunction to return a variant alternative
41/// - bsl::variant_alternative_t: alias to return type of @ref variant_alternative
42/// - bsl::variant_size: metafunction to return number of variant alternatives
43/// - bsl::variant_size_v: the result value of the @ref variant_size metafunction
44///
45/// # Canonical Header {#bslstl_variant-canonical-header}
46/// bsl_variant.h
47///
48/// # Description {#bslstl_variant-description}
49/// This component provides a class template,
50/// `bsl::variant<TYPES...>`, that is a not-yet-standardised allocator-aware
51/// version of `std::variant`. For functionality common to `std::variant`,
52/// C++23 was used as the reference specification, modulo limitations listed
53/// below. `bsl::variant` may hold and manage the lifetime of an object, known
54/// as the *contained value*, which is stored within the footprint of the
55/// `bsl::variant` object, and must be one of the template arguments `TYPES`.
56/// These template arguments are called *alternatives*, and the alternative
57/// corresponding to the contained value is said to be *active*. A
58/// `bsl::variant` object may also hold no value under exceptional
59/// circumstances.
60///
61/// A program that instantiates the definition of `variant` with no template
62/// arguments is ill-formed.
63///
64/// A reference or pointer to the contained value of a `bsl::variant` can be
65/// obtained using the free functions `get` or `get_if`, respectively. Such a
66/// reference or pointer that does not have top-level `const` may be used to
67/// modify the contained value directly, if desired.
68///
69/// `bsl::variant` is copy/move constructible when all alternatives are
70/// copy/move constructible; the resulting object holds the alternative that the
71/// source object held. `bsl::variant` can also be constructed from a value of
72/// one of the alternatives, or from an expression for which there is an
73/// unambiguous best match conversion to one of the alternatives. In addition,
74/// `bsl::variant` supports construction of an explicitly specified alternative
75/// from a variadic number of arguments.
76///
77/// If at least one alternative is allocator-aware, `bsl::variant` is
78/// allocator-aware. For an allocator-aware `bsl::variant`, each constructor
79/// has a matching allocator-extended version that specifies the allocator that
80/// will be used during the lifetime of the `bsl::variant` object to construct
81/// any allocator-aware alternative that the `bsl::variant` object holds. Note
82/// that the `bsl::variant` object itself does not allocate any memory; its
83/// footprint is large enough to hold any of its alternatives.
84///
85/// `bsl::variant` is copy/move assignable when all alternatives are copy/move
86/// assignable and copy/move constructible; if the LHS has a different active
87/// alternative than the RHS, the contained value of the LHS will be destroyed
88/// before the contained value of the new alternative is created.
89/// `bsl::variant` may also be assigned to from an expression for which there is
90/// an unambiguous best match conversion to one of the alternatives.
91///
92/// The `bsl::variant::emplace` methods, which take an explicitly specified
93/// alternative, can also be used to construct a contained value after a
94/// `bsl::variant` object has already been constructed. If the `bsl::variant`
95/// object already holds a contained value, that object will be destroyed before
96/// the specified alternative is created.
97///
98/// If an exception is thrown during an operation that changes the active
99/// alternative in a `bsl::variant` object, the `bsl::variant` object might be
100/// left in a state that holds no value, referred to as the *valueless by
101/// exception* state, indicated by the `valueless_by_exception()` method
102/// returning `true` and the `index()` method returning `bsl::variant_npos`.
103///
104/// Two `bsl::variant`s of the same type compare equal if they hold the same
105/// alternative and their contained values compare equal, or they both hold no
106/// value.
107///
108/// The `index()` method returns the zero-based index of the current
109/// alternative. Additionally, the free function @ref holds_alternative can be
110/// used to check whether an explicitly specified type is the currently active
111/// alternative.
112///
113/// Free function `bsl::visit` is provided that implements the visitor design
114/// pattern as specified by the C++ standard, modulo limitations listed below.
115///
116/// ## Usage {#bslstl_variant-usage}
117///
118///
119/// This section illustrates intended use of this component.
120///
121/// ### Example 1: Basic Variant Use {#bslstl_variant-example-1-basic-variant-use}
122///
123///
124/// First, we create a `variant` object that can hold an integer, a char, or
125/// a string. The default constructor of `bsl::variant<TYPES...>` creates the
126/// first alternative in `TYPES...`; to create a different alternative, we can
127/// provide the index or the type of the alternative to create:
128/// @code
129/// bsl::variant<int, char> v1;
130/// bsl::variant<int, char> v2(bsl::in_place_type_t<char>(), 'c');
131///
132/// assert(bsl::holds_alternative<int>(v1));
133/// assert(bsl::holds_alternative<char>(v2));
134/// @endcode
135/// Next, we create a visitor that can be called with a value of any of the
136/// alternatives:
137/// @code
138/// class MyVisitor {
139/// public:
140/// template <class t_TYPE>
141/// void operator()(const t_TYPE& value) const
142/// {
143/// bsl::cout << value << bsl::endl;
144/// }
145/// };
146/// @endcode
147/// We can now use `bsl::visit` to apply the visitor to our variant objects:
148/// @code
149/// MyVisitor visitor;
150/// bsl::visit(visitor, v1); // prints integer 0
151/// bsl::visit(visitor, v2); // prints char 'c'
152/// @endcode
153/// To retrieve a contained value, we can use the `get` free functions. If the
154/// requested alternative is not the currently active alternative, an exception
155/// of type `bsl::bad_variant_access` will be thrown.
156/// @code
157/// assert(0 == bsl::get<int>(v1));
158/// assert('c' == bsl::get<1>(v2));
159/// try {
160/// bsl::get<int>(v2);
161/// } catch (const bsl::bad_variant_access& ex) {
162/// bsl::cout << "non-active alternative requested" << bsl::endl;
163/// }
164/// @endcode
165///
166/// ### Example 2: Variant Default Construction {#bslstl_variant-example-2-variant-default-construction}
167///
168///
169/// Suppose we want to default construct a `bsl::variant` which can hold an
170/// alternative of type `S`. Type `S` is not default constructible so we use
171/// `bsl::monostate`as the first alternative to allow for default construction
172/// of the variant object.
173/// @code
174/// struct S {
175/// S(int i) : d_i(i) {}
176/// int d_i;
177/// };
178///
179/// bsl::variant<bsl::monostate, S> v3;
180/// @endcode
181/// To create an alternative of type `S`. we can use the emplace method.
182/// @code
183/// v3.emplace<S>(3);
184/// assert(bsl::holds_alternative<S>(v3));
185/// @endcode
186///
187/// ## Known limitations {#bslstl_variant-known-limitations}
188///
189///
190/// * The variadic constructors and emplace methods in C++03 are limited to one
191/// parameter.
192/// * In C++03, constructors and assignment operators that determine the
193/// best-matching alternative (instead of taking an explicitly specified
194/// alternative) require the argument type to exactly match one of the
195/// alternatives, modulo cv-qualification.
196/// * In C++03, the majority of functions do not have constraints due to
197/// language limitations. The documentation for each specific function lists
198/// any constraints that are implemented.
199/// * In C++03, the `visit` function does not support visitation of a class
200/// derived from `variant` due to language limitations.
201/// * Visitation functionality is limited to one variant. Before C++17,
202/// visitation only supports the `VISITOR(ALTERNATIVE)` form of invocation;
203/// cases where the visitor is a pointer to member are not supported.
204/// * Constexpr, triviality, and exception specifications are not implemented.
205/// * In `operator=(const variant& rhs)` and `operator=(T&& t)`, only direct
206/// copy construction from the relevant alternative is tried. This behavior
207/// differs from the standard, which requires the construction of a temporary
208/// alternative object if construction of the relevant alternative is not
209/// `noexcept` (see [variant.assign] for details). The standard behavior
210/// causes unnecessary performance degradation in cases where the alternative
211/// constructor does not throw, yet is not marked `noexcept`; this behavior
212/// is therefore not implemented in `bsl::variant`.
213/// * Due to the C++03 limitations of the `bsl::invoke_result` facility, it is
214/// not possible to explicitly specify a return type for `bsl::visit` without
215/// triggering a hard error during substitution into the overload of
216/// `bsl::visit` having a deduced return type on some C++03 compilers (Sun
217/// for example). For this reason, the overload of `bsl::visit` that takes
218/// the return type as the first, non-deduced template argument is not
219/// provided in C++03. The non-standard free function `bsl::visitR` may be
220/// used instead. `bsl::visitR` is also provided in C++11 and later for
221/// backward compatibility with the C++03 interface.
222/// @}
223/** @} */
224/** @} */
225
226/** @addtogroup bsl
227 * @{
228 */
229/** @addtogroup bslstl
230 * @{
231 */
232/** @addtogroup bslstl_variant
233 * @{
234 */
235
236#include <bslscm_version.h>
237
239#include <bslstl_hash.h>
240#include <bslstl_inplace.h>
241
242#include <bslalg_swaputil.h>
243
244#include <bslma_bslallocator.h>
248
249#include <bslmf_allocatorargt.h>
250#include <bslmf_assert.h>
251#include <bslmf_conjunction.h>
254#include <bslmf_invokeresult.h>
256#include <bslmf_isconvertible.h>
258#include <bslmf_isreference.h>
259#include <bslmf_issame.h>
261#include <bslmf_movableref.h>
263#include <bslmf_removeconst.h>
264#include <bslmf_removecvref.h>
265#include <bslmf_util.h>
266#include <bslmf_voidtype.h>
267
268#include <bsls_assert.h>
270#include <bsls_exceptionutil.h>
271#include <bsls_keyword.h>
272#include <bsls_libraryfeatures.h>
273#include <bsls_objectbuffer.h>
274#include <bsls_util.h> // 'forward<T>(V)'
275
276#include <stddef.h>
277
278// We provide one of two feature sets for 'bsl::variant', depending on the
279// capabilities of the compiler. These are the necessary compiler features for
280// the full feature set of 'bsl::variant'.
281#ifdef BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE
282#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
283#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
284#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
285// Note that 'BSLS_LIBRARYFEATURES_HAS_CPP14_INTEGER_SEQUENCE' does not require
286// a C++14 compiler.
287#ifdef BSLS_LIBRARYFEATURES_HAS_CPP14_INTEGER_SEQUENCE
288#define BSL_VARIANT_FULL_IMPLEMENTATION
289#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
290#endif // BSLS_LIBRARYFEATURES_HAS_CPP14_INTEGER_SEQUENCE
291#endif // BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
292#endif // BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
293#endif // BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE
294
295#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
296#include <type_traits>
297#include <functional> // std::invoke
298#endif // BSL_VARIANT_FULL_IMPLEMENTATION
299
300#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
301#include <initializer_list>
302#endif // BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
303
304#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
305#include <variant>
306#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
307
308#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
309// clang-format off
310// Include version that can be compiled with C++03
311// Generated on Mon Jan 13 08:31:40 2025
312// Command line: sim_cpp11_features.pl bslstl_variant.h
313
314# define COMPILING_BSLSTL_VARIANT_H
315# include <bslstl_variant_cpp03.h>
316# undef COMPILING_BSLSTL_VARIANT_H
317
318// clang-format on
319#else
320
321// When generating the expansion of a variadic template, the
322// sim_cpp11_features.pl script currently expands the primary template by the
323// required number of template arguments. If there is a partial specialization
324// that adds a non variadic template parameter, the generated primary template
325// will no longer match the expansion of such specialization. In the case of
326// 'variant' metafunction helpers, such additional template argument is always
327// a type parameter. To work around this issue, a dummy template type
328// parameter is added to the primary template and defaulted to
329// 'BSLSTL_VARIANT_NOT_A_TYPE'.
331
332namespace bsl {
333
334#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=18
335template <class t_HEAD, class... t_TAIL>
336class variant;
337#endif
338
339// TRAITS
340
341 // ===================
342 // struct variant_size
343 // ===================
344
345/// This metafunction calculates the number of alternatives in the (possibly
346/// cv-qualified) `bsl::variant` type of (template parameter)
347/// `t_BSL_VARIANT`. The primary template is not defined.
348template <class t_BSL_VARIANT>
350
351template <class t_BSL_VARIANT>
352struct variant_size<const t_BSL_VARIANT> : variant_size<t_BSL_VARIANT> {
353};
354
355template <class t_BSL_VARIANT>
356struct variant_size<volatile t_BSL_VARIANT> : variant_size<t_BSL_VARIANT> {
357};
358
359template <class t_BSL_VARIANT>
360struct variant_size<const volatile t_BSL_VARIANT>
361: variant_size<t_BSL_VARIANT> {
362};
363
364#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
365template <class t_HEAD, class... t_TAIL>
366struct variant_size<variant<t_HEAD, t_TAIL...> >
367: bsl::integral_constant<size_t, 1 + sizeof...(t_TAIL)> {
368};
369#endif
370
371#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
372/// This variable template represents the result value of the
373/// `bsl::variant_size` metafunction.
374template <class t_BSL_VARIANT>
375BSLS_KEYWORD_INLINE_VARIABLE constexpr size_t variant_size_v =
377#endif // BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
378
379/// This value is returned by `bsl::variant::index()` if
380/// `valueless_by_exception()` is `true`.
382
383 // ==========================
384 // struct variant_alternative
385 // ==========================
386
387/// This metafunction calculates the type of the alternative whose index is
388/// (template parameter) `t_INDEX` in the possibly cv-qualified
389/// `bsl::variant` type of (template parameter) `t_TYPE`. If `t_TYPE` is
390/// cv-qualified, its cv-qualifiers are applied to the alternative.
391template <size_t t_INDEX, class t_TYPE>
393
394template <size_t t_INDEX, class t_TYPE>
395struct variant_alternative<t_INDEX, const t_TYPE> {
397};
398
399template <size_t t_INDEX, class t_TYPE>
400struct variant_alternative<t_INDEX, volatile t_TYPE> {
402};
403
404template <size_t t_INDEX, class t_TYPE>
405struct variant_alternative<t_INDEX, const volatile t_TYPE> {
406 typedef
408};
409
410#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
411// 'Variant_VariantAlternativeImpl' defined to avoid 'variant<>' from the
412// sim_cpp11_features.pl script
413
414/// This component-private metafunction provides the implementation of
415/// `bsl::variant_alternative`.
416template <size_t t_INDEX,
417 class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE,
418 class... t_TAIL>
420: Variant_VariantAlternativeImpl<t_INDEX - 1, t_TAIL...> {
421};
422
423template <size_t t_INDEX>
426
427template <>
430
431template <class t_HEAD, class... t_TAIL>
432struct Variant_VariantAlternativeImpl<0, t_HEAD, t_TAIL...> {
433 typedef t_HEAD type;
434};
435
436template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
437struct variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >
438: Variant_VariantAlternativeImpl<t_INDEX, t_HEAD, t_TAIL...> {
439 BSLMF_ASSERT((t_INDEX <
441};
442
443#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
444/// @ref variant_alternative_t is an alias to the return type of the
445/// @ref variant_alternative metafunction.
446template <size_t t_INDEX, class t_TYPE>
447using variant_alternative_t =
449#endif // BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
450
451// FREE FUNCTIONS
452
453/// Efficiently exchange the values of the specified `lhs` and `rhs`
454/// objects. This method provides the no-throw guarantee if the two variant
455/// objects being swapped have the same active alternative and that
456/// alternative provides that guarantee; otherwise, this method provides the
457/// basic guarantee. If `lhs` and `rhs` do not contain the same alternative
458/// or they have unequal allocators, and an exception is thrown during the
459/// swap, either or both variant objects may be left in a valueless state or
460/// with an alternative in a moved-from state. All alternatives shall be
461/// move constructible and swappable. For simplicity of implementation,
462/// this function differs from the standard in the following :
463/// * constraints are not implemented
464/// * constexpr is not implemented
465template <class t_HEAD, class... t_TAIL>
468
469// HASH SPECIALIZATIONS
470
471/// Pass the specified `input` to the specified `hashAlg`, where `hashAlg`
472/// is a hashing algorithm.
473template <class t_HASHALG, class t_HEAD, class... t_TAIL>
474void hashAppend(t_HASHALG& hashAlg, const variant<t_HEAD, t_TAIL...>& input);
475
476// 20.7.5, value access
477
478/// Return `true` if the specified `obj` currently holds the (template
479/// parameter) `t_TYPE` alternative, and `false` otherwise. `t_TYPE` shall
480/// appear exactly once in the variant's list of alternatives.
481template <class t_TYPE, class t_HEAD, class... t_TAIL>
484#endif
485#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
486/// Return a reference to the alternative object at index (template
487/// parameter) `t_INDEX` in the specified `obj`. If `t_INDEX` is not the
488/// index of the currently active alternative, throw an exception of type
489/// @ref bad_variant_access . `t_INDEX` shall be a valid index for the variant
490/// type of `obj`.
491template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
492typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type& get(
494template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
495const typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
497template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
498typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&& get(
500template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
501const typename variant_alternative<t_INDEX,
502 variant<t_HEAD, t_TAIL...> >::type&&
504
505/// Return a reference to the alternative object with type (template
506/// parameter) `t_TYPE` in the specified `obj`. If `t_TYPE` is not the type
507/// of the currently active alternative, throw an exception of type
508/// @ref bad_variant_access . `t_TYPE` shall appear exactly once in the
509/// variant's list of alternatives.
510template <class t_TYPE, class t_HEAD, class... t_TAIL>
511t_TYPE& get(variant<t_HEAD, t_TAIL...>& obj);
512template <class t_TYPE, class t_HEAD, class... t_TAIL>
513const t_TYPE& get(const variant<t_HEAD, t_TAIL...>& obj);
514template <class t_TYPE, class t_HEAD, class... t_TAIL>
515t_TYPE&& get(variant<t_HEAD, t_TAIL...>&& obj);
516template <class t_TYPE, class t_HEAD, class... t_TAIL>
517const t_TYPE&& get(const variant<t_HEAD, t_TAIL...>&& obj);
518
519template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
520typename add_pointer<
521 typename variant_alternative<t_INDEX,
522 variant<t_HEAD, t_TAIL...> >::type>::type
524
525/// Return a pointer to the alternative object with index (template
526/// parameter) `t_INDEX` in the specified `obj`, or a null pointer if `obj`
527/// itself is a null pointer or if `t_INDEX` is not the index of the
528/// currently active alternative. `t_INDEX` shall be a valid alternative
529/// index.
530template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
531typename add_pointer<const typename variant_alternative<
532 t_INDEX,
533 variant<t_HEAD, t_TAIL...> >::type>::type
535
536template <class t_TYPE, class t_HEAD, class... t_TAIL>
539
540/// Return a pointer to the alternative object with type (template
541/// parameter) `t_TYPE` in the specified `obj`, or a null pointer if `obj`
542/// itself is a null pointer or if `t_TYPE` is not the type of the currently
543/// active alternative. `t_TYPE` shall appear exactly once in the variant's
544/// list of alternatives.
545template <class t_TYPE, class t_HEAD, class... t_TAIL>
548#else // BSL_VARIANT_FULL_IMPLEMENTATION
549
550// See 'bslstl_variant.cpp' for implementation notes regarding 'bsl::get'.
551
552/// This component-private metafunction computes the return types for
553/// `bsl::get<t_INDEX>` and `bsl::get_if<t_INDEX>` with an argument of type
554/// `t_ARG` or `t_ARG*`, respectively, where `t_VARIANT` is `t_ARG` with
555/// cvref-qualifiers stripped, and shall be a specialization of `bsl::variant`.
556/// `t_VALID` shall be `true` if and only if `t_INDEX` is a valid index for
557/// `t_VARIANT`. If `t_VALID` is `false`, no member typedefs are provided.
558///
559/// See @ref bslstl_variant
560template <bool t_VALID, size_t t_INDEX, class t_ARG, class t_VARIANT>
563
564template <size_t t_INDEX, class t_VARIANT>
565struct Variant_GetIndexReturnTypeImpl<true, t_INDEX, t_VARIANT, t_VARIANT> {
567
568 typedef
570};
571
572template <size_t t_INDEX, class t_VARIANT>
574 t_INDEX,
575 const t_VARIANT,
576 t_VARIANT> {
579
582};
583
584template <size_t t_INDEX, class t_VARIANT>
586 true,
587 t_INDEX,
588 BloombergLP::bslmf::MovableRef<t_VARIANT>,
589 t_VARIANT> {
590 typedef BloombergLP::bslmf::MovableRef<
593};
594
595/// This component-private metafunction computes the return types for
596/// `bsl::get<t_INDEX>` and `bsl::get_if<t_INDEX>` with an argument of type
597/// `t_ARG` or `t_ARG*` respectively. If `t_ARG` is not a (possibly
598/// cvref-qualified) `bsl::variant`, no definition is provided. If `t_INDEX`
599/// is not a valid index for `t_ARG`, the member typedefs `type` and `pointer`
600/// are not provided.
601template <size_t t_INDEX,
602 class t_ARG,
603 class t_VARIANT = typename BloombergLP::bslmf::MovableRefUtil::
604 Decay<t_ARG>::type>
606
607#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
608template <size_t t_INDEX, class t_ARG, class t_HEAD, class... t_TAIL>
610 t_ARG,
611 bsl::variant<t_HEAD, t_TAIL...> >
612: Variant_GetIndexReturnTypeImpl<(t_INDEX <= sizeof...(t_TAIL)),
613 t_INDEX,
614 t_ARG,
615 bsl::variant<t_HEAD, t_TAIL...> > {
616};
617
618/// This component-private metafunction is defined only when `t_HEAD` is a
619/// specialization of `bsl::variant` and `t_TAIL` is empty, in which case it
620/// provides member typedefs corresponding to `t_TYPE`. Naming these member
621/// typedefs results in a substitution failure when this metafunction is not
622/// defined.
623template <class t_TYPE, class t_HEAD, class... t_TAIL>
624struct Variant_GetTypeReturnType;
625
626/// This partial specialization provides member typedefs that are used to
627/// declare the `get` and `get_if` function templates in C++03 as non-variadic
628/// function templates that are constrained to accept only references or
629/// pointers to `bsl::variant`.
630template <class t_TYPE, class t_HEAD, class... t_TAIL>
631struct Variant_GetTypeReturnType<t_TYPE, bsl::variant<t_HEAD, t_TAIL...> > {
632 typedef t_TYPE type;
633 typedef typename add_pointer<t_TYPE>::type pointer;
634};
635#endif
636
637/// Return a reference to the alternative object at index (template parameter)
638/// `t_INDEX` in the specified `obj`. If `t_INDEX` is not the index of the
639/// currently active alternative, throw an exception of type
640/// @ref bad_variant_access . `t_INDEX` shall be a valid index for the variant type of `obj`.
641///
642/// \note Note that `t_VARIANT` may be const-qualified.
643template <size_t t_INDEX, class t_VARIANT>
644typename Variant_GetIndexReturnType<t_INDEX, t_VARIANT>::type
645get(t_VARIANT& obj);
646template <size_t t_INDEX, class t_VARIANT>
647typename Variant_GetIndexReturnType<
648 t_INDEX,
649 BloombergLP::bslmf::MovableRef<t_VARIANT> >::type
650get(BloombergLP::bslmf::MovableRef<t_VARIANT> obj);
651
652/// Return a reference to the alternative object with type (template parameter)
653/// `t_TYPE` in the specified `obj`. If `t_TYPE` is not the type of the
654/// currently active alternative, throw an exception of type
655/// @ref bad_variant_access . `t_TYPE` shall appear exactly once in the variant`s
656/// list of alternatives.
657template <class t_TYPE, class t_VARIANT>
658typename Variant_GetTypeReturnType<t_TYPE&, t_VARIANT>::type get(
659 t_VARIANT& obj);
660template <class t_TYPE, class t_VARIANT>
661typename Variant_GetTypeReturnType<const t_TYPE&, t_VARIANT>::type get(
662 const t_VARIANT& obj);
663template <class t_TYPE, class t_VARIANT>
664typename Variant_GetTypeReturnType<BloombergLP::bslmf::MovableRef<t_TYPE>,
665 t_VARIANT>::type get(
666 BloombergLP::bslmf::MovableRef<t_VARIANT> obj);
667
668// Return a pointer to the alternative object with index (template parameter)
669// `t_INDEX` in the specified `obj`, or a null pointer if `obj` itself is a
670// null pointer or if `t_INDEX` is not the index of the currently active
671// alternative. `t_INDEX` shall be a valid alternative index. Note that
672// `t_VARIANT` may be const-qualified.
673template <size_t t_INDEX, class t_VARIANT>
674typename Variant_GetIndexReturnType<t_INDEX, t_VARIANT>::pointer
675get_if(t_VARIANT *obj) BSLS_KEYWORD_NOEXCEPT;
676
677/// Return a pointer to the alternative object with type (template parameter)
678/// `t_TYPE` in the specified `obj`, or a null pointer if `obj` itself is a
679/// null pointer or if `t_TYPE` is not the type of the currently active
680/// alternative. `t_TYPE` shall appear exactly once in the variant`s list of
681/// alternatives.
682template <class t_TYPE, class t_VARIANT>
683typename Variant_GetTypeReturnType<t_TYPE, t_VARIANT>::pointer get_if(
684 t_VARIANT *obj) BSLS_KEYWORD_NOEXCEPT;
685template <class t_TYPE, class t_VARIANT>
686typename Variant_GetTypeReturnType<const t_TYPE, t_VARIANT>::pointer get_if(
687 const t_VARIANT *obj) BSLS_KEYWORD_NOEXCEPT;
688#endif // BSL_VARIANT_FULL_IMPLEMENTATION
689// FREE OPERATORS
690
691// 20.7.6, relational operators
692#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
693/// Return `true` if the specified `lhs` and `rhs` are both valueless by
694/// exception or if they have the same active alternative and their
695/// contained values compare equal; otherwise, return `false`. All
696/// alternatives shall support `operator==`.
697template <class t_HEAD, class... t_TAIL>
698bool operator==(const variant<t_HEAD, t_TAIL...>& lhs,
699 const variant<t_HEAD, t_TAIL...>& rhs);
700
701/// Return `true` if the specified `lhs` and `rhs` have different active
702/// alternatives or only one holds an alternative, or if they have the same
703/// active alternative and the contained values compare unequal; otherwise,
704/// return `false`. All alternatives shall support `operator!=`.
705template <class t_HEAD, class... t_TAIL>
706bool operator!=(const variant<t_HEAD, t_TAIL...>& lhs,
707 const variant<t_HEAD, t_TAIL...>& rhs);
708
709/// Return `true` if the index of the active alternative in the specified
710/// `lhs` is less than that of the specified `rhs`, or if both have the same
711/// active alternative and the contained value of `lhs` compares less than
712/// that of `rhs`, or if `lhs` is valueless by exception and `rhs` is not;
713/// otherwise, return `false`. All alternatives shall support `operator<`.
714template <class t_HEAD, class... t_TAIL>
715bool operator<(const variant<t_HEAD, t_TAIL...>& lhs,
716 const variant<t_HEAD, t_TAIL...>& rhs);
717
718/// Return `true` if the index of the active alternative in the specified
719/// `lhs` is greater than that of the specified `rhs`, or if both have the
720/// same active alternative and the contained value of `lhs` compares
721/// greater than that of `rhs`, or if `rhs` is valueless by exception and
722/// `lhs` is not; otherwise, return `false`. All alternatives shall support
723/// `operator>`.
724template <class t_HEAD, class... t_TAIL>
725bool operator>(const variant<t_HEAD, t_TAIL...>& lhs,
726 const variant<t_HEAD, t_TAIL...>& rhs);
727
728/// Return `true` if the index of the active alternative in the specified
729/// `lhs` is less than that of the specified `rhs`, or if both have the same
730/// active alternative and the contained value of `lhs` compares less than
731/// or equal to that of `rhs`, or if `lhs` is valueless by exception;
732/// otherwise, return `false`. All alternatives shall support `operator<=`.
733template <class t_HEAD, class... t_TAIL>
734bool operator<=(const variant<t_HEAD, t_TAIL...>& lhs,
735 const variant<t_HEAD, t_TAIL...>& rhs);
736
737/// Return `true` if the index of the active alternative in the specified
738/// `lhs` is greater than that of the specified `rhs`, or if both have the
739/// same active alternative and the contained value of `lhs` compares
740/// greater than or equal to that of `rhs`, or if `rhs` is valueless by
741/// exception; otherwise, return `false`. All alternatives shall support
742/// `operator>=`.
743template <class t_HEAD, class... t_TAIL>
744bool operator>=(const variant<t_HEAD, t_TAIL...>& lhs,
745 const variant<t_HEAD, t_TAIL...>& rhs);
746
747#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON && \
748 defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
749
750/// If `lhs` and `rhs` are not valueless by exception and hold the same
751/// alternative `i`, return `get<i>(lhs) <=> get<i>(rhs)` . If `lhs` and
752/// `rhs` are not valueless by exception and hold the aalternatives `i` and
753/// `j` respectively, return `i<=>j`. Return `strong_ordering::equal` if
754/// both variants are valueless by exception. Return
755/// `strong_ordering::less` if `lhs` is valueless by exception. Return
756/// `strong_ordering::greater` if `rhs` is valueless by exception.
757template <class... t_ALTS>
758 requires(std::three_way_comparable<t_ALTS> && ...)
759constexpr std::common_comparison_category_t<
760 std::compare_three_way_result_t<t_ALTS>...>
761operator<=>(const variant<t_ALTS...>& lhs, const variant<t_ALTS...>& rhs);
762#endif
763#endif
764
765} // close namespace bsl
766
767
768namespace bslstl {
769// COMPONENT-PRIVATE TAG TYPES
770
771/// This component-private tag type is used as a parameter type for
772/// constructors of `Variant_Base` that accept a `std::variant`.
773///
774/// See @ref bslstl_variant
775struct Variant_ConstructFromStdTag {};
776
777#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
778/// This component-private metafunction is derived from `bsl::true_type` if
779/// at least one template argument uses an allocator, and from
780/// `bsl::false_type` otherwise.
781template <class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE, class... t_TAIL>
782struct Variant_UsesBslmaAllocatorAny;
783
784template <>
785struct Variant_UsesBslmaAllocatorAny<BSLSTL_VARIANT_NOT_A_TYPE>
786: bsl::false_type {
787};
788
789template <class t_HEAD, class... t_TAIL>
790struct Variant_UsesBslmaAllocatorAny
791: bsl::integral_constant<
792 bool,
793 BloombergLP::bslma::UsesBslmaAllocator<t_HEAD>::value ||
794 BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<
795 t_TAIL...>::value> {
796};
797
798/// This component-private metafunction is derived from `bsl::true_type` if
799/// all template arguments are bitwise moveable, and from `bsl::false_type`
800/// otherwise.
801template <class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE, class... t_TAIL>
802struct Variant_IsBitwiseMoveableAll;
803
804template <>
805struct Variant_IsBitwiseMoveableAll<BSLSTL_VARIANT_NOT_A_TYPE>
806: bsl::true_type {
807};
808
809template <class t_HEAD, class... t_TAIL>
810struct Variant_IsBitwiseMoveableAll
811: bsl::integral_constant<
812 bool,
813 BloombergLP::bslmf::IsBitwiseMoveable<t_HEAD>::value &&
814 Variant_IsBitwiseMoveableAll<t_TAIL...>::value> {
815};
816
817/// This component-private metafunction is derived from `bsl::true_type` if
818/// (template parameter) `t_TYPE` is not a tag type. This metafunction
819/// requires any cv and ref qualifications to be removed from the queried
820/// type.
821template <class t_TYPE>
822struct Variant_IsTag : bsl::false_type {
823};
824
825template <>
826struct Variant_IsTag<bsl::allocator_arg_t> : bsl::true_type {
827};
828
829template <class t_TYPE>
830struct Variant_IsTag<bsl::in_place_type_t<t_TYPE> > : bsl::true_type {
831};
832
833template <size_t t_INDEX>
834struct Variant_IsTag<bsl::in_place_index_t<t_INDEX> > : bsl::true_type {
835};
836
837#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
838/// This component-private metafunction derives from
839/// `std::is_constructible<t_TO, t_FROM>` in C++11 and later, and
840/// `bsl::true_type` in C++03.
841template <class t_TO, class t_FROM>
842struct Variant_IsConstructible : std::is_constructible<t_TO, t_FROM> {
843};
844
845/// This component-private metafunction derives from
846/// `std::is_assignable<t_LHS, t_RHS>` in C++11 and later, and
847/// `bsl::true_type` in C++03.
848template <class t_LHS, class t_RHS>
849struct Variant_IsAssignable : std::is_assignable<t_LHS, t_RHS> {
850};
851#else
852/// This component-private metafunction derives from
853/// `std::is_constructible<t_TO, t_FROM>` in C++11 and later, and
854/// `bsl::true_type` in C++03.
855template <class t_TO, class t_FROM>
856struct Variant_IsConstructible : bsl::true_type {
857};
858
859// This component-private metafunction derives from
860// `std::is_assignable<t_LHS, t_RHS>` in C++11 and later, and
861// `bsl::true_type` in C++03.
862template <class t_LHS, class t_RHS>
863struct Variant_IsAssignable : bsl::true_type {
864};
865#endif // BSL_VARIANT_FULL_IMPLEMENTATION
866
867/// This component-private macro is used as a constraint in function
868/// definitions which require the specified `VARIANT` to be constructible
869/// from the specified `TYPE`.
870#define BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM(VARIANT, TYPE) \
871 typename bsl::enable_if< \
872 BloombergLP::bslstl::Variant_ConstructsFromType<VARIANT, \
873 TYPE>::value, \
874 BloombergLP::bslstl::Variant_NoSuchType>::type
875
876/// This component-private macro is used as a constraint in function
877/// declarations which require the specified `VARIANT` to be constructible
878/// from the specified `TYPE`.
879#define BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM(VARIANT, TYPE) \
880 BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM( \
881 VARIANT, \
882 TYPE) = BloombergLP::bslstl::Variant_NoSuchType(0)
883
884/// This component-private macro is used as a constraint when defining
885/// constructors of `variant` from the corresponding `std::variant`.
886#define BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM_STD(STD_VARIANT) \
887 bsl::enable_if_t< \
888 BloombergLP::bslstl::variant_constructsFromStd<variant, STD_VARIANT>, \
889 BloombergLP::bslstl::Variant_NoSuchType>
890
891/// This component-private macro is used as a constraintwhen declaring
892/// constructors of `variant` from the corresponding `std::variant`.
893#define BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM_STD(STD_VARIANT) \
894 BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM_STD(STD_VARIANT) \
895 = BloombergLP::bslstl::Variant_NoSuchType(0)
896
897/// This component-private macro is used as a constraint in function
898/// definitions which require the specified `TYPE` to be a unique
899/// alternative in `variant<t_HEAD, t_TAIL...>`.
900/// Implementation note: This macro can't use
901/// `BSLSTL_VARIANT_HAS_UNIQUE_TYPE` because this macro is used at points
902/// where `variant<t_HEAD, t_TAIL...>` expands to an invalid construct.
903#define BSLSTL_VARIANT_DEFINE_IF_HAS_UNIQUE_TYPE(TYPE) \
904 typename bsl::enable_if< \
905 BloombergLP::bslstl::Variant_HasUniqueType<TYPE, variant>::value, \
906 BloombergLP::bslstl::Variant_NoSuchType>::type
907
908/// This component-private macro is used as a constraint in function
909/// declarations which require the specified `TYPE` to be a unique
910/// alternative in `variant<t_HEAD, t_TAIL...>`.
911#define BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(TYPE) \
912 BSLSTL_VARIANT_DEFINE_IF_HAS_UNIQUE_TYPE( \
913 TYPE) = BloombergLP::bslstl::Variant_NoSuchType(0)
914
915/// This component-private macro expands to the check for whether the
916/// specified `TYPE` is a unique alternative in
917/// `variant<t_HEAD, t_TAIL...>`. See definition `Variant_HasUniqueType`
918/// for more details.
919#define BSLSTL_VARIANT_HAS_UNIQUE_TYPE(TYPE) \
920 BloombergLP::bslstl:: \
921 Variant_HasUniqueType<TYPE, variant<t_HEAD, t_TAIL...> >::value
922
923/// This component-private macro expands to the type of alternative at
924/// specified `INDEX` for a variant of type
925/// `bsl::variant<t_HEAD, t_TAIL...>`.
926#define BSLSTL_VARIANT_TYPE_AT_INDEX(INDEX) \
927 typename bsl::variant_alternative<INDEX, \
928 bsl::variant<t_HEAD, t_TAIL...> >::type
929
930/// This component-private macro expands to the index of the first
931/// alternative in the specified `VARIANT` that is identical to the
932/// specified `TYPE`, or `bsl::variant_npos` if no such alternative exists.
933#define BSLSTL_VARIANT_INDEX_OF(TYPE, VARIANT) \
934 BloombergLP::bslstl::Variant_TypeToIndex<TYPE, VARIANT>::value
935
936/// This component-private macro expands to the index of the first
937/// alternative in the specified `VARIANT` that is a "unique" best match for
938/// conversion from `std::declval<TYPE>()`. See the documentation for
939/// `Variant_ConvertIndex` for more details.
940#define BSLSTL_VARIANT_CONVERT_INDEX_OF(TYPE, VARIANT) \
941 BloombergLP::bslstl::Variant_ConvertIndex<TYPE, VARIANT>::value
942
943/// This component-private macro expands to the type of the alternative
944/// in the specified `VARIANT` that is a "unique" best match for conversion
945/// from `std::declval<TYPE>()`. See the documentation for
946/// `Variant_ConvertIndex` for more details.
947#define BSLSTL_VARIANT_CONVERT_TYPE_OF(TYPE, VARIANT) \
948 typename bsl::variant_alternative<BSLSTL_VARIANT_CONVERT_INDEX_OF( \
949 TYPE, VARIANT), \
950 VARIANT>::type
951
952/// This component-private macro expands to the invocation of
953/// `Variant_ImpUtil::visitId` with specified `RET` as return type, and
954/// specified `VISITOR` and specified `VAROBJ` as arguments. See the
955/// documentation of `Variant_ImpUtil::visitId` for more details.
956#define BSLSTL_VARIANT_VISITID(RET, VISITOR, VAROBJ) \
957 BloombergLP::bslstl::Variant_ImpUtil::visitId<RET>(VISITOR, VAROBJ);
958
959/// This component-private metafunction provides implementation for
960/// `Variant_TypeToIndex`. It evaluates to `t_INDEX + i` where `i` is the
961/// zero-based index of (template parameter) `t_TYPE` in (template parameters)
962/// `t_HEAD, t_TAIL...`, or `bsl::variant_npos` if `t_TYPE` is not found.
963template <size_t t_INDEX,
964 class t_TYPE,
965 class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE,
966 class... t_TAIL>
967struct Variant_TypeToIndexImpl
968: bsl::conditional<
969 bsl::is_same<t_TYPE, t_HEAD>::value,
970 bsl::integral_constant<size_t, t_INDEX>,
971 Variant_TypeToIndexImpl<t_INDEX + 1, t_TYPE, t_TAIL...> >::type {
972};
973
974/// This partial specialization is used when the list of alternatives
975/// `t_HEAD, t_TAIL...` is empty, i.e., `t_TYPE` wasn't found in the
976/// originally supplied list of alternatives.
977template <size_t t_INDEX, class t_TYPE>
978struct Variant_TypeToIndexImpl<t_INDEX, t_TYPE, BSLSTL_VARIANT_NOT_A_TYPE>
979: bsl::integral_constant<size_t, bsl::variant_npos> {
980};
981
982/// This component-private metafunction calculates the zero-based index of
983/// (template parameter) `t_TYPE` in the list of alternatives in (template
984/// parameter) `t_VARIANT`, or `bsl::variant_npos` if there is no such
985/// alternative. The primary template (used when `t_VARIANT` is not a
986/// `bsl::variant`) is not defined.
987template <class t_TYPE, class t_VARIANT>
988struct Variant_TypeToIndex; // primary template not defined
989
990template <class t_TYPE, class t_HEAD, class... t_TAIL>
991struct Variant_TypeToIndex<t_TYPE, bsl::variant<t_HEAD, t_TAIL...> >
992: Variant_TypeToIndexImpl<0, t_TYPE, t_HEAD, t_TAIL...> {
993};
994
995/// This component-private metafunction calculates the number of times
996/// (template parameter) `t_TYPE` occurs in (template parameters)
997/// `t_HEAD, t_TAIL...`. An alternative must have the same cv-qualification
998/// as `t_TYPE` in order to be counted.
999template <class t_TYPE,
1000 class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE,
1001 class... t_TAIL>
1002struct Variant_CountType
1003: bsl::integral_constant<size_t,
1004 bsl::is_same<t_TYPE, t_HEAD>::value +
1005 Variant_CountType<t_TYPE, t_TAIL...>::value> {
1006};
1007
1008/// Specialization for purposes of the sim_cpp11_features.pl script.
1009template <class t_TYPE>
1010struct Variant_CountType<t_TYPE, BSLSTL_VARIANT_NOT_A_TYPE>
1011: bsl::integral_constant<size_t, 0> {
1012};
1013
1014/// This component-private metafunction derives from `bsl::true_type` if
1015/// (template parameter) `t_TYPE` occurs exactly once as an alternative of
1016/// (template parameter) `t_VARIANT`, and `bsl::false_type` otherwise. An
1017/// alternative must have the same cv-qualification as `t_TYPE` in order to
1018/// be counted. The primary template (used when `t_VARIANT` is not a
1019/// `bsl::variant`) is not defined.
1020template <class t_TYPE, class t_VARIANT>
1021struct Variant_HasUniqueType;
1022
1023template <class t_TYPE, class t_HEAD, class... t_TAIL>
1024struct Variant_HasUniqueType<t_TYPE, bsl::variant<t_HEAD, t_TAIL...> >
1025: bsl::integral_constant<bool,
1026 Variant_CountType<t_TYPE, t_HEAD, t_TAIL...>::value ==
1027 1> {
1028};
1029
1030/// This component-private metafunction calculates the number of times
1031/// (template parameter) `t_TYPE` occurs in (template parameters)
1032/// `t_HEAD, t_TAIL...`, where two types that differ only in top-level
1033/// cv-qualification are considered to be the same.
1034template <class t_TYPE,
1035 class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE,
1036 class... t_TAIL>
1037struct Variant_CountCVType
1038: bsl::integral_constant<
1039 size_t,
1040 bsl::is_same<typename bsl::remove_cv<t_TYPE>::type,
1041 typename bsl::remove_cv<t_HEAD>::type>::value +
1042 Variant_CountCVType<t_TYPE, t_TAIL...>::value> {
1043};
1044
1045/// Specialization for purposes of the sim_cpp11_features.pl script.
1046template <class t_TYPE>
1047struct Variant_CountCVType<t_TYPE, BSLSTL_VARIANT_NOT_A_TYPE>
1048: bsl::integral_constant<size_t, 0> {
1049};
1050
1051/// This component-private metafunction derives from `bsl::true_type` if
1052/// (template parameter) `t_TYPE` occurs exactly once as an alternative of
1053/// (template parameter) `t_VARIANT`, and `bsl::false_type` otherwise, where
1054/// two types that differ only in top-level cv-qualification are considered
1055/// to be the same. The primary template (used when `t_VARIANT` is not a
1056/// `bsl::variant`) is not defined.
1057template <class t_TYPE, class t_VARIANT>
1058struct Variant_HasUniqueCVType;
1059
1060template <class t_TYPE, class t_HEAD, class... t_TAIL>
1061struct Variant_HasUniqueCVType<t_TYPE, bsl::variant<t_HEAD, t_TAIL...> >
1062: bsl::integral_constant<
1063 bool,
1064 Variant_CountCVType<t_TYPE, t_HEAD, t_TAIL...>::value == 1> {
1065};
1066#endif
1067
1068/// This component-private metafunction calculates the alternative type at
1069/// index (template parameter) `t_INDEX` in (template parameter)
1070/// `t_VARIANT`, where the cv- and ref-qualifiers of `t_VARIANT` are added
1071/// to the alternative type. This metafunction is used to calculate the
1072/// return type of `bsl::visit`.
1073///
1074/// See @ref bslstl_variant
1075template <class t_VARIANT, size_t t_INDEX>
1076struct Variant_CVQualAlt {
1077
1078 /// Alternative at `t_INDEX` with combined cv-qualifiers
1079 typedef typename bsl::variant_alternative<
1080 t_INDEX,
1081 typename bslmf::MovableRefUtil::RemoveReference<t_VARIANT>::type>::type
1082 CVAlt;
1083
1084 typedef typename bsl::conditional<
1085 bslmf::MovableRefUtil::IsReference<t_VARIANT>::value,
1086 typename bsl::conditional<
1087 bslmf::MovableRefUtil::IsMovableReference<t_VARIANT>::value,
1088 typename bslmf::MovableRefUtil::AddMovableReference<CVAlt>::type,
1089 typename bslmf::MovableRefUtil::AddLvalueReference<CVAlt>::type>::
1090 type,
1091 CVAlt>::type type;
1092};
1093
1094/// This component-private metafunction derives from `bsl::true_type` if,
1095/// for each alternative `ALTi` in (template parameter) `t_VARIANT` with
1096/// index less than or equal to (template parameter) `t_INDEX`,
1097/// `decltype(std::declval<t_VISITOR>(std::declval<ALTi>()))` is `t_RET`;
1098/// otherwise, this metafunction derives from `bsl::false_type`.
1099///
1100/// \note Note that `ALTi` has the cv- and ref-qualifiers from `t_VARIANT` added to it.
1101/// This metafunction is used to determine whether invoking the visitor
1102/// results in the same type and value category for all alternatives.
1103template <class t_RET,
1104 class t_VISITOR,
1105 class t_VARIANT,
1106 size_t t_INDEX =
1107 bsl::variant_size<typename bslmf::MovableRefUtil::
1108 RemoveReference<t_VARIANT>::type>::value -
1109 1>
1110struct Variant_IsSameReturnType
1111: public bsl::integral_constant<
1112 bool,
1113 bsl::is_same<t_RET,
1114 typename bsl::invoke_result<
1115 t_VISITOR,
1116 typename Variant_CVQualAlt<t_VARIANT, t_INDEX>::type>::
1117 type>::value &&
1118 Variant_IsSameReturnType<t_RET, t_VISITOR, t_VARIANT, t_INDEX - 1>::
1119 value> {
1120};
1121template <class t_RET, class t_VISITOR, class t_VARIANT>
1122struct Variant_IsSameReturnType<t_RET, t_VISITOR, t_VARIANT, 0>
1123: bsl::is_same<t_RET,
1124 typename bsl::invoke_result<
1125 t_VISITOR,
1126 typename Variant_CVQualAlt<t_VARIANT, 0>::type>::type> {
1127};
1128
1129 // ======================
1130 // struct Variant_ImpUtil
1131 // ======================
1132
1133/// This `struct` provides a namespace for utility functions used implement
1134/// various operations on `bsl::variant`.
1135///
1136/// See @ref bslstl_variant
1137struct Variant_ImpUtil {
1138
1139#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=18
1140 /// Returns a reference to the specified `v`.
1141 template <class t_HEAD, class... t_TAIL>
1142 static bsl::variant<t_HEAD, t_TAIL...>& asVariant(
1143 bsl::variant<t_HEAD, t_TAIL...>& v)
1144 {
1145 return v;
1146 }
1147 template <class t_HEAD, class... t_TAIL>
1148 static const bsl::variant<t_HEAD, t_TAIL...>& asVariant(
1149 const bsl::variant<t_HEAD, t_TAIL...>& v)
1150 {
1151 return v;
1152 }
1153#endif
1154
1155#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
1156 && defined(BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES)
1157 /// Returns a reference to the specified `v`.
1158 template <class t_HEAD, class... t_TAIL>
1159 static bsl::variant<t_HEAD, t_TAIL...>&& asVariant(
1160 bsl::variant<t_HEAD, t_TAIL...>&& v)
1161 {
1162 return std::move(v);
1163 }
1164 template <class t_HEAD, class... t_TAIL>
1165 static const bsl::variant<t_HEAD, t_TAIL...>&& asVariant(
1166 const bsl::variant<t_HEAD, t_TAIL...>&& v)
1167 {
1168 return std::move(v);
1169 }
1170#endif
1171
1172 /// Return a reference to the alternative with index (template
1173 /// parameter) `t_INDEX` in the specified `variant`. If `t_INDEX` is
1174 /// not the index of the currently active alternative, throw an exception of type `bad_variant_access`.
1175 ///
1176 /// \note Note that the return type
1177 /// must be explicitly specified.
1178 template <class t_RET, size_t t_INDEX, class t_VARIANT>
1179 static t_RET& get(t_VARIANT& variant);
1180 template <class t_RET, size_t t_INDEX, class t_VARIANT>
1181 static t_RET& get(const t_VARIANT& variant);
1182
1183#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
1184 /// Invoke the specified `visitor` on the active alternative of the
1185 /// specified `variant`, implicitly converting the return type to the
1186 /// explicitly specified (template parameter) `t_RET`.
1187 ///
1188 /// \pre The behavior is undefined unless `variant` holds a value.
1189 /// \note Note that the return type
1190 /// must be explicitly specified. This function does not require friend
1191 /// access to `Variant` and has been added to `Variant_ImpUtil` for the
1192 /// purposes of avoiding free functions.
1193 template <class t_RET, class t_VISITOR, class t_VARIANT>
1194 static t_RET visit(t_VISITOR&& visitor, t_VARIANT&& variant);
1195
1196 /// Invoke the specified `visitor` on the active alternative of the
1197 /// specified `variant`, implicitly converting the return type to the
1198 /// explicitly specified (template parameter) `t_RET`, and pass a tag
1199 /// representing the index of the selected alternative when invoking the
1200 /// visitor. It is used internally for visitors that participate in the `variant` implementation.
1201 ///
1202 /// \pre The behavior is undefined unless
1203 /// `variant` holds a value. This function does not require friend
1204 /// access to `Variant` and has been added to `Variant_ImpUtil` for the
1205 /// purposes of avoiding free functions.
1206 template <class t_RET, class t_VISITOR, class t_VARIANT>
1207 static t_RET visitId(t_VISITOR&& visitor, t_VARIANT&& variant);
1208#else
1209 // Lack of perfect forwarding in C++03 means overload set must be
1210 // different.
1211
1212 /// Invoke the specified `visitor` on the active alternative of the
1213 /// specified `variant`, implicitly converting the return type to the
1214 /// explicitly specified (template parameter) `t_RET`.
1215 ///
1216 /// \pre The behavior is undefined if `variant` does not hold a value. This function does
1217 /// not require friend access to `Variant` and has been added to
1218 /// `Variant_ImpUtil` for the purposes of avoiding free functions.
1219 template <class t_RET, class t_VISITOR, class t_VARIANT>
1220 static t_RET visit(t_VISITOR& visitor, t_VARIANT& variant);
1221 template <class t_RET, class t_VISITOR, class t_VARIANT>
1222 static t_RET visit(t_VISITOR& visitor, const t_VARIANT& variant);
1223
1224 /// Invoke the specified `visitor` on a `bslmf::MovableRef` referring to
1225 /// the active alternative of the specified `variant`, implicitly
1226 /// converting the return type to the explicitly specified (template parameter) `t_RET`.
1227 ///
1228 /// \pre The behavior is undefined if `variant` does not
1229 /// hold a value. This function does not require friend access to
1230 /// `Variant` and has been added to `Variant_ImpUtil` for the purposes
1231 /// of avoiding free functions.
1232 template <class t_RET, class t_VISITOR, class t_VARIANT>
1233 static t_RET moveVisit(t_VISITOR& visitor, t_VARIANT& variant);
1234
1235 /// Invoke the specified `visitor` with a
1236 /// `bsl::in_place_index_t<t_INDEX>` tag (where `t_INDEX` is the index
1237 /// of the first alternative that has the same type as the active
1238 /// alternative of the specified `variant`) and the active alternative
1239 /// of `variant`, implicitly converting the return type to the
1240 /// explicitly specified (template parameter) `t_RET`.
1241 ///
1242 /// \pre The behavior is undefined if `variant` does not hold a value. This function does
1243 /// not require friend access to `Variant` and has been added to
1244 /// `Variant_ImpUtil` for the purposes of avoiding free functions.
1245 template <class t_RET, class t_VISITOR, class t_VARIANT>
1246 static t_RET visitId(t_VISITOR& visitor, t_VARIANT& variant);
1247 template <class t_RET, class t_VISITOR, class t_VARIANT>
1248 static t_RET visitId(t_VISITOR& visitor, const t_VARIANT& variant);
1249
1250#endif // BSL_VARIANT_FULL_IMPLEMENTATION
1251
1252#ifndef BSL_VARIANT_FULL_IMPLEMENTATION
1253 // Implementation notes
1254 // --------------------
1255 // In C++03, the internal visitation dispatch must call a type-based (not
1256 // index-based) getter. This internal type-based getter will always be
1257 // passed the type of the currently active alternative, so there is no need
1258 // to check whether the requested alternative matches the currently active
1259 // alternative. Moreover, in cases where there are alternatives of
1260 // identical type, 'bsl::get' cannot be passed such a type. To solve the
1261 // problem, we implement an unsafe type-based getter that is used only for
1262 // internal visitation.
1263
1264 /// Return a reference to type (template parameter) 't_RET' to the
1265 /// alternative at (template parameter) 't_INDEX' in the specified
1266 /// 'variant', regardless of whether that is the active alternative.
1267 ///
1268 /// \pre The behavior is undefined unless the active alternative of 'variant'
1269 /// has the same type as the alternative with index 't_INDEX'.
1270 ///
1271 /// \note Note that the return type must be explicitly specified.
1272 template <class t_RET, size_t t_INDEX, class t_VARIANT>
1273 static t_RET& unsafeGet(t_VARIANT& variant);
1274 template <class t_RET, size_t t_INDEX, class t_VARIANT>
1275 static t_RET& unsafeGet(const t_VARIANT& variant);
1276
1277 /// Return a reference to const-qualified (template parameter) `t_TYPE`
1278 /// to the first alternative of the specified `obj` that has type
1279 /// `t_TYPE`, regardless of whether that is the active alternative.
1280 ///
1281 /// \pre The behavior is undefined unless the active alternative of `variant` is
1282 /// of type `t_TYPE`. This function does not require friend access to
1283 /// `Variant` and has been added to `Variant_ImpUtil` for the purposes
1284 /// of avoiding free functions.
1285 template <class t_TYPE, class t_VARIANT>
1286 static t_TYPE& unsafeGet(t_VARIANT& obj);
1287 template <class t_TYPE, class t_VARIANT>
1288 static const t_TYPE& unsafeGet(const t_VARIANT& obj);
1289
1290#endif // BSL_VARIANT_FULL_IMPLEMENTATION
1291
1292 /// Return a reference to the object managed by the first member of the
1293 /// specified `variantUnion`. It is the base case for the overload of
1294 /// `getAlternative` below. This function does not require friend
1295 /// access to `Variant` and has been added to `Variant_ImpUtil` for the
1296 /// purposes of avoiding free functions.
1297 template <class t_RET, class t_VARIANT_UNION>
1298 static t_RET& getAlternative(
1299 bsl::in_place_index_t<0>,
1300 t_VARIANT_UNION& variantUnion) BSLS_KEYWORD_NOEXCEPT;
1301
1302 /// Return a reference to the alternative with index (template
1303 /// parameter) `t_INDEX` in the specified `variantUnion` by recursively
1304 /// unravelling `variantUnion` until the desired alternative is at the
1305 /// head. `t_INDEX` shall be a valid alternative index.
1306 ///
1307 /// \pre The behavior is undefined unless the alternative with index `t_INDEX` has the
1308 /// same type as the active alternative of `variantUnion`. This
1309 /// function does not require friend access to `Variant` and has been
1310 /// added to `Variant_ImpUtil` for the purposes of avoiding free
1311 /// functions.
1312 template <class t_RET, size_t t_INDEX, class t_VARIANT_UNION>
1313 static t_RET& getAlternative(
1314 bsl::in_place_index_t<t_INDEX>,
1315 t_VARIANT_UNION& variantUnion) BSLS_KEYWORD_NOEXCEPT;
1316
1317 template <class t_VARIANT>
1318 static bool Equal(const t_VARIANT& lhs, const t_VARIANT& rhs);
1319 template <class t_VARIANT>
1320 static bool NotEqual(const t_VARIANT& lhs, const t_VARIANT& rhs);
1321 template <class t_VARIANT>
1322 static bool LessThan(const t_VARIANT& lhs, const t_VARIANT& rhs);
1323 template <class t_VARIANT>
1324 static bool GreaterThan(const t_VARIANT& lhs, const t_VARIANT& rhs);
1325 template <class t_VARIANT>
1326 static bool LessOrEqual(const t_VARIANT& lhs, const t_VARIANT& rhs);
1327
1328 /// Return the result of comparing the specified `lhs` with the specified `rhs`.
1329 ///
1330 /// \pre The behavior is undefined unless both `lhs` and `rhs` hold the same alternative.
1331 ///
1332 /// \note Note that the capitalization of
1333 /// the names of these methods has been chosen so that their definitions
1334 /// can be generated using a macro.
1335 template <class t_VARIANT>
1336 static bool GreaterOrEqual(const t_VARIANT& lhs, const t_VARIANT& rhs);
1337
1338#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1339 /// This visitor is used to implement the explicit constructor for
1340 /// `bsl::variant` from `std::variant`.
1341 template <class t_VARIANT, class t_STD_VARIANT>
1342 class ConstructFromStdVisitor;
1343#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1344};
1345
1346#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1347
1348 // ==============================================
1349 // class Variant_ImpUtil::ConstructFromStdVisitor
1350 // ==============================================
1351
1352template <class t_VARIANT, class t_STD_VARIANT>
1353class Variant_ImpUtil::ConstructFromStdVisitor {
1354 private:
1355 // DATA
1356 t_VARIANT& d_target;
1357 t_STD_VARIANT& d_original;
1358
1359 public:
1360 // CREATORS
1361
1362 /// Create a `ConstructFromStdVisitor` object that, when invoked, will
1363 /// construct the alternative of the specified `target` corresponding to
1364 /// the active alternative of the specified `original`. `target` shall
1365 /// have the same sequence of alternative types as `original`.
1366 explicit ConstructFromStdVisitor(t_VARIANT& target,
1367 t_STD_VARIANT& original);
1368
1369 // ACCESSORS
1370
1371 /// Construct the alternative at index (template parameter) `t_INDEX`
1372 /// in `d_target` from the contained value of `d_original`. If
1373 /// `t_STD_VARIANT` is an lvalue reference type, the alternative will be
1374 /// created by copy construction, otherwise it will be created by move construction.
1375 ///
1376 /// \pre The behavior is undefined unless `d_original` holds a value and `d_target.index() == d_original.index()`.
1377 ///
1378 /// \note Note that the
1379 /// unused parameter of type `t_TYPE&` refers to the alternative that
1380 /// will be constructed, but we do not construct directly into that
1381 /// object because we need to make sure that the allocator of `d_target`
1382 /// (if any) is used.
1383 template <size_t t_INDEX, class t_TYPE>
1384 void operator()(bsl::in_place_index_t<t_INDEX>, t_TYPE&) const;
1385};
1386#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1387
1388#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
1389/// This component-private struct is used to check whether an alternative
1390/// given by (template parameter) `t_TYPE` is a potential match for an
1391/// argument of a `bsl::variant` constructor or assignment operator that
1392/// does not take an explicitly specified alternative type. The standard
1393/// allows such conversion only when the declaration `t_TYPE d_x[] = {expr};`
1394/// is valid, where `expr` is the (forwarded) argument expression.
1395///
1396/// See @ref bslstl_variant
1397template <class t_TYPE>
1398struct Variant_ArrayHelper {
1399 t_TYPE d_x[1];
1400};
1401
1402/// This component-private metafunction checks whether a conversion from a
1403/// pointer type to (template parameter) `t_TYPE` is narrowing. It is
1404/// instantiated only for `bool`, and its behavior depends on whether the
1405/// compiler has implemented P1957R2.
1406template <class t_TYPE, class = void>
1407struct Variant_CheckForP1957R2 : bsl::true_type {
1408};
1409
1410template <class t_TYPE>
1411struct Variant_CheckForP1957R2<
1412 t_TYPE,
1413 bsl::void_t<decltype(Variant_ArrayHelper<t_TYPE>{{"bc"}})> >
1414: bsl::false_type {
1415};
1416
1417template <class t_DEST, class t_SOURCE, class = void>
1418struct Variant_ConvertsWithoutNarrowing : bsl::false_type {
1419};
1420
1421/// This component-private metafunction is derived from `bsl::true_type` if
1422/// (template parameter) `t_SOURCE` can be converted to (template parameter)
1423/// `t_DEST` without narrowing, and `bsl::false_type` otherwise. A
1424/// conversion from pointer or pointer-to-member type to cv `bool` is
1425/// considered narrowing even if the compiler does not implement P1957R2
1426/// (which was adopted as a DR); however, on compilers that do not implement
1427/// P1957R2, we do not have the ability to check whether a user-defined
1428/// conversion sequence to cv `bool` would use a narrowing standard
1429/// conversion, so on those compilers, we permit conversion to a `t_DEST`
1430/// that is cv `bool` only if `t_SOURCE` is also cv `bool`, and not when
1431/// `t_SOURCE` is a class type. This behavior is not expected to pose a
1432/// problem for users migrating from `bdlb::Variant`, because that class
1433/// does not support implicit conversions from an argument type to an
1434/// alternative type.
1435template <class t_DEST, class t_SOURCE>
1436struct Variant_ConvertsWithoutNarrowing<
1437 t_DEST,
1438 t_SOURCE,
1439 bsl::void_t<decltype(
1440 Variant_ArrayHelper<t_DEST>{{std::declval<t_SOURCE>()}})> >
1441: bsl::integral_constant<
1442 bool,
1443 !(!Variant_CheckForP1957R2<bool>::value &&
1444 bsl::is_same<bool, typename bsl::remove_cvref<t_DEST>::type>::value &&
1445 !bsl::is_same<bool,
1446 typename bsl::remove_cvref<t_SOURCE>::type>::value)> {
1447};
1448
1449 // =============================
1450 // struct Variant_OverloadSetImp
1451 // =============================
1452
1453/// This component-private metafunction computes an overload set consisting
1454/// of one function, named `candidate`, for each type in (template
1455/// parameters) `t_HEAD, t_TAIL...`, having one parameter of that type.
1456/// Each such function participates in overload resolution only when
1457/// `std::declval<t_SRC>()` is convertible to the alternative without
1458/// narrowing, and returns `bsl::integral_constant<t_INDEX + i>`, where `i` is the zero-based index of the corresponding alternative.
1459///
1460/// \note Note that a
1461/// type that occurs multiple times in `t_HEAD, t_TAIL...` (possibly with
1462/// varying cv-qualifications) will only result in the generation of a
1463/// single candidate. This implementation relies on expression SFINAE,
1464/// `decltype`, `std::declval`, and P1957R2; since these features are not
1465/// available in C++03, the C++03 version requires an exact match modulo
1466/// cv-qualification.
1467template <class t_SRC, size_t t_INDEX, class t_HEAD, class... t_TAIL>
1468struct Variant_OverloadSetImp
1469: Variant_OverloadSetImp<t_SRC, t_INDEX + 1, t_TAIL...> {
1470
1471 using Variant_OverloadSetImp<t_SRC, t_INDEX + 1, t_TAIL...>::candidate;
1472
1473 template <class t_DEST = t_HEAD>
1474 static typename bsl::enable_if<
1475 Variant_ConvertsWithoutNarrowing<t_DEST, t_SRC>::value,
1476 bsl::integral_constant<size_t, t_INDEX> >::type candidate(t_HEAD);
1477};
1478template <class t_SRC, size_t t_INDEX, class t_HEAD>
1479struct Variant_OverloadSetImp<t_SRC, t_INDEX, t_HEAD> {
1480 template <class t_DEST = t_HEAD>
1481 static typename bsl::enable_if<
1482 Variant_ConvertsWithoutNarrowing<t_DEST, t_SRC>::value,
1483 bsl::integral_constant<size_t, t_INDEX> >::type candidate(t_HEAD);
1484};
1485
1486/// This component-private metafunction provides a member typedef `Index`
1487/// representing the value that should be computed by
1488/// `Variant_ConvertIndex`. The primary template is instantiated when the
1489/// partial specialization below is not viable because no viable alternative
1490/// exists for the conversion or because the best match is not "unique" (see
1491/// the documentation of `Variant_ConvertIndex` for an explanation).
1492///
1493/// See @ref bslstl_variant
1494template <class t_SRC, class t_VARIANT, class = void>
1495struct Variant_OverloadHelper {
1496
1497 typedef bsl::integral_constant<size_t, bsl::variant_npos> Index;
1498};
1499
1500/// This partial specialization is used when a "unique" best match is found
1501/// for converting `std::declval<t_SRC>()` to one of (template parameters)
1502/// `t_HEAD, t_TAIL...`.
1503template <class t_SRC, class t_HEAD, class... t_TAIL>
1504struct Variant_OverloadHelper<
1505 t_SRC,
1506 bsl::variant<t_HEAD, t_TAIL...>,
1507 bsl::void_t<decltype(Variant_OverloadSetImp<t_SRC, 0, t_HEAD, t_TAIL...>::
1508 candidate(std::declval<t_SRC>()))> > {
1509 typedef decltype(
1510 Variant_OverloadSetImp<t_SRC, 0, t_HEAD, t_TAIL...>::candidate(
1511 std::declval<t_SRC>())) Index;
1512};
1513
1514/// This component-private metafunction computes the index of the
1515/// alternative in (template parameter) `t_VARIANT` that is the "unique"
1516/// best match for conversion from `std::declval<t_TYPE>()`, or
1517/// `bsl::variant_npos` if there is no such alternative. An alternative
1518/// that occurs multiple times in `t_VARIANT` (possibly with varying
1519/// cv-qualifications) is considered to occur only once; thus, if all
1520/// alternatives that are tied for the best match are the same type
1521/// (possibly with varying cv-qualifications), the result is the lowest
1522/// index at which that type (with any cv-qualification) occurs.
1523template <class t_TYPE, class t_VARIANT>
1524struct Variant_ConvertIndex
1525: Variant_OverloadHelper<t_TYPE, t_VARIANT>::Index {
1526};
1527
1528#else // BSL_VARIANT_FULL_IMPLEMENTATION
1529
1530#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1531/// This component-private metafunction computes `t_INDEX + i`, where `i` is
1532/// the zero-based index of the first occurrence of (template parameter)
1533/// `t_TYPE` in (template parameters) `t_HEAD, t_TAIL...`, or
1534/// `bsl::variant_npos` if not found. An alternative is considered to match
1535/// `t_TYPE` if the two types are the same modulo cv-qualification. This
1536/// metafunction is used to implement `Variant_ConvertIndex`.
1537template <size_t t_INDEX,
1538 class t_TYPE,
1539 class t_HEAD = BSLSTL_VARIANT_NOT_A_TYPE,
1540 class... t_TAIL>
1541struct Variant_ConvertToIndexImpl;
1542
1543/// Specialization for the case when t_ARGS is empty, i.e. the type wasn't
1544/// found in the given list of template type arguments.
1545template <size_t t_INDEX, class t_TYPE>
1546struct Variant_ConvertToIndexImpl<t_INDEX, t_TYPE, BSLSTL_VARIANT_NOT_A_TYPE>
1547: bsl::integral_constant<size_t, bsl::variant_npos> {
1548};
1549template <size_t t_INDEX, class t_TYPE, class t_HEAD, class... t_TAIL>
1550struct Variant_ConvertToIndexImpl<t_INDEX, t_TYPE, t_HEAD, t_TAIL...>
1551: bsl::conditional<
1552 bsl::is_same<typename bsl::remove_cv<t_TYPE>::type,
1553 typename bsl::remove_cv<t_HEAD>::type>::value,
1554 bsl::integral_constant<size_t, t_INDEX>,
1555 Variant_ConvertToIndexImpl<t_INDEX + 1, t_TYPE, t_TAIL...> >::type {
1556};
1557
1558/// This component-private metafunction computes the zero-based index of the
1559/// first occurrence of (template parameter) `t_TYPE` in the list of
1560/// alternatives of (template parameter) `t_VARIANT`, or `bsl::variant_npos`
1561/// if not found. An alternative is considered to match `t_TYPE` if the two
1562/// types are the same modulo cv-qualification. The primary template (used
1563/// when `t_VARIANT` is not a `bsl::variant`) is not defined. This
1564/// metafunction is used to determine the alternative to be constructed or
1565/// assigned to from a given argument type when the alternative type is not explicitly specified.
1566///
1567/// \note Note that in C++11 and later,
1568/// `Variant_ConvertIndex` allows implicit conversions, but this behavior
1569/// cannot be implemented in C++03.
1570template <class t_TYPE, class t_VARIANT>
1571struct Variant_ConvertIndex;
1572
1573template <class t_TYPE, class t_HEAD, class... t_TAIL>
1574struct Variant_ConvertIndex<t_TYPE, bsl::variant<t_HEAD, t_TAIL...> >
1575: Variant_ConvertToIndexImpl<
1576 0,
1577 typename bslmf::MovableRefUtil::RemoveReference<t_TYPE>::type,
1578 t_HEAD,
1579 t_TAIL...> {
1580};
1581
1582#endif
1583#endif // BSL_VARIANT_FULL_IMPLEMENTATION
1584
1585/// This component-private metafunction is derived from `bsl::true_type` if
1586/// there is a unique best match alternative in (template parameter)
1587/// `t_VARIANT` for 'std::declval<t_TYPE>() and that alternative is
1588/// constructible from `std::declval<t_TYPE>(), and `bsl::false_type'
1589/// otherwise.
1590template <class t_VARIANT,
1591 class t_TYPE,
1592 size_t t_INDEX = BSLSTL_VARIANT_CONVERT_INDEX_OF(t_TYPE, t_VARIANT)>
1593struct Variant_IsAlternativeConstructibleFrom
1594: bsl::integral_constant<
1595 bool,
1596 Variant_IsConstructible<
1597 typename bsl::variant_alternative<t_INDEX, t_VARIANT>::type,
1598 t_TYPE>::value &&
1599 Variant_HasUniqueCVType<BSLSTL_VARIANT_CONVERT_TYPE_OF(t_TYPE,
1600 t_VARIANT),
1601 t_VARIANT>::value> {
1602};
1603
1604template <class t_VARIANT, class t_TYPE>
1605struct Variant_IsAlternativeConstructibleFrom<t_VARIANT,
1606 t_TYPE,
1607 bsl::variant_npos>
1608: bsl::false_type {
1609};
1610
1611/// This component-private metafunction is derived from `bsl::true_type` if
1612/// there is a unique best match alternative in (template parameter)
1613/// `t_VARIANT` for `std::declval<t_TYPE>()` and that alternative is both
1614/// constructible and assignable from `std::declval<t_TYPE>()`, and
1615/// `bsl::false_type` otherwise.
1616template <class t_VARIANT,
1617 class t_TYPE,
1618 size_t t_INDEX = BSLSTL_VARIANT_CONVERT_INDEX_OF(t_TYPE, t_VARIANT)>
1619struct Variant_isAlternativeAssignableFrom
1620: bsl::integral_constant<
1621 bool,
1622 Variant_IsAssignable<
1623 typename bsl::variant_alternative<t_INDEX, t_VARIANT>::type&,
1624 t_TYPE>::value &&
1625 Variant_HasUniqueCVType<BSLSTL_VARIANT_CONVERT_TYPE_OF(t_TYPE,
1626 t_VARIANT),
1627 t_VARIANT>::value> {
1628};
1629
1630template <class t_VARIANT, class t_TYPE>
1631struct Variant_isAlternativeAssignableFrom<t_VARIANT,
1632 t_TYPE,
1633 bsl::variant_npos>
1634: bsl::false_type {
1635};
1636
1637/// This component-private metafunction declares a member `type` that is an
1638/// alias to the `std::variant` type corresponding to `t_TYPE` if one
1639/// exists, and `void` otherwise.
1640///
1641/// See @ref bslstl_variant
1642template <class t_TYPE>
1643struct Variant_CorrespondingStdVariant {
1644 typedef void type;
1645};
1646
1647#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1648template <class t_HEAD, class... t_TAIL>
1649struct Variant_CorrespondingStdVariant<bsl::variant<t_HEAD, t_TAIL...>> {
1650 typedef std::variant<t_HEAD, t_TAIL...> type;
1651};
1652#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1653
1654/// This component-private metafunction is derived from `bsl::true_type` if
1655/// (template parameter) `t_TYPE` is neither a tag type, nor the type
1656/// (template parameter) `t_VARIANT` (modulo cv-qualification), nor the
1657/// corresponding (possibly cv-qualified) `std::variant` type, there is a
1658/// unique best match alternative in `t_VARIANT` for
1659/// `std::declval<t_TYPE>()`, and that alternative is constructible from
1660/// `std::declval<t_TYPE>()`; otherwise, this metafunction is derived from
1661/// `bsl::false_type`.
1662template <class t_VARIANT, class t_TYPE>
1663struct Variant_ConstructsFromType
1664: bsl::integral_constant<
1665 bool,
1666 !bsl::is_same<typename bsl::remove_cvref<t_TYPE>::type,
1667 t_VARIANT>::value &&
1668 !Variant_IsTag<typename bsl::remove_cvref<t_TYPE>::type>::value &&
1669 !bsl::is_same<
1670 typename Variant_CorrespondingStdVariant<t_VARIANT>::type,
1671 typename bsl::remove_cvref<t_TYPE>::type>::value &&
1672 Variant_IsAlternativeConstructibleFrom<t_VARIANT, t_TYPE>::value> {
1673};
1674
1675/// This component-private metafunction is derived from `bsl::true_type` if
1676/// (template parameter) `t_TYPE` is neither a tag type nor the type
1677/// (template parameter) `t_VARIANT` (modulo cv-qualification), there is a
1678/// unique best match alternative in `t_VARIANT` for
1679/// `std::declval<t_TYPE>()`, and that alternative is constructible and
1680/// assignable from `std::declval<t_TYPE>()`; otherwise, this metafunction
1681/// is derived from `bsl::false_type`.
1682template <class t_VARIANT, class t_TYPE>
1683struct Variant_AssignsFromType
1684: bsl::integral_constant<
1685 bool,
1686 !bsl::is_same<typename bsl::remove_cvref<t_TYPE>::type,
1687 t_VARIANT>::value &&
1688 Variant_IsAlternativeConstructibleFrom<t_VARIANT, t_TYPE>::value &&
1689 Variant_isAlternativeAssignableFrom<t_VARIANT, t_TYPE>::value> {
1690};
1691
1692#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1693/// This component-private constexpr variable template is `true` if
1694/// `t_VARIANT` is a specialization of `bsl::variant`, and `t_STD_VARIANT`
1695/// is the `std::variant` type (possibly with added cvref-qualification)
1696/// that has the same sequence of alternatives, and each alternative of
1697/// `t_VARIANT` is constructible from the corresponding alternative of
1698/// `t_STD_VARIANT` (with cv-qualification and value category matching that of `t_STD_VARIANT`).
1699///
1700/// \note Note that we use `bsl::conjunction_v` for its
1701/// short-circuiting properties: if `t_STD_VARIANT` isn`t a `std::variant`
1702/// (for example, if it`s a `bsl::variant`) we avoid recursing into the
1703/// constraints of `bsl::variant`.
1704template <class t_VARIANT, class t_STD_VARIANT>
1705constexpr bool variant_constructsFromStd =
1706 bsl::conjunction_v<
1707 bsl::is_same<typename Variant_CorrespondingStdVariant<t_VARIANT>::type,
1708 bsl::remove_cvref_t<t_STD_VARIANT>>,
1709 std::is_constructible<bsl::remove_cvref_t<t_STD_VARIANT>,
1710 t_STD_VARIANT>>;
1711#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1712
1713#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
1714// The following component-private machinery allows for conditionally deleting
1715// special member functions.
1716
1717/// This component-private class has deleted copy constructor if (template
1718/// parameter) `t_ISCOPYCONSTRUCTIBLE` is `false`. All other special member
1719/// functions are defaulted.
1720///
1721/// See @ref bslstl_variant
1722template <bool t_ISCOPYCONSTRUCTIBLE>
1723struct Variant_CopyConstructorBase {
1724};
1725template <>
1726struct Variant_CopyConstructorBase<false> {
1727 Variant_CopyConstructorBase() = default;
1728 Variant_CopyConstructorBase(const Variant_CopyConstructorBase&) = delete;
1729 Variant_CopyConstructorBase(Variant_CopyConstructorBase&&) = default;
1730 Variant_CopyConstructorBase&
1731 operator=(const Variant_CopyConstructorBase&) = default;
1732 Variant_CopyConstructorBase&
1733 operator=(Variant_CopyConstructorBase&&) = default;
1734};
1735
1736/// This component-private class has deleted move constructor if (template
1737/// parameter) `t_ISMOVECONSTRUCTIBLE` is `false`. All other special member
1738/// functions are defaulted.
1739template <bool t_ISCOPYCONSTRUCTIBLE, bool t_ISMOVECONSTRUCTIBLE>
1740struct Variant_MoveConstructorBase
1741: Variant_CopyConstructorBase<t_ISCOPYCONSTRUCTIBLE> {
1742};
1743template <bool t_ISCOPYCONSTRUCTIBLE>
1744struct Variant_MoveConstructorBase<t_ISCOPYCONSTRUCTIBLE, false>
1745: Variant_CopyConstructorBase<t_ISCOPYCONSTRUCTIBLE> {
1746 Variant_MoveConstructorBase() = default;
1747 Variant_MoveConstructorBase(const Variant_MoveConstructorBase&) = default;
1748 Variant_MoveConstructorBase(Variant_MoveConstructorBase&&) = delete;
1749 Variant_MoveConstructorBase&
1750 operator=(const Variant_MoveConstructorBase&) = default;
1751 Variant_MoveConstructorBase&
1752 operator=(Variant_MoveConstructorBase&&) = default;
1753};
1754
1755/// This component-private class has deleted copy assignment operator if
1756/// (template parameter) `t_ISCOPYASSIGNABLE` is `false`. All other special
1757/// member functions are defaulted.
1758template <bool t_ISCOPYCONSTRUCTIBLE,
1759 bool t_ISMOVECONSTRUCTIBLE,
1760 bool t_ISCOPYASSIGNABLE>
1761struct Variant_CopyAssignBase
1762: Variant_MoveConstructorBase<t_ISCOPYCONSTRUCTIBLE, t_ISMOVECONSTRUCTIBLE> {
1763};
1764template <bool t_ISCOPYCONSTRUCTIBLE, bool t_ISMOVECONSTRUCTIBLE>
1765struct Variant_CopyAssignBase<t_ISCOPYCONSTRUCTIBLE,
1766 t_ISMOVECONSTRUCTIBLE,
1767 false>
1768: Variant_MoveConstructorBase<t_ISCOPYCONSTRUCTIBLE, t_ISMOVECONSTRUCTIBLE> {
1769 Variant_CopyAssignBase() = default;
1770 Variant_CopyAssignBase(const Variant_CopyAssignBase&) = default;
1771 Variant_CopyAssignBase(Variant_CopyAssignBase&&) = default;
1772 Variant_CopyAssignBase& operator=(const Variant_CopyAssignBase&) = delete;
1773 Variant_CopyAssignBase& operator=(Variant_CopyAssignBase&&) = default;
1774};
1775
1776/// This component-private class has deleted move assignment operator if
1777/// (template parameter) `t_ISMOVEASSIGNABLE` is `false`. All other special
1778/// member functions are defaulted.
1779template <bool t_ISCOPYCONSTRUCTIBLE,
1780 bool t_ISMOVECONSTRUCTIBLE,
1781 bool t_ISCOPYASSIGNABLE,
1782 bool t_ISMOVEASSIGNABLE>
1783struct Variant_MoveAssignBase : Variant_CopyAssignBase<t_ISCOPYCONSTRUCTIBLE,
1784 t_ISMOVECONSTRUCTIBLE,
1785 t_ISCOPYASSIGNABLE> {
1786};
1787template <bool t_ISCOPYCONSTRUCTIBLE,
1788 bool t_ISMOVECONSTRUCTIBLE,
1789 bool t_ISCOPYASSIGNABLE>
1790struct Variant_MoveAssignBase<t_ISCOPYCONSTRUCTIBLE,
1791 t_ISMOVECONSTRUCTIBLE,
1792 t_ISCOPYASSIGNABLE,
1793 false>
1794: Variant_CopyAssignBase<t_ISCOPYCONSTRUCTIBLE,
1795 t_ISMOVECONSTRUCTIBLE,
1796 t_ISCOPYASSIGNABLE> {
1797 Variant_MoveAssignBase() = default;
1798 Variant_MoveAssignBase(const Variant_MoveAssignBase&) = default;
1799 Variant_MoveAssignBase(Variant_MoveAssignBase&&) = default;
1800 Variant_MoveAssignBase& operator=(const Variant_MoveAssignBase&) = default;
1801 Variant_MoveAssignBase& operator=(Variant_MoveAssignBase&&) = delete;
1802};
1803
1804/// This component-private class has special member functions that are
1805/// either deleted or defaulted according to the specified template
1806/// parameters.
1807template <bool t_ISCOPYCONSTRUCTIBLE,
1808 bool t_ISMOVECONSTRUCTIBLE,
1809 bool t_ISCOPYASSIGNABLE,
1810 bool t_ISMOVEASSIGNABLE>
1811struct Variant_SMFBase : Variant_MoveAssignBase<t_ISCOPYCONSTRUCTIBLE,
1812 t_ISMOVECONSTRUCTIBLE,
1813 t_ISCOPYASSIGNABLE,
1814 t_ISMOVEASSIGNABLE> {
1815};
1816
1817/// This component-private metafunction is derived from `bsl::true_type` if
1818/// all template parameters are copy constructible, and `bsl::false_type`
1819/// otherwise.
1820template <class t_HEAD, class... t_TAIL>
1821struct Variant_IsCopyConstructibleAll
1822: bsl::integral_constant<
1823 bool,
1824 std::is_copy_constructible<t_HEAD>::value &&
1825 Variant_IsCopyConstructibleAll<t_TAIL...>::value> {
1826};
1827
1828template <class t_HEAD>
1829struct Variant_IsCopyConstructibleAll<t_HEAD>
1830: std::is_copy_constructible<t_HEAD> {
1831};
1832
1833/// This component-private metafunction is derived from `bsl::true_type` if
1834/// all template parameters are move constructible, and `bsl::false_type`
1835/// otherwise.
1836template <class t_HEAD, class... t_TAIL>
1837struct Variant_IsMoveConstructibleAll
1838: bsl::integral_constant<
1839 bool,
1840 std::is_move_constructible<t_HEAD>::value &&
1841 Variant_IsMoveConstructibleAll<t_TAIL...>::value> {
1842};
1843
1844template <class t_HEAD>
1845struct Variant_IsMoveConstructibleAll<t_HEAD>
1846: std::is_move_constructible<t_HEAD> {
1847};
1848
1849/// This component-private metafunction is derived from `bsl::true_type` if
1850/// all template parameters are copy assignable, and `bsl::false_type`
1851/// otherwise.
1852template <class t_HEAD, class... t_TAIL>
1853struct Variant_IsCopyAssignableAll
1854: bsl::integral_constant<bool,
1855 std::is_copy_assignable<t_HEAD>::value &&
1856 Variant_IsCopyAssignableAll<t_TAIL...>::value> {
1857};
1858
1859template <class t_HEAD>
1860struct Variant_IsCopyAssignableAll<t_HEAD> : std::is_copy_assignable<t_HEAD> {
1861};
1862
1863/// This component-private metafunction is derived from `bsl::true_type` if
1864/// all template parameters are move assignable, and `bsl::false_type`
1865/// otherwise.
1866template <class t_HEAD, class... t_TAIL>
1867struct Variant_IsMoveAssignableAll
1868: bsl::integral_constant<bool,
1869 std::is_move_assignable<t_HEAD>::value &&
1870 Variant_IsMoveAssignableAll<t_TAIL...>::value> {
1871};
1872
1873template <class t_HEAD>
1874struct Variant_IsMoveAssignableAll<t_HEAD> : std::is_move_assignable<t_HEAD> {
1875};
1876#endif // BSL_VARIANT_FULL_IMPLEMENTATION
1877
1878#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
1879template <class t_RET, class t_VISITOR, class t_VARIANT, size_t t_INDEX>
1880struct Variant_Function {
1881 /// This component-private function invokes the specified `visitor` with
1882 /// the active alternative object of the specified `variant` and
1883 /// implicitly converts the return type to (template parameter) `t_RET`.
1884 /// The pre-C++17 implementation is limited to invocations of the form `visitor(variant)`.
1885 ///
1886 /// \pre The behavior is undefined unless (template
1887 /// parameter) `t_INDEX` is the index of the active alternative.
1888 static t_RET functionImpl(t_VISITOR&& visitor, t_VARIANT&& variant)
1889 {
1890#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1891 return std::invoke(
1892 std::forward<t_VISITOR>(visitor),
1893 bsl::get<t_INDEX>(std::forward<t_VARIANT>(variant)));
1894#else
1895 return std::forward<t_VISITOR>(visitor)(
1896 bsl::get<t_INDEX>(std::forward<t_VARIANT>(variant)));
1897#endif
1898 }
1899};
1900
1901/// This partial specialization is used when `t_RET` is `void`. The visitor
1902/// is invoked and its return value, if any, is ignored. This partial
1903/// specialization is necessary because a `void`-returning function cannot
1904/// contain a `return` statement with a non-`void` operand.
1905template <class t_VISITOR, class t_VARIANT, size_t t_INDEX>
1906struct Variant_Function<void, t_VISITOR, t_VARIANT, t_INDEX> {
1907
1908 static void functionImpl(t_VISITOR&& visitor, t_VARIANT&& variant)
1909 {
1910#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1911 std::invoke(std::forward<t_VISITOR>(visitor),
1912 bsl::get<t_INDEX>(std::forward<t_VARIANT>(variant)));
1913#else
1914 std::forward<t_VISITOR>(visitor)(
1915 bsl::get<t_INDEX>(std::forward<t_VARIANT>(variant)));
1916#endif
1917 }
1918};
1919
1920template <class t_RET, class t_VISITOR, class t_VARIANT, size_t t_INDEX>
1921struct Variant_FunctionId {
1922 /// This component-private function invokes the specified `visitor` with
1923 /// a `bsl::in_place_index_t` tag representing the value of (template
1924 /// parameter) `t_INDEX` and the active alternative object of the
1925 /// specified `variant`, implicitly converting the return type to (template parameter) `t_RET`.
1926 ///
1927 /// \pre The behavior is undefined unless
1928 /// `t_INDEX` is the index of the active alternative.
1929 static t_RET functionImpl(t_VISITOR&& visitor, t_VARIANT&& variant)
1930 {
1931 return visitor(bsl::in_place_index_t<t_INDEX>(),
1932 bsl::get<t_INDEX>(std::forward<t_VARIANT>(variant)));
1933 }
1934};
1935
1936/// This component-private struct computes an array in which element `i` is
1937/// a pointer to
1938/// `Variant_Function<t_RET, t_VISITOR, t_VARIANT, i>::functionImpl`,
1939/// defined above as a function that invokes a `t_VISITOR` with alternative
1940/// `i` of `t_VARIANT` and implicitly converts the return type to `t_RET`.
1941template <class t_RET, class t_VISITOR, class t_VARIANT, class t_DUMMY>
1942struct Variant_VTable;
1943
1944/// In order to allow for perfect forwarding, both t_VISITOR and t_VARIANT
1945/// must be of reference type. If they are not, something went wrong.
1946template <class t_RET, class t_VISITOR, class t_VARIANT, size_t... t_INDICES>
1947struct Variant_VTable<t_RET,
1948 t_VISITOR,
1949 t_VARIANT,
1950 bslmf::IntegerSequence<std::size_t, t_INDICES...> > {
1951 BSLMF_ASSERT(bsl::is_reference<t_VISITOR>::value);
1952 BSLMF_ASSERT(bsl::is_reference<t_VARIANT>::value);
1953
1954 typedef t_RET (*FuncPtr)(t_VISITOR, t_VARIANT);
1955
1956 static BSLS_KEYWORD_CONSTEXPR FuncPtr s_map[sizeof...(t_INDICES)] = {
1957 &(Variant_Function<t_RET, t_VISITOR, t_VARIANT, t_INDICES>::
1958 functionImpl)...};
1959};
1960
1961/// This component-private struct computes an array in which element `i` is
1962/// a pointer to
1963/// `Variant_FunctionId<t_RET, t_VISITOR, t_VARIANT, i>::functionImpl`,
1964/// defined above as a function that invokes a `t_VISITOR` with a tag
1965/// representing `i` and alternative `i` of `t_VARIANT`, implicitly
1966/// converting the return type to `t_RET`. Implementation note: The
1967/// constexpr static maps of pointers defined by `Variant_VTable` and this
1968/// class have deliberately been defined in two different classes as having
1969/// them in the same class caused issues with Clang and Microsoft Visual
1970/// C++.
1971template <class t_RET, class t_VISITOR, class t_VARIANT, class t_DUMMY>
1972struct Variant_VTableId;
1973
1974/// In order to allow for perfect forwarding, both t_VISITOR and t_VARIANT
1975/// must be of reference type. If they are not, something went wrong.
1976template <class t_RET, class t_VISITOR, class t_VARIANT, size_t... t_INDICES>
1977struct Variant_VTableId<t_RET,
1978 t_VISITOR,
1979 t_VARIANT,
1980 bslmf::IntegerSequence<std::size_t, t_INDICES...> > {
1981 BSLMF_ASSERT(bsl::is_reference<t_VISITOR>::value);
1982 BSLMF_ASSERT(bsl::is_reference<t_VARIANT>::value);
1983
1984 typedef t_RET (*FuncPtr)(t_VISITOR, t_VARIANT);
1985
1986 static BSLS_KEYWORD_CONSTEXPR FuncPtr s_mapId[sizeof...(t_INDICES)] = {
1987 &(Variant_FunctionId<t_RET, t_VISITOR, t_VARIANT, t_INDICES>::
1988 functionImpl)...};
1989};
1990
1991# if !defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES)
1992// inline definitions of component-private function pointer maps
1993template <class t_RET, class t_VISITOR, class t_VARIANT, size_t... t_INDICES>
1994BSLS_KEYWORD_CONSTEXPR typename Variant_VTable<
1995 t_RET,
1996 t_VISITOR,
1997 t_VARIANT,
1998 bslmf::IntegerSequence<std::size_t, t_INDICES...> >::FuncPtr
1999 Variant_VTable<t_RET,
2000 t_VISITOR,
2001 t_VARIANT,
2002 bslmf::IntegerSequence<std::size_t, t_INDICES...> >::s_map
2003 [sizeof...(t_INDICES)];
2004
2005template <class t_RET, class t_VISITOR, class t_VARIANT, size_t... t_INDICES>
2006BSLS_KEYWORD_CONSTEXPR typename Variant_VTableId<
2007 t_RET,
2008 t_VISITOR,
2009 t_VARIANT,
2010 bslmf::IntegerSequence<std::size_t, t_INDICES...> >::FuncPtr
2011 Variant_VTableId<t_RET,
2012 t_VISITOR,
2013 t_VARIANT,
2014 bslmf::IntegerSequence<std::size_t, t_INDICES...> >::
2015 s_mapId[sizeof...(t_INDICES)];
2016# endif
2017#else // BSL_VARIANT_FULL_IMPLEMENTATION
2018#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2019
2020template <class t_RET, class t_VISITOR, class t_VARIANT, class t_ALT_TYPE>
2021struct Variant_Function {
2022 /// This component-private function invokes the specified `visitor` on
2023 /// the contained value of the specified `variant`, implicitly
2024 /// converting the return type to (template parameter) `t_RET`.
2025 ///
2026 /// \pre The behavior is undefined if (template parameter) `t_ALT_TYPE` is not
2027 /// the type of the active alternative.
2028 static t_RET functionImpl(t_VISITOR& visitor, t_VARIANT& variant)
2029 {
2030 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2031 return visitor(ImpUtil::unsafeGet<t_ALT_TYPE>(variant));
2032 }
2033};
2034
2035/// This partial specialization is used when `t_RET` is `void`. The visitor
2036/// is invoked and its return value, if any, is ignored. This partial
2037/// specialization is necessary because a `void`-returning function cannot
2038/// contain a `return` statement with a non-`void` operand.
2039template <class t_VISITOR, class t_VARIANT, class t_ALT_TYPE>
2040struct Variant_Function<void, t_VISITOR, t_VARIANT, t_ALT_TYPE> {
2041
2042 static void functionImpl(t_VISITOR& visitor, t_VARIANT& variant)
2043 {
2044 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2045 visitor(ImpUtil::unsafeGet<t_ALT_TYPE>(variant));
2046 }
2047};
2048
2049template <class t_RET, class t_VISITOR, class t_VARIANT, class t_ALT_TYPE>
2050struct Variant_MoveFunction {
2051 /// This component-private function invokes the specified `visitor` with
2052 /// a `bslmf::MovableRef` referring to the active alternative object of
2053 /// the specified `variant`, implicitly converting the return type to (template parameter) `t_RET`.
2054 ///
2055 /// \pre The behavior is undefined unless
2056 /// `variant` has an active alternative of type (template parameter)
2057 /// `t_ALT_TYPE`.
2058 static t_RET functionImpl(t_VISITOR& visitor, t_VARIANT& variant)
2059 {
2060 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2061 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2062
2063 return visitor(
2064 MoveUtil::move(ImpUtil::unsafeGet<t_ALT_TYPE>(variant)));
2065 }
2066};
2067
2068/// This partial specialization is used when `t_RET` is `void`. The visitor
2069/// is invoked and its return value, if any, is ignored. This partial
2070/// specialization is necessary because a `void`-returning function cannot
2071/// contain a `return` statement with a non-`void` operand.
2072template <class t_VISITOR, class t_VARIANT, class t_ALT_TYPE>
2073struct Variant_MoveFunction<void, t_VISITOR, t_VARIANT, t_ALT_TYPE> {
2074
2075 static void functionImpl(t_VISITOR& visitor, t_VARIANT& variant)
2076 {
2077 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2078 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2079
2080 visitor(MoveUtil::move(ImpUtil::unsafeGet<t_ALT_TYPE>(variant)));
2081 }
2082};
2083
2084template <class t_RET, class t_VISITOR, class t_VARIANT, class t_ALT_TYPE>
2085struct Variant_FunctionId {
2086 /// This component-private function invokes the specified `visitor` with
2087 /// a `bsl::in_place_index_t` tag representing the index of the first
2088 /// occurrence of (template parameter) `t_ALT_TYPE` in the specified
2089 /// `variant` and the active alternative object of `variant`, implicitly
2090 /// converting the return type to (template parameter) `t_RET`.
2091 ///
2092 /// \pre The behavior is undefined unless `variant` has an active alternative of type `t_ALT_TYPE`.
2093 ///
2094 /// \note Note that the index passed to the visitor might
2095 /// not be the index of the active alternative, if that alternative
2096 /// occurs multiple times in `t_VARIANT`.
2097 static t_RET functionImpl(t_VISITOR& visitor, t_VARIANT& variant)
2098 {
2099 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2100 static const size_t t_INDEX = BSLSTL_VARIANT_INDEX_OF(
2101 t_ALT_TYPE, typename bsl::remove_cv<t_VARIANT>::type);
2102
2103 return visitor(bsl::in_place_index_t<t_INDEX>(),
2104 ImpUtil::unsafeGet<t_ALT_TYPE>(variant));
2105 }
2106};
2107
2108/// This component-private struct computes arrays in which element `i` is a
2109/// pointer to one of the `functionImpl` functions defined above, invoking
2110/// an lvalue of type (template parameter) `t_VISITOR` with alternative `i`
2111/// of (template parameter) `t_VARIANT` and implicitly converting the return
2112/// type to `t_RET`. The primary template (used when `t_VARIANT` is not a `bsl::variant`) is not defined.
2113///
2114/// \note Note that the `t_UNUSED` template
2115/// parameter is required due to limitations of `sim_cpp11_features.pl`.
2116template <class t_RET, class t_VISITOR, class t_VARIANT, class... t_UNUSED>
2117struct Variant_VTable;
2118
2119/// This partial specialization is used when the `bsl::variant` is not `const`.
2120template <class t_RET, class t_VISITOR, class t_HEAD, class... t_TAIL>
2121struct Variant_VTable<t_RET, t_VISITOR, bsl::variant<t_HEAD, t_TAIL...> > {
2122
2123 typedef t_RET (*FuncPtr)(t_VISITOR&, bsl::variant<t_HEAD, t_TAIL...>&);
2124
2125 typedef bsl::variant<t_HEAD, t_TAIL...> Variant;
2126
2127 /// Return a pointer to the first element of an array of function pointers
2128 /// that invoke the visitor with an lvalue referring to the corresponding
2129 /// alternative.
2130 static const FuncPtr *map()
2131 {
2132 static const FuncPtr s_mapArray[] = {
2133 &(Variant_Function<t_RET, t_VISITOR, Variant, t_HEAD>::
2134 functionImpl),
2135 &(Variant_Function<t_RET, t_VISITOR, Variant, t_TAIL>::
2136 functionImpl)...};
2137 return s_mapArray;
2138 }
2139
2140 /// Return a pointer to the first element of an array of function pointers
2141 /// that invoke the visitor with a `bslmf::MovableRef` referring to the
2142 /// corresponding alternative.
2143 static const FuncPtr *moveMap()
2144 {
2145 static const FuncPtr s_mapArray[] = {
2146 &(Variant_MoveFunction<t_RET, t_VISITOR, Variant, t_HEAD>::
2147 functionImpl),
2148 &(Variant_MoveFunction<t_RET, t_VISITOR, Variant, t_TAIL>::
2149 functionImpl)...};
2150 return s_mapArray;
2151 }
2152
2153 /// Return a pointer to the first element of an array of function pointers
2154 /// where element `i` invokes the visitor with a tag representing the index
2155 /// of the first alternative whose type is the same as that of alternative
2156 /// `i`, and an lvalue referring to alternative `i`.
2157 static const FuncPtr *mapId()
2158 {
2159 static const FuncPtr s_mapArray[] = {
2160 &(Variant_FunctionId<t_RET, t_VISITOR, Variant, t_HEAD>::
2161 functionImpl),
2162 &(Variant_FunctionId<t_RET, t_VISITOR, Variant, t_TAIL>::
2163 functionImpl)...};
2164 return s_mapArray;
2165 }
2166};
2167
2168/// This partial specialization is used when the 'bsl::variant' is 'const'.
2169template <class t_RET, class t_VISITOR, class t_HEAD, class... t_TAIL>
2170struct Variant_VTable<t_RET,
2171 t_VISITOR,
2172 const bsl::variant<t_HEAD, t_TAIL...> > {
2173
2174 typedef t_RET (*FuncPtr)(t_VISITOR&,
2175 const bsl::variant<t_HEAD, t_TAIL...>&);
2176
2177 typedef const bsl::variant<t_HEAD, t_TAIL...> Variant;
2178
2179 /// Return a pointer to the first element of an array of function pointers
2180 /// that invoke the visitor with an lvalue referring to the corresponding
2181 /// alternative.
2182 static const FuncPtr *map()
2183 {
2184 static const FuncPtr s_mapArray[] = {
2185 &(Variant_Function<t_RET, t_VISITOR, Variant, t_HEAD>::
2186 functionImpl),
2187 &(Variant_Function<t_RET, t_VISITOR, Variant, t_TAIL>::
2188 functionImpl)...};
2189 return s_mapArray;
2190 }
2191
2192 /// Return a pointer to the first element of an array of function pointers
2193 /// where element `i` invokes the visitor with a tag representing the index
2194 /// of the first alternative whose type is the same as that of alternative
2195 /// `i`, and an lvalue referring to alternative `i`.
2196 static const FuncPtr *mapId()
2197 {
2198 static const FuncPtr s_mapArray[] = {
2199 &(Variant_FunctionId<t_RET, t_VISITOR, Variant, t_HEAD>::
2200 functionImpl),
2201 &(Variant_FunctionId<t_RET, t_VISITOR, Variant, t_TAIL>::
2202 functionImpl)...};
2203 return s_mapArray;
2204 }
2205};
2206
2207#endif
2208#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2209
2210} // close package namespace
2211
2212
2213namespace bsl {
2214#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2215/// Return the result of invoking the specified `visitor` with the currently
2216/// active alternative of the specified `variant`, implicitly converting the
2217/// result to the explicitly specified (template parameter) `t_RET`. If
2218/// `variant` does not hold a value, throw an exception of type `bsl::bad_variant_access`.
2219///
2220/// \note Note that unlike the `visit` overload below
2221/// that deduces its return type, this overload does not require the visitor
2222/// to yield the exact same type for each alternative, but only requires
2223/// each such type to be implicitly convertible to `t_RET`. This function
2224/// differs from the standard in the following ways:
2225/// * only one variant is supported
2226/// * constexpr is not implemented
2227/// * before C++17, only `t_VISITOR(ALTERNATIVE)` form of visitation is
2228/// supported; cases where the visitor is a pointer to member are not
2229/// supported.
2230template <class t_RET, class t_VISITOR, class t_VARIANT>
2231t_RET visit(t_VISITOR&& visitor, t_VARIANT&& variant)
2232{
2233 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2234
2235 if (variant.valueless_by_exception()) {
2236 BSLS_THROW(bsl::bad_variant_access());
2237 }
2238 return ImpUtil::visit<t_RET>(std::forward<t_VISITOR>(visitor),
2239 ImpUtil::asVariant(
2240 std::forward<t_VARIANT>(variant)));
2241}
2242
2243/// Return the result of invoking the specified `visitor` with the currently
2244/// active alternative of the specified `variant`. If `variant` does not
2245/// hold a value, throw an exception of type `bsl::bad_variant_access`. For
2246/// each alternative, invocation of the visitor with that alternative shall
2247/// be of the same type and value category. This function differs from the
2248/// standard in the following ways:
2249/// * only one variant is supported
2250/// * constexpr is not implemented
2251/// * before C++17, only `t_VISITOR(ALTERNATIVE)` form of visitation is
2252/// supported; cases where the visitor is a pointer to member are not
2253/// supported.
2254template <class t_VISITOR, class t_VARIANT>
2255auto visit(t_VISITOR&& visitor, t_VARIANT&& variant) ->
2256typename bsl::invoke_result<
2257 t_VISITOR&&,
2258 decltype(get<0>(BloombergLP::bslstl::Variant_ImpUtil::
2259 asVariant(std::forward<t_VARIANT>(variant))))>::type
2260{
2261 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2262 typedef decltype(ImpUtil::asVariant(std::forward<t_VARIANT>(variant)))
2263 VariantFwdRefType;
2264 typedef typename bsl::invoke_result<
2265 t_VISITOR&&,
2266 decltype(get<0>(ImpUtil::
2267 asVariant(std::forward<t_VARIANT>(variant))))>::type RET;
2268
2269 static_assert(
2270 BloombergLP::bslstl::
2271 Variant_IsSameReturnType<RET, t_VISITOR&&, VariantFwdRefType>::value,
2272 "The value type and category of invoking the visitor with "
2273 "every alternative is not the same");
2274 if (variant.valueless_by_exception()) {
2275 BSLS_THROW(bsl::bad_variant_access());
2276 }
2277 return ImpUtil::visit<RET>(std::forward<t_VISITOR>(visitor),
2278 ImpUtil::asVariant(
2279 std::forward<t_VARIANT>(variant)));
2280}
2281
2282/// Return the result of invoking the specified `visitor` with the currently
2283/// active alternative of the specified `variant`, implicitly converting the
2284/// result to the explicitly specified (template parameter) `t_RET`. If
2285/// `variant` does not hold a value, throw an exception of type
2286/// `bsl::bad_variant_access`. This function is provided in all language
2287/// versions for compatibility with the C++03 version (see below), but in new
2288/// code in C++11 and later, `bsl::visit` should be used instead of this
2289/// function.
2290template <class t_RET, class t_VISITOR, class t_VARIANT>
2291t_RET visitR(t_VISITOR& visitor, t_VARIANT&& variant)
2292{
2293 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2294 return visit<t_RET>(visitor,
2295 ImpUtil::asVariant(std::forward<t_VARIANT>(variant)));
2296}
2297#else // BSL_VARIANT_FULL_IMPLEMENTATION
2298
2299/// Return the result of invoking the specified `visitor` with the currently
2300/// active alternative of the specified `variant`, implicitly converting the
2301/// result to the explicitly specified (template parameter) `t_RET`. If
2302/// `variant` does not hold a value, throw an exception of type
2303/// `bsl::bad_variant_access`. Unlike `visit`, which deduces its return type,
2304/// this function does not require the visitor to yield the exact same type for
2305/// each alternative, but only requires each such type to be implicitly
2306/// convertible to `t_RET`. Implementation note: Due to limitations of the
2307/// type deduction facility in C++03, this function can not share the same name
2308/// as the deduced type `visit` because it is not possible to discern between
2309/// invocation of non deduced return type `visit` where the return type
2310/// parameter is explicitly specified and invocation of deduced return type
2311/// `visit` where the visitor type parameter is explicitly specified.
2312template <class t_RET, class t_VISITOR, class t_VARIANT>
2313t_RET visitR(t_VISITOR& visitor, t_VARIANT& variant)
2314{
2315 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2316
2318 BSLS_THROW(bsl::bad_variant_access());
2319 }
2320 return ImpUtil::visit<t_RET>(visitor, ImpUtil::asVariant(variant));
2321}
2322
2323/// Return the result of invoking the specified `visitor` with a
2324/// `bslmf::MovableRef` referring to the currently active alternative of the
2325/// specified `variant`, implicitly converting the result to the explicitly
2326/// specified (template parameter) `t_RET`. If `variant` does not hold a
2327/// value, throw an exception of type `bsl::bad_variant_access`. Unlike
2328/// `visit`, which deduces its return type, this function does not require the
2329/// visitor to yield the exact same type for each alternative, but only
2330/// requires each such type to be implicitly convertible to `t_RET`.
2331/// Implementation note: Due to limitations of the type deduction facility in
2332/// C++03, this function can not share the same name as the deduced type
2333/// `visit` because it is not possible to discern between invocation of non
2334/// deduced return type `visit` where the return type parameter is explicitly
2335/// specified and invocation of deduced return type `visit` where the visitor
2336/// type parameter is explicitly specified.
2337template <class t_RET, class t_VISITOR, class t_VARIANT>
2338t_RET visitR(t_VISITOR& visitor,
2339 BloombergLP::bslmf::MovableRef<t_VARIANT> variant)
2340{
2341 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2342
2343 t_VARIANT& lvalue = variant;
2344 if (lvalue.valueless_by_exception()) {
2345 BSLS_THROW(bsl::bad_variant_access());
2346 }
2347 return ImpUtil::moveVisit<t_RET>(visitor, ImpUtil::asVariant(lvalue));
2348}
2349
2350/// Return the result of invoking the specified `visitor` with the currently
2351/// active alternative of the specified `variant`. If `variant` does not hold
2352/// a value, throw an exception of type `bsl::bad_variant_access`. For each
2353/// alternative, invocation of the visitor with that alternative shall be of
2354/// the same type and value category.
2355template <class t_VISITOR, class t_VARIANT>
2356typename bsl::invoke_result<
2357 t_VISITOR&,
2359visit(t_VISITOR& visitor, t_VARIANT& variant)
2360{
2361 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2362
2364 BSLS_THROW(bsl::bad_variant_access());
2365 }
2366 typedef typename bsl::invoke_result<
2367 t_VISITOR&,
2369
2371 (BloombergLP::bslstl::
2372 Variant_IsSameReturnType<Ret, t_VISITOR, t_VARIANT&>::value));
2373
2374 return ImpUtil::visit<Ret>(visitor, ImpUtil::asVariant(variant));
2375}
2376
2377/// Return the result of invoking the specified `visitor` with a
2378/// `bslmf::MovableRef` referring to the currently active alternative of the
2379/// specified `variant`. If `variant` does not hold a value, throw an
2380/// exception of type `bsl::bad_variant_access`. For each alternative,
2381/// invocation of the visitor with that alternative shall be of the same type
2382/// and value category.
2383template <class t_VISITOR, class t_VARIANT>
2384typename bsl::invoke_result<
2385 t_VISITOR&,
2386 BloombergLP::bslmf::MovableRef<
2388visit(t_VISITOR& visitor, BloombergLP::bslmf::MovableRef<t_VARIANT> variant)
2389{
2390 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2391
2392 t_VARIANT& lvalue = variant;
2393 if (lvalue.valueless_by_exception()) {
2394 BSLS_THROW(bsl::bad_variant_access());
2395 }
2396 typedef typename bsl::invoke_result<
2397 t_VISITOR&,
2398 BloombergLP::bslmf::MovableRef<
2400
2401 BSLMF_ASSERT((BloombergLP::bslstl::Variant_IsSameReturnType<
2402 Ret,
2403 t_VISITOR,
2404 BloombergLP::bslmf::MovableRef<t_VARIANT> >::value));
2405
2406 return ImpUtil::moveVisit<Ret>(visitor, ImpUtil::asVariant(lvalue));
2407}
2408
2409#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2410
2411} // close namespace bsl
2412
2413
2414namespace bslstl {
2415
2416 // ========================
2417 // class Variant_NoSuchType
2418 // ========================
2419
2420/// This component-private trivial tag type is used to distinguish between
2421/// arguments passed by a user, and an `enable_if` argument. It is not default
2422/// constructible so the following construction never invokes a constrained
2423/// single parameter constructor:
2424/// @code
2425/// struct SomeType
2426/// {
2427/// SomeType(int, const std::string &s = "default"){}
2428/// };
2429///
2430/// variant<SomeType> o(1, {});
2431/// @endcode
2432///
2433/// See @ref bslstl_variant
2435
2436 // CREATORS
2437
2438 /// Create a `Variant_NoSuchType` object.
2441};
2442
2443#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2444/// This component-private class manages an object of type (template parameter) `t_TYPE` that is stored in a `variant` object.
2445///
2446/// \note Note that `t_TYPE` may be
2447/// const-qualified, in which case the internally stored object is not `const`,
2448/// but the interface of this class prevents modification thereof.
2449///
2450/// See @ref bslstl_variant
2451template <class t_TYPE>
2452class Variant_DataImp {
2453
2454 private:
2455 // PRIVATE TYPES
2456 typedef typename bsl::remove_const<t_TYPE>::type StoredType;
2457
2458 // DATA
2459 bsls::ObjectBuffer<StoredType> d_buffer; // in-place 't_TYPE' object
2460
2461 public:
2462 // CREATORS
2463 Variant_DataImp() = default;
2464 // Create a 'Variant_DataImp' object that holds an empty buffer.
2465
2466 // MANIPULATORS
2467
2468 /// Create a `Variant_DataImp` object whose stored `t_TYPE` object is
2469 /// constructed by forwarding the specified `args` to
2470 /// `ConstructionUtil::construct` directly. This means the first
2471 /// argument in `args` must be a pointer to `bslma::Allocator`, which
2472 /// will be ignored if `t_TYPE` is not allocator-aware.
2473 template <class... t_ARGS>
2474 Variant_DataImp(t_ARGS&&... args);
2475
2476 /// Return a reference to the stored `t_TYPE` object.
2477 ///
2478 /// \pre The behavior is undefined unless this object contains a `t_TYPE` object (i.e., this
2479 /// object is currently managing the active alternative of a `bsl::variant`
2480 /// object).
2482 BSLS_KEYWORD_CONSTEXPR_CPP14 t_TYPE&& value() &&;
2483
2484 // ACCESSORS
2485
2486 /// Return a const reference to the stored `t_TYPE` object.
2487 ///
2488 /// \pre The behavior is undefined unless this object contains a `t_TYPE` object (i.e., this
2489 /// object is currently managing the active alternative of a `bsl::variant`
2490 /// object).
2491 BSLS_KEYWORD_CONSTEXPR_CPP14 const t_TYPE& value() const&;
2492 BSLS_KEYWORD_CONSTEXPR_CPP14 const t_TYPE&& value() const&&;
2493};
2494
2495/// This component-private union can hold a `Variant_DataImp` object for any
2496/// alternative in (template parameters) `t_TYPES...`. The primary template
2497/// is used when `t_TYPES...` is empty.
2498template <class... t_TYPES>
2499union Variant_Union {
2500};
2501
2502/// This partial specialization uses template recursion because C++ does not
2503/// support member packs.
2504template <class t_HEAD, class... t_TAIL>
2505union Variant_Union<t_HEAD, t_TAIL...> {
2506
2507 // PUBLIC DATA
2508 Variant_DataImp<t_HEAD> d_head;
2509 Variant_Union<t_TAIL...> d_tail;
2510
2511 // CREATORS
2512
2513 /// Create a `Variant_Union` object having no active alternative.
2514 Variant_Union() = default;
2515
2516 /// Create a `Variant_Union` object holding an object of type `t_HEAD`
2517 /// direct-initialized from the specified `args`.
2518 template <class... t_ARGS>
2519 Variant_Union(bsl::in_place_index_t<0>, t_ARGS&&... args)
2520 : d_head(std::forward<t_ARGS>(args)...)
2521 {
2522 }
2523
2524 /// Create a `Variant_Union` object holding the alternative at index
2525 /// (template parameter) `t_INDEX` in (template parameters) 't_HEAD,
2526 /// t_TAIL...`, direct-initialized from the specified `args'.
2527 ///
2528 /// \note Note that `t_INDEX` is not necessarily the absolute index of the desired
2529 /// alternative in the `bsl::variant` object. We use the tag to
2530 /// "unravel" the union until we get to the desired alternative type.
2531 template <size_t t_INDEX, class... t_ARGS>
2532 Variant_Union(bsl::in_place_index_t<t_INDEX>, t_ARGS&&... args)
2533 : d_tail(bsl::in_place_index_t<t_INDEX - 1>(),
2534 std::forward<t_ARGS>(args)...)
2535 {
2536 }
2537};
2538#else // BSL_VARIANT_FULL_IMPLEMENTATION
2539/// This component-private class manages an object of type (template parameter) `t_TYPE` that is stored in a `variant` object.
2540///
2541/// \note Note that `t_TYPE` may be
2542/// const-qualified, in which case the internally stored object is not `const`,
2543/// but the interface of this class prevents modification thereof.
2544///
2545/// See @ref bslstl_variant
2546template <class t_TYPE>
2548
2549 private:
2550 // PRIVATE TYPES
2551 typedef typename bsl::remove_const<t_TYPE>::type StoredType;
2552
2553 // DATA
2554 bsls::ObjectBuffer<StoredType> d_buffer; // in-place 't_TYPE' object
2555
2556 public:
2557 // CREATORS
2558
2559 /// Create a `Variant_DataImp` object that holds an empty buffer.
2560 Variant_DataImp() = default;
2561
2562 // MANIPULATOR
2563
2564 /// Return a reference to the stored `t_TYPE` object.
2565 ///
2566 /// \pre The behavior is undefined unless the enclosing union contains a `t_TYPE` object (i.e.,
2567 /// the enclosing `bsl::variant` has an active alternative of type
2568 /// `t_TYPE`).
2569 t_TYPE& value();
2570
2571 // ACCESSORS
2572
2573 /// Return a const reference to the stored `t_TYPE` object.
2574 ///
2575 /// \pre The behavior is undefined unless the enclosing union contains a `t_TYPE` object
2576 /// (i.e., the enclosing `bsl::variant` has an active alternative of type
2577 /// `t_TYPE`).
2578 const t_TYPE& value() const;
2579};
2580
2581#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2582/// This component-private union can hold a `Variant_DataImp` object for any
2583/// alternative in (template parameters) `t_HEAD, t_TAIL0, t_TAIL...`.
2584///
2585/// \note Note that the declaration and definition of the primary template must be kept
2586/// separate in order for `sim_cpp11_features.pl` to work properly. The
2587/// purpose of the `t_TAIL0` template parameter is explained below.
2588template <class t_HEAD = void, class... t_TAIL0 = void, class... t_TAIL>
2590
2591/// This specialization is used when the type list is empty.
2592template <>
2593union Variant_Union<void, void> {
2594};
2595
2596template <>
2597union Variant_Union<BloombergLP::bsls::CompilerFeaturesNilT> {
2598};
2599
2600/// The implementation of this template uses template recursion because C++
2601/// does not support member packs. The `t_TAIL0` template parameter is
2602/// needed in order to avoid an empty template argument list in the type of
2603/// the `d_tail` member, which causes an issue with the IBM compiler.
2604template <class t_HEAD, class t_TAIL0, class... t_TAIL>
2605union Variant_Union<t_HEAD, t_TAIL0, t_TAIL...> {
2606
2607 // PUBLIC DATA
2609 Variant_Union<t_TAIL0, t_TAIL...> d_tail;
2610};
2611#endif
2612#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2613
2614 // ==================================
2615 // class Variant_CopyConstructVisitor
2616 // ==================================
2617
2618/// This component-private class is a visitor that is used to implement the
2619/// copy constructor for `bsl::variant`.
2620///
2621/// See @ref bslstl_variant
2622template <class t_VARIANT_BASE>
2624
2625 private:
2626 // DATA
2627 t_VARIANT_BASE *d_variant_p;
2628
2629 public:
2630 // CREATORS
2631
2632 /// Create a `Variant_CopyConstructVisitor` object that, when invoked, will
2633 /// copy-construct an alternative in the specified `variant`.
2634 explicit Variant_CopyConstructVisitor(t_VARIANT_BASE *variant)
2635 : d_variant_p(variant)
2636 {
2637 BSLS_ASSERT_SAFE(d_variant_p);
2638 }
2639
2640 // ACCESSORS
2641
2642 /// Copy-construct the alternative at index (template parameter)
2643 /// `t_INDEX` from the specified `other` (i.e. the alternative that is being visited).
2644 ///
2645 /// \note Note that the allocator specified on construction
2646 /// of `*d_variant_p` will be used.
2647 template <size_t t_INDEX, class t_TYPE>
2648 void operator()(bsl::in_place_index_t<t_INDEX>, const t_TYPE& other) const
2649 {
2650 d_variant_p->template baseEmplace<t_INDEX>(other);
2651 }
2652};
2653
2654 // ==================================
2655 // class Variant_MoveConstructVisitor
2656 // ==================================
2657
2658/// This component-private class is a visitor that is used to implement the
2659/// move constructor for `bsl::variant`.
2660///
2661/// See @ref bslstl_variant
2662template <class t_VARIANT_BASE>
2664
2665 private:
2666 // PRIVATE TYPES
2667 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2668
2669 // DATA
2670 t_VARIANT_BASE *d_variant_p;
2671
2672 public:
2673 // CREATORS
2674
2675 /// Create a `Variant_MoveConstructVisitor` object that, when invoked,
2676 /// will move-construct an alternative in the specified `variant`.
2677 explicit Variant_MoveConstructVisitor(t_VARIANT_BASE *variant)
2678 : d_variant_p(variant)
2679 {
2680 BSLS_ASSERT_SAFE(d_variant_p);
2681 }
2682
2683 // ACCESSORS
2684
2685 /// Move-construct the alternative at index (template parameter)
2686 /// `t_INDEX` from the specified `other` (i.e. the alternative that is being visited).
2687 ///
2688 /// \note Note that the allocator specified on construction
2689 /// of `*d_variant_p` will be used.
2690 template <size_t t_INDEX, class t_TYPE>
2692 {
2693 d_variant_p->template baseEmplace<t_INDEX>(MoveUtil::move(other));
2694 }
2695};
2696
2697 // ===============================
2698 // class Variant_CopyAssignVisitor
2699 // ===============================
2700
2701/// This component-private class is a visitor that is used to implement the
2702/// copy assignment operator for `bsl::variant`.
2703///
2704/// See @ref bslstl_variant
2705template <class t_VARIANT>
2707
2708 private:
2709 // DATA
2710 t_VARIANT *d_variant_p;
2711
2712 public:
2713 // CREATORS
2714
2715 /// Create a `Variant_CopyAssignVisitor` object that, when invoked, will
2716 /// copy-assign to the active alternative of the specified `variant`.
2717 explicit Variant_CopyAssignVisitor(t_VARIANT *variant)
2718 : d_variant_p(variant)
2719 {
2720 BSLS_ASSERT_SAFE(d_variant_p);
2721 }
2722
2723
2724 public:
2725 // ACCESSORS
2726
2727 /// Copy-assign to the active alternative of `*d_variant_p` from the
2728 /// specified `value` (i.e. the alternative that is being visited).
2729 ///
2730 /// \pre The behavior is undefined unless (template parameter) `t_INDEX` is the
2731 /// index of the active alternative of `*d_variant_p` (or, in C++03, the
2732 /// index of an alternative that has the same type as the active
2733 /// alternative).
2734 template <size_t t_INDEX, class t_TYPE>
2735 void operator()(bsl::in_place_index_t<t_INDEX>, const t_TYPE& value) const
2736 {
2737#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2738 bsl::get<t_INDEX>(*d_variant_p) = value;
2739#else
2740 // When invoking this visitor in C++03, `t_INDEX` may not be the index
2741 // of the active alternative, but it will be an index of an alternative
2742 // of same type. However, because `t_TYPE` is deduced, it may be
2743 // missing cv-qualifications. `t_ALT_TYPE` will give the correct
2744 // cv-qualification.
2746 Alt_Type;
2747 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2748
2749 ImpUtil::unsafeGet<Alt_Type>(*d_variant_p) = value;
2750#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2751 }
2752};
2753
2754 // ===============================
2755 // class Variant_MoveAssignVisitor
2756 // ===============================
2757
2758/// This component-private class is a visitor that is used to implement the
2759/// move assignment operator for `bsl::variant`.
2760///
2761/// See @ref bslstl_variant
2762template <class t_VARIANT>
2764
2765 private:
2766 // PRIVATE TYPES
2767 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2768
2769 // DATA
2770 t_VARIANT *d_variant_p;
2771
2772 public:
2773 // CREATORS
2774
2775 /// Create a `Variant_MoveAssignVisitor` object that, when invoked, will
2776 /// move-assign to the active alternative of the specified `variant`.
2777 explicit Variant_MoveAssignVisitor(t_VARIANT *variant)
2778 : d_variant_p(variant)
2779 {
2780 BSLS_ASSERT_SAFE(d_variant_p);
2781 }
2782
2783 public:
2784 // ACCESSORS
2785
2786 /// Move-assign to the active alternative of `*d_variant_p` from the
2787 /// specified `value` (i.e. the alternative that is being visited).
2788 ///
2789 /// \pre The behavior is undefined unless (template parameter) `t_INDEX` is the
2790 /// index of the active alternative of `*d_variant_p` (or, in C++03, the
2791 /// index of an alternative that has the same type as the active
2792 /// alternative).
2793 template <size_t t_INDEX, class t_TYPE>
2795 {
2796#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2797 bsl::get<t_INDEX>(*d_variant_p) = MoveUtil::move(value);
2798#else
2799 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2800 ImpUtil::unsafeGet<t_TYPE>(*d_variant_p) = MoveUtil::move(value);
2801#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2802 }
2803};
2804
2805 // ================================
2806 // struct Variant_DestructorVisitor
2807 // ================================
2808
2809/// This component-private struct is a visitor that destroys the active
2810/// alternative of the visited `variant` object.
2811///
2812/// See @ref bslstl_variant
2814
2815 public:
2816 // ACCESSORS
2817
2818 /// Destroy the specified `object`, which is the alternative that is
2819 /// being visited.
2820 template <class t_TYPE>
2821 void operator()(t_TYPE& object) const
2822 {
2823 bslma::DestructionUtil::destroy(&object);
2824 }
2825};
2826
2827 // ==============================
2828 // struct Variant_##NAME##Visitor
2829 // ==============================
2830
2831#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2832#define BSLSTL_VARIANT_RELOP_VISITOR_DEFINITON(NAME, OP) \
2833 template <class t_VARIANT> \
2834 struct Variant_##NAME##Visitor { \
2835 /* When using this visitor, construct the visitor using the left */ \
2836 /* operand, and call visitation on the right operand. */ \
2837 explicit Variant_##NAME##Visitor(const t_VARIANT *variant) \
2838 : d_variant_p(variant) \
2839 { \
2840 BSLS_ASSERT_SAFE(d_variant_p); \
2841 } \
2842 \
2843 private: \
2844 const t_VARIANT *d_variant_p; \
2845 \
2846 public: \
2847 template <size_t t_INDEX, class t_TYPE> \
2848 bool operator()(bsl::in_place_index_t<t_INDEX>, \
2849 const t_TYPE& value) const \
2850 { \
2851 return (bsl::get<t_INDEX>(*d_variant_p) OP value); \
2852 } \
2853 }; \
2854 \
2855 template <class t_VARIANT> \
2856 bool Variant_ImpUtil::NAME(const t_VARIANT& lhs, const t_VARIANT& rhs) \
2857 { \
2858 BSLS_ASSERT(lhs.index() == rhs.index() && \
2859 !lhs.valueless_by_exception()); \
2860 \
2861 Variant_##NAME##Visitor<t_VARIANT> NAME##Visitor( \
2862 BSLS_UTIL_ADDRESSOF(lhs)); \
2863 return BSLSTL_VARIANT_VISITID(bool, NAME##Visitor, rhs); \
2864 }
2865#else
2866#define BSLSTL_VARIANT_RELOP_VISITOR_DEFINITON(NAME, OP) \
2867 template <class t_VARIANT> \
2868 struct Variant_##NAME##Visitor { \
2869 Variant_##NAME##Visitor(const t_VARIANT *variant) \
2870 : d_variant_p(variant) \
2871 { \
2872 BSLS_ASSERT_SAFE(d_variant_p); \
2873 } \
2874 \
2875 private: \
2876 const t_VARIANT *d_variant_p; \
2877 \
2878 public: \
2879 template <size_t t_INDEX, class t_TYPE> \
2880 bool operator()(bsl::in_place_index_t<t_INDEX>, \
2881 t_TYPE& value) const \
2882 { \
2883 /* When invoking this visitor in C++03, `t_INDEX` may not be */ \
2884 /* the index of the active alternative, but it will be an */ \
2885 /* index of an alternative of same type. However, because */ \
2886 /* `t_TYPE` is deduced, it may have incorrect */ \
2887 /* cv-qualifications. `t_ALT_TYPE` will give the correct */ \
2888 /* cv-qualification. */ \
2889 typedef \
2890 typename bsl::variant_alternative<t_INDEX, t_VARIANT>::type \
2891 Alt_Type; \
2892 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil; \
2893 return (ImpUtil::unsafeGet<Alt_Type>(*d_variant_p) OP value); \
2894 } \
2895 }; \
2896 \
2897 template <class t_VARIANT> \
2898 bool Variant_ImpUtil::NAME(const t_VARIANT& lhs, const t_VARIANT& rhs) \
2899 { \
2900 BSLS_ASSERT(lhs.index() == rhs.index() && \
2901 !lhs.valueless_by_exception()); \
2902 \
2903 Variant_##NAME##Visitor<t_VARIANT> NAME##Visitor( \
2904 BSLS_UTIL_ADDRESSOF(lhs)); \
2905 return BSLSTL_VARIANT_VISITID(bool, NAME##Visitor, rhs); \
2906 }
2907#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2908 // This macro is used to define the 'Variant_ImpUtil::*Impl' methods.
2909
2916
2917 // =========================
2918 // class Variant_SwapVisitor
2919 // =========================
2920
2921/// This component-private class is a visitor that is used to implement
2922/// `bsl::variant::swap`.
2923///
2924/// See @ref bslstl_variant
2925template <class t_VARIANT>
2927
2928 private:
2929 // DATA
2930 t_VARIANT *d_variant_p;
2931
2932 public:
2933 // CREATORS
2934
2935 /// Create a `Variant_SwapVisitor` object that, when invoked, will swap
2936 /// the visited alternative with the active alternative of the specified
2937 /// `variant`.
2938 explicit Variant_SwapVisitor(t_VARIANT *variant)
2939 : d_variant_p(variant)
2940 {
2941 BSLS_ASSERT_SAFE(d_variant_p);
2942 }
2943
2944 // ACCESSORS
2945
2946 /// Swap the alternative having index (template parameter) `t_INDEX` in
2947 /// `*d_variant_p` with the specified `value` (i.e. the alternative that is being visited).
2948 ///
2949 /// \pre The behavior is undefined unless `t_INDEX` is the
2950 /// index of the active alternative of `*d_variant_p` (or, in C++03, the
2951 /// index of an alternative that has the same type as the active
2952 /// alternative).
2953 template <size_t t_INDEX, class t_TYPE>
2955 {
2956#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
2957 BloombergLP::bslalg::SwapUtil::swap(
2959 BSLS_UTIL_ADDRESSOF(bsl::get<t_INDEX>(*d_variant_p)));
2960#else
2961 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
2962 // When invoking this visitor in C++03, 't_INDEX' may not be the
2963 // index of the active alternative, but it will be an index of an
2964 // alternative of same type. Swap can not be invoked on a constant
2965 // variant, so the cv qualifications will match.
2966 BloombergLP::bslalg::SwapUtil::swap(
2968 BSLS_UTIL_ADDRESSOF((ImpUtil::unsafeGet<t_TYPE>(*d_variant_p))));
2969#endif // BSL_VARIANT_FULL_IMPLEMENTATION
2970 }
2971};
2972
2973 // =========================
2974 // class Variant_HashVisitor
2975 // =========================
2976
2977/// This component-private class is a visitor that is used to implement
2978/// `hashAppend` for `bsl::variant`.
2979///
2980/// See @ref bslstl_variant
2981template <class t_HASHALG>
2983
2984 private:
2985 // DATA
2986 t_HASHALG& d_hashAlg;
2987
2988 public:
2989 // CREATORS
2990
2991 /// Create a `Variant_HashVisitor` object that, when invoked, appends to
2992 /// the specified `hashAlg`.
2993 explicit Variant_HashVisitor(t_HASHALG& hashAlg)
2994 : d_hashAlg(hashAlg)
2995 {
2996 }
2997
2998 // ACCESSORS
2999
3000 /// Append the specified `value` (i.e., the alternative that is being
3001 /// visited) to `d_hashAlg`.
3002 template <class t_TYPE>
3003 void operator()(t_TYPE& value) const
3004 {
3005 using BloombergLP::bslh::hashAppend;
3006 hashAppend(d_hashAlg, value);
3007 }
3008};
3009
3010/// This component-private struct keeps track of the allocator for a
3011/// `bsl::variant` object. The primary template is used when the `variant`
3012/// is not allocator-aware (because it has no allocator-aware alternatives).
3013///
3014/// See @ref bslstl_variant
3015template <bool t_AA>
3017
3018 // ACCESSORS
3019
3020 /// Return a null pointer.
3021 /// \note Note that this method has the same return
3022 /// type as the allocator-aware version so that the remainder of the
3023 /// implementation of `bsl::variant` is abstracted with respect to
3024 /// whether or not the specialization is allocator-aware; this is why
3025 /// both methods return `bslma::Allocator*` instead of
3026 /// `bsl::allocator<char>`. The returned pointer will be ignored (and
3027 /// not dereferenced) when passed to
3028 /// `bslma::ConstructionUtil::construct`.
3029 BloombergLP::bslma::Allocator *mechanism() const
3030 {
3031 return NULL;
3032 }
3033};
3034
3035/// This specialization is used when the `variant` is allocator-aware.
3036template <>
3038
3039 // TYPES
3040 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
3042
3043 // PUBLIC DATA
3045
3046 // CREATORS
3047
3048 /// Create a `Variant_AllocatorBase` object that holds the currently
3049 /// installed default allocator.
3051
3052 /// Create a `Variant_AllocatorBase` object that holds a copy of the
3053 /// allocator held by the specified `original`.
3055 : d_allocator(original.d_allocator)
3056 {
3057 }
3058
3059 /// Create a `Variant_AllocatorBase` object that holds a copy of the
3060 /// specified `allocator`.
3062 : d_allocator(allocator)
3063 {
3064 }
3065
3066 // ACCESSORS
3067
3068 /// Return the mechanism of the stored allocator.
3069 BloombergLP::bslma::Allocator *mechanism() const
3070 {
3071 return d_allocator.mechanism();
3072 }
3073};
3074
3075 // ===================
3076 // struct variant_base
3077 // ===================
3078
3079#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3080/// This component-private struct defines the data representation of
3081/// `bsl::variant` and contains the implementations of its special member
3082/// functions (which must be defaulted in `bsl::variant` itself). This
3083/// class also contains implementations of additional constructors and
3084/// methods needed for the correct functionality of the `variant` class
3085/// hierarchy.
3086template <class t_HEAD, class... t_TAIL>
3088: public BloombergLP::bslstl::Variant_AllocatorBase<
3089 BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD,
3090 t_TAIL...>::value> {
3091
3092 // TYPES
3093 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
3094 typedef BloombergLP::bslstl::Variant_AllocatorBase<
3095 BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD,
3096 t_TAIL...>::value>
3098 typedef BloombergLP::bslstl::Variant_Union<t_HEAD, t_TAIL...>
3100 typedef bsl::variant<t_HEAD, t_TAIL...> Variant;
3101
3102 /// This trivial tag type is used as a dummy when `Variant_Base` wraps a
3103 /// non-allocator-aware type.
3104 ///
3105 /// See @ref bslstl_variant
3106 struct NoAlloc {
3107 };
3108
3109 /// Type alias to the allocator type used by `variant`.
3110 typedef typename bsl::conditional<
3111 BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD,
3112 t_TAIL...>::value,
3115
3116 // PUBLIC DATA
3117
3118 /// Index of the currently active alternative in this variant object, or
3119 /// `bsl::variant_npos` if the variant is valueless by exception.
3120 size_t d_type;
3121
3122 /// Union holding the alternative object.
3124
3125 // TRAITS
3128 BloombergLP::bslma::UsesBslmaAllocator,
3129 (BloombergLP::bslstl::
3130 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value));
3133 BloombergLP::bslmf::UsesAllocatorArgT,
3134 (BloombergLP::bslstl::
3135 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value));
3138 BloombergLP::bslmf::IsBitwiseMoveable,
3139 (BloombergLP::bslstl::Variant_IsBitwiseMoveableAll<t_HEAD,
3140 t_TAIL...>::value));
3141
3142 // CREATORS
3143#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
3144 /// Create a `Variant_Base` object holding the 0th alternative, which is
3145 /// value-initialized. If this `Variant_Base` is allocator-aware, the
3146 /// currently installed default allocator is used to supply memory.
3147 Variant_Base();
3148
3149 /// Create a `Variant_Base` object holding the same alternative (if any)
3150 /// as the specified `original` object. If this `Variant_Base` is
3151 /// allocator-aware, the currently installed default allocator is used
3152 /// to supply memory. If the `original` object is not valueless by
3153 /// exception', the contained value is copy-constructed from the
3154 /// contained value of `original`. All alternatives shall be copy
3155 /// constructible.
3156 Variant_Base(const Variant_Base& original);
3157
3158 /// Create a `Variant_Base` object holding the same alternative (if any)
3159 /// held by the specified `original`. If this `Variant_Base` is
3160 /// allocator-aware, the allocator of `original` is used to supply
3161 /// memory. If the `original` object is not valueless by exception, the
3162 /// contained value is move-constructed from the contained value of
3163 /// `original`. All alternatives shall be move constructible.
3164 Variant_Base(Variant_Base&& original);
3165
3166#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3167 /// Create a `Variant_Base` object whose index is the specified `index`
3168 /// without constructing an alternative object. If this `Variant_Base`
3169 /// is allocator-aware, the default allocator is used to supply memory.
3171#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3172
3173 /// Create a `Variant_Base` object holding the alternative with index
3174 /// (template parameter) `t_INDEX`, direct-initialized from the
3175 /// specified `args`. If this `Variant_Base` is allocator-aware, the
3176 /// currently installed default allocator is used to supply memory.
3177 template <size_t t_INDEX, class... t_ARGS>
3178 explicit Variant_Base(bsl::in_place_index_t<t_INDEX>, t_ARGS&&... args);
3179
3180 // allocator-extended constructors
3181
3182 /// Create a `Variant_Base` object holding the 0th alternative, which is
3183 /// value-initialized. If this `Variant_Base` is allocator-aware, the
3184 /// specified `allocator` is used to supply memory.
3186
3187 /// Create a `Variant_Base` object holding the same alternative (if any)
3188 /// held by the specified `original` object. If this `Variant_Base` is
3189 /// allocator-aware, the specified `allocator` is used to supply memory.
3190 /// If the `original` object is not valueless by exception, the
3191 /// contained value is copy/move constructed from the contained value of
3192 /// `original`. All alternatives shall be copy/move constructible.
3194 allocator_type allocator,
3195 const Variant& original);
3197 allocator_type allocator,
3198 Variant&& original);
3199
3200#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3201 /// Create a `Variant_Base` object whose index is the specified `index`
3202 /// without constructing an alternative object. If this `Variant_Base`
3203 /// is allocator-aware, the specified `allocator` is used to supply
3204 /// memory.
3206 allocator_type allocator,
3208 size_t index);
3209#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3210
3211 /// Create a `Variant_Base` object holding the alternative with index
3212 /// (template parameter) `t_INDEX`, direct-initialized from the
3213 /// specified `args`. If this `Variant_Base` is allocator-aware, the
3214 /// specified `allocator` is used to supply memory.
3215 template <size_t t_INDEX, class... t_ARGS>
3217 allocator_type allocator,
3219 t_ARGS&&... args);
3220
3221#else // BSL_VARIANT_FULL_IMPLEMENTATION
3222
3223 /// Create a `Variant_Base` object holding the 0th alternative, which is
3224 /// value-initialized. If this `Variant_Base` is allocator-aware, the
3225 /// currently installed default constructor is used to supply memory.
3226 Variant_Base();
3227
3228 /// Create a `Variant_Base` object holding the same alternative (if any) as
3229 /// the specified `original` object. If this `Variant_Base` is
3230 /// allocator-aware, the currently installed default allocator is used to
3231 /// supply memory. If the `original` object is not valueless by
3232 /// exception, the contained value is copy-constructed from the contained
3233 /// value of `original`. All alternatives shall be copy constructible.
3234 Variant_Base(const Variant& original);
3235
3236 /// Create a `Variant_Base` object holding the same alternative (if any)
3237 /// held by the specified `original`. If this `Variant_Base` is
3238 /// allocator-aware, the allocator of `original` is used to supply memory.
3239 /// If the `original` object is not valueless by exception, the contained
3240 /// value is move-constructed from the contained value of `original`. All
3241 /// alternatives shall be move constructible.
3242 Variant_Base(BloombergLP::bslmf::MovableRef<Variant> original);
3243
3244 /// Create a `Variant_Base` object holding the alternative with index
3245 /// (template parameter) `t_INDEX`, which is value-initialized. If this
3246 /// `Variant_Base` is allocator-aware, the currently installed default
3247 /// constructor is used to supply memory.
3248 template <size_t t_INDEX>
3250
3251 /// Create a `Variant_Base` object holding the alternative with index
3252 /// (template parameter) `t_INDEX`, which is direct-initialized from the
3253 /// specified `arg`. If this `Variant_Base` is allocator-aware, the
3254 /// currently installed default constructor is used to supply memory.
3255 template <size_t t_INDEX, class t_ARG_01>
3257 const t_ARG_01& arg_01);
3258
3259 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
3261 const t_ARG_01& arg_01,
3262 const t_ARG_02& arg_02);
3263
3264 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
3266 const t_ARG_01& arg_01,
3267 const t_ARG_02& arg_02,
3268 const t_ARG_03& arg_03);
3269
3270 template <size_t t_INDEX,
3271 class t_ARG_01,
3272 class t_ARG_02,
3273 class t_ARG_03,
3274 class t_ARG_04>
3276 const t_ARG_01& arg_01,
3277 const t_ARG_02& arg_02,
3278 const t_ARG_03& arg_03,
3279 const t_ARG_04& arg_04);
3280
3281 template <size_t t_INDEX,
3282 class t_ARG_01,
3283 class t_ARG_02,
3284 class t_ARG_03,
3285 class t_ARG_04,
3286 class t_ARG_05>
3288 const t_ARG_01& arg_01,
3289 const t_ARG_02& arg_02,
3290 const t_ARG_03& arg_03,
3291 const t_ARG_04& arg_04,
3292 const t_ARG_05& arg_05);
3293
3294 template <size_t t_INDEX,
3295 class t_ARG_01,
3296 class t_ARG_02,
3297 class t_ARG_03,
3298 class t_ARG_04,
3299 class t_ARG_05,
3300 class t_ARG_06>
3302 const t_ARG_01& arg_01,
3303 const t_ARG_02& arg_02,
3304 const t_ARG_03& arg_03,
3305 const t_ARG_04& arg_04,
3306 const t_ARG_05& arg_05,
3307 const t_ARG_06& arg_06);
3308
3309 template <size_t t_INDEX,
3310 class t_ARG_01,
3311 class t_ARG_02,
3312 class t_ARG_03,
3313 class t_ARG_04,
3314 class t_ARG_05,
3315 class t_ARG_06,
3316 class t_ARG_07>
3318 const t_ARG_01& arg_01,
3319 const t_ARG_02& arg_02,
3320 const t_ARG_03& arg_03,
3321 const t_ARG_04& arg_04,
3322 const t_ARG_05& arg_05,
3323 const t_ARG_06& arg_06,
3324 const t_ARG_07& arg_07);
3325
3326 template <size_t t_INDEX,
3327 class t_ARG_01,
3328 class t_ARG_02,
3329 class t_ARG_03,
3330 class t_ARG_04,
3331 class t_ARG_05,
3332 class t_ARG_06,
3333 class t_ARG_07,
3334 class t_ARG_08>
3336 const t_ARG_01& arg_01,
3337 const t_ARG_02& arg_02,
3338 const t_ARG_03& arg_03,
3339 const t_ARG_04& arg_04,
3340 const t_ARG_05& arg_05,
3341 const t_ARG_06& arg_06,
3342 const t_ARG_07& arg_07,
3343 const t_ARG_08& arg_08);
3344
3345 template <size_t t_INDEX,
3346 class t_ARG_01,
3347 class t_ARG_02,
3348 class t_ARG_03,
3349 class t_ARG_04,
3350 class t_ARG_05,
3351 class t_ARG_06,
3352 class t_ARG_07,
3353 class t_ARG_08,
3354 class t_ARG_09>
3356 const t_ARG_01& arg_01,
3357 const t_ARG_02& arg_02,
3358 const t_ARG_03& arg_03,
3359 const t_ARG_04& arg_04,
3360 const t_ARG_05& arg_05,
3361 const t_ARG_06& arg_06,
3362 const t_ARG_07& arg_07,
3363 const t_ARG_08& arg_08,
3364 const t_ARG_09& arg_09);
3365
3366 template <size_t t_INDEX,
3367 class t_ARG_01,
3368 class t_ARG_02,
3369 class t_ARG_03,
3370 class t_ARG_04,
3371 class t_ARG_05,
3372 class t_ARG_06,
3373 class t_ARG_07,
3374 class t_ARG_08,
3375 class t_ARG_09,
3376 class t_ARG_10>
3378 const t_ARG_01& arg_01,
3379 const t_ARG_02& arg_02,
3380 const t_ARG_03& arg_03,
3381 const t_ARG_04& arg_04,
3382 const t_ARG_05& arg_05,
3383 const t_ARG_06& arg_06,
3384 const t_ARG_07& arg_07,
3385 const t_ARG_08& arg_08,
3386 const t_ARG_09& arg_09,
3387 const t_ARG_10& arg_10);
3388
3389 // allocator-extended constructors
3390
3391 /// Create a `Variant_Base` object holding the 0th alternative, which is
3392 /// value-initialized. If this `Variant_Base` is allocator-aware, the
3393 /// specified `allocator` is used to supply memory.
3395
3396 /// Create a `Variant_Base` object holding the same alternative (if any)
3397 /// held by the specified `original` object. If this `Variant_Base` is
3398 /// allocator-aware, the specified `allocator` is used to supply memory.
3399 /// If the `original` object is not valueless by exception, the
3400 /// contained value is copy/move constructed from the contained value of
3401 /// `original`. All alternatives shall be copy/move constructible.
3403 allocator_type allocator,
3404 const Variant& original);
3406 allocator_type allocator,
3407 BloombergLP::bslmf::MovableRef<Variant> original);
3408
3409 /// Create a `Variant_Base` object holding the alternative with index
3410 /// (template parameter) `t_INDEX`, which is value-initialized. If this
3411 /// `Variant_Base` is allocator-aware, the specified `allocator` is used to
3412 /// supply memory.
3413 template <size_t t_INDEX>
3415 allocator_type allocator,
3417
3418 /// Create a `Variant_Base` object holding the alternative with index
3419 /// (template parameter) `t_INDEX`, direct-initialized from `arg`. If this
3420 /// `Variant_Base` is allocator-aware, the specified `allocator` is used to
3421 /// supply memory.
3422 template <size_t t_INDEX, class t_ARG_01>
3424 allocator_type allocator,
3426 const t_ARG_01& arg_01);
3427
3428 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
3430 allocator_type allocator,
3432 const t_ARG_01& arg_01,
3433 const t_ARG_02& arg_02);
3434
3435 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
3437 allocator_type allocator,
3439 const t_ARG_01& arg_01,
3440 const t_ARG_02& arg_02,
3441 const t_ARG_03& arg_03);
3442
3443 template <size_t t_INDEX,
3444 class t_ARG_01,
3445 class t_ARG_02,
3446 class t_ARG_03,
3447 class t_ARG_04>
3449 allocator_type allocator,
3451 const t_ARG_01& arg_01,
3452 const t_ARG_02& arg_02,
3453 const t_ARG_03& arg_03,
3454 const t_ARG_04& arg_04);
3455
3456 template <size_t t_INDEX,
3457 class t_ARG_01,
3458 class t_ARG_02,
3459 class t_ARG_03,
3460 class t_ARG_04,
3461 class t_ARG_05>
3463 allocator_type allocator,
3465 const t_ARG_01& arg_01,
3466 const t_ARG_02& arg_02,
3467 const t_ARG_03& arg_03,
3468 const t_ARG_04& arg_04,
3469 const t_ARG_05& arg_05);
3470
3471 template <size_t t_INDEX,
3472 class t_ARG_01,
3473 class t_ARG_02,
3474 class t_ARG_03,
3475 class t_ARG_04,
3476 class t_ARG_05,
3477 class t_ARG_06>
3479 allocator_type allocator,
3481 const t_ARG_01& arg_01,
3482 const t_ARG_02& arg_02,
3483 const t_ARG_03& arg_03,
3484 const t_ARG_04& arg_04,
3485 const t_ARG_05& arg_05,
3486 const t_ARG_06& arg_06);
3487
3488 template <size_t t_INDEX,
3489 class t_ARG_01,
3490 class t_ARG_02,
3491 class t_ARG_03,
3492 class t_ARG_04,
3493 class t_ARG_05,
3494 class t_ARG_06,
3495 class t_ARG_07>
3497 allocator_type allocator,
3499 const t_ARG_01& arg_01,
3500 const t_ARG_02& arg_02,
3501 const t_ARG_03& arg_03,
3502 const t_ARG_04& arg_04,
3503 const t_ARG_05& arg_05,
3504 const t_ARG_06& arg_06,
3505 const t_ARG_07& arg_07);
3506
3507 template <size_t t_INDEX,
3508 class t_ARG_01,
3509 class t_ARG_02,
3510 class t_ARG_03,
3511 class t_ARG_04,
3512 class t_ARG_05,
3513 class t_ARG_06,
3514 class t_ARG_07,
3515 class t_ARG_08>
3517 allocator_type allocator,
3519 const t_ARG_01& arg_01,
3520 const t_ARG_02& arg_02,
3521 const t_ARG_03& arg_03,
3522 const t_ARG_04& arg_04,
3523 const t_ARG_05& arg_05,
3524 const t_ARG_06& arg_06,
3525 const t_ARG_07& arg_07,
3526 const t_ARG_08& arg_08);
3527
3528 template <size_t t_INDEX,
3529 class t_ARG_01,
3530 class t_ARG_02,
3531 class t_ARG_03,
3532 class t_ARG_04,
3533 class t_ARG_05,
3534 class t_ARG_06,
3535 class t_ARG_07,
3536 class t_ARG_08,
3537 class t_ARG_09>
3539 allocator_type allocator,
3541 const t_ARG_01& arg_01,
3542 const t_ARG_02& arg_02,
3543 const t_ARG_03& arg_03,
3544 const t_ARG_04& arg_04,
3545 const t_ARG_05& arg_05,
3546 const t_ARG_06& arg_06,
3547 const t_ARG_07& arg_07,
3548 const t_ARG_08& arg_08,
3549 const t_ARG_09& arg_09);
3550
3551 template <size_t t_INDEX,
3552 class t_ARG_01,
3553 class t_ARG_02,
3554 class t_ARG_03,
3555 class t_ARG_04,
3556 class t_ARG_05,
3557 class t_ARG_06,
3558 class t_ARG_07,
3559 class t_ARG_08,
3560 class t_ARG_09,
3561 class t_ARG_10>
3563 allocator_type allocator,
3565 const t_ARG_01& arg_01,
3566 const t_ARG_02& arg_02,
3567 const t_ARG_03& arg_03,
3568 const t_ARG_04& arg_04,
3569 const t_ARG_05& arg_05,
3570 const t_ARG_06& arg_06,
3571 const t_ARG_07& arg_07,
3572 const t_ARG_08& arg_08,
3573 const t_ARG_09& arg_09,
3574 const t_ARG_10& arg_10);
3575
3576#endif // BSL_VARIANT_FULL_IMPLEMENTATION
3577
3578 /// Destroy this object. The contained value, if any, is destroyed.
3579 ~Variant_Base();
3580
3581 // MANIPULATORS
3582#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
3583 /// Create the alternative with index (template parameter) `t_INDEX` in
3584 /// place, direct-initialized from the specified `args`. If this
3585 /// `Variant_Base` object already holds a value, that contained value is
3586 /// destroyed before the new object is created. If the alternative is
3587 /// allocator-aware, it uses the allocator specified upon the
3588 /// construction of this `Variant_Base` object to supply memory; passing
3589 /// an allocator argument to this method results in two allocators being
3590 /// passed to the alternative constructor, resulting in a likely compilation error.
3591 ///
3592 /// \note Note that if the constructor of the alternative
3593 /// exits via an exception, this object is left in the valueless by
3594 /// exception state.
3595 template <size_t t_INDEX, class... t_ARGS>
3596 void baseEmplace(t_ARGS&&...);
3597#else // BSL_VARIANT_FULL_IMPLEMENTATION
3598 /// Create the alternative with index (template parameter) `t_INDEX` in
3599 /// place, which is value-initialized. If this `Variant_Base` object
3600 /// already holds a value, that contained value is destroyed before the new
3601 /// object is created. If the alternative is allocator-aware, it uses the
3602 /// allocator specified upon the construction of this `Variant_Base` object
3603 /// to supply memory; passing an allocator argument to this method results
3604 /// in two allocators being passed to the alternative constructor, resulting in a likely compilation error.
3605 ///
3606 /// \note Note that if the constructor
3607 /// of the alternative exits via an exception, this object is left in the
3608 /// valueless by exception state.
3609 template <size_t t_INDEX>
3610 void baseEmplace();
3611
3612 /// Create the alternative with index (template parameter) `t_INDEX` in
3613 /// place, direct-initialized from the specified `arg`. If this
3614 /// `Variant_Base` object already holds a value, that contained value is
3615 /// destroyed before the new object is created. If the alternative is
3616 /// allocator-aware, it uses the allocator specified upon the construction
3617 /// of this `Variant_Base` object to supply memory; passing an allocator
3618 /// argument to this method results in two allocators being passed to the
3619 /// alternative constructor, resulting in a likely compilation error.
3620 ///
3621 /// \note Note that if the constructor of the alternative exits via an exception, this
3622 /// object is left in the valueless by exception state.
3623 template <size_t t_INDEX, class t_ARG_01>
3624 void baseEmplace(const t_ARG_01& arg_01);
3625
3626 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
3627 void baseEmplace(const t_ARG_01& arg_01, const t_ARG_02& arg_02);
3628
3629 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
3630 void baseEmplace(const t_ARG_01& arg_01,
3631 const t_ARG_02& arg_02,
3632 const t_ARG_03& arg_03);
3633
3634 template <size_t t_INDEX,
3635 class t_ARG_01,
3636 class t_ARG_02,
3637 class t_ARG_03,
3638 class t_ARG_04>
3639 void baseEmplace(const t_ARG_01& arg_01,
3640 const t_ARG_02& arg_02,
3641 const t_ARG_03& arg_03,
3642 const t_ARG_04& arg_04);
3643
3644 template <size_t t_INDEX,
3645 class t_ARG_01,
3646 class t_ARG_02,
3647 class t_ARG_03,
3648 class t_ARG_04,
3649 class t_ARG_05>
3650 void baseEmplace(const t_ARG_01& arg_01,
3651 const t_ARG_02& arg_02,
3652 const t_ARG_03& arg_03,
3653 const t_ARG_04& arg_04,
3654 const t_ARG_05& arg_05);
3655
3656 template <size_t t_INDEX,
3657 class t_ARG_01,
3658 class t_ARG_02,
3659 class t_ARG_03,
3660 class t_ARG_04,
3661 class t_ARG_05,
3662 class t_ARG_06>
3663 void baseEmplace(const t_ARG_01& arg_01,
3664 const t_ARG_02& arg_02,
3665 const t_ARG_03& arg_03,
3666 const t_ARG_04& arg_04,
3667 const t_ARG_05& arg_05,
3668 const t_ARG_06& arg_06);
3669
3670 template <size_t t_INDEX,
3671 class t_ARG_01,
3672 class t_ARG_02,
3673 class t_ARG_03,
3674 class t_ARG_04,
3675 class t_ARG_05,
3676 class t_ARG_06,
3677 class t_ARG_07>
3678 void baseEmplace(const t_ARG_01& arg_01,
3679 const t_ARG_02& arg_02,
3680 const t_ARG_03& arg_03,
3681 const t_ARG_04& arg_04,
3682 const t_ARG_05& arg_05,
3683 const t_ARG_06& arg_06,
3684 const t_ARG_07& arg_07);
3685
3686 template <size_t t_INDEX,
3687 class t_ARG_01,
3688 class t_ARG_02,
3689 class t_ARG_03,
3690 class t_ARG_04,
3691 class t_ARG_05,
3692 class t_ARG_06,
3693 class t_ARG_07,
3694 class t_ARG_08>
3695 void baseEmplace(const t_ARG_01& arg_01,
3696 const t_ARG_02& arg_02,
3697 const t_ARG_03& arg_03,
3698 const t_ARG_04& arg_04,
3699 const t_ARG_05& arg_05,
3700 const t_ARG_06& arg_06,
3701 const t_ARG_07& arg_07,
3702 const t_ARG_08& arg_08);
3703
3704 template <size_t t_INDEX,
3705 class t_ARG_01,
3706 class t_ARG_02,
3707 class t_ARG_03,
3708 class t_ARG_04,
3709 class t_ARG_05,
3710 class t_ARG_06,
3711 class t_ARG_07,
3712 class t_ARG_08,
3713 class t_ARG_09>
3714 void baseEmplace(const t_ARG_01& arg_01,
3715 const t_ARG_02& arg_02,
3716 const t_ARG_03& arg_03,
3717 const t_ARG_04& arg_04,
3718 const t_ARG_05& arg_05,
3719 const t_ARG_06& arg_06,
3720 const t_ARG_07& arg_07,
3721 const t_ARG_08& arg_08,
3722 const t_ARG_09& arg_09);
3723
3724 template <size_t t_INDEX,
3725 class t_ARG_01,
3726 class t_ARG_02,
3727 class t_ARG_03,
3728 class t_ARG_04,
3729 class t_ARG_05,
3730 class t_ARG_06,
3731 class t_ARG_07,
3732 class t_ARG_08,
3733 class t_ARG_09,
3734 class t_ARG_10>
3735 void baseEmplace(const t_ARG_01& arg_01,
3736 const t_ARG_02& arg_02,
3737 const t_ARG_03& arg_03,
3738 const t_ARG_04& arg_04,
3739 const t_ARG_05& arg_05,
3740 const t_ARG_06& arg_06,
3741 const t_ARG_07& arg_07,
3742 const t_ARG_08& arg_08,
3743 const t_ARG_09& arg_09,
3744 const t_ARG_10& arg_10);
3745#endif // BSL_VARIANT_FULL_IMPLEMENTATION
3746
3747 /// If the specified `rhs` holds the same alternative type as this
3748 /// object, copy assign the contained value of `rhs` to the contained
3749 /// value of this object. Otherwise, destroy the contained value of
3750 /// this object (if any) and, if `rhs` holds a value, copy-construct the
3751 /// corresponding alternative of this object from the contained value of
3752 /// `rhs`. The allocators of this object and `rhs` both remain
3753 /// unchanged. If the construction of a new alternative object exits
3754 /// via an exception, this `Variant_Base` object is left in a valueless
3755 /// by exception state. This behavior differs from the standard, for
3756 /// reasons that are explained in the documentation for
3757 /// `variant::operator=`. All alternatives shall be copy constructible
3758 /// and copy assignable.
3759 Variant_Base& operator=(const Variant_Base& rhs);
3760
3761 /// If the specified `rhs` holds the same alternative type as this
3762 /// object, move assign the contained value of `rhs` to the contained
3763 /// value of this object. Otherwise, destroy the currently held
3764 /// alternative object (if any) and, if `rhs` holds a value,
3765 /// move-construct the corresponding alternative of this object from the
3766 /// contained value of `rhs`. The allocators of this object and `rhs`
3767 /// both remain unchanged. If the construction of a new alternative
3768 /// object exits via an exception, this `Variant_Base` object is left in
3769 /// a valueless by exception state. All alternatives shall be move
3770 /// constructible and move assignable.
3771 Variant_Base& operator=(BloombergLP::bslmf::MovableRef<Variant_Base> rhs);
3772
3773 /// Destroy the contained value, if any.
3774 void reset() BSLS_KEYWORD_NOEXCEPT;
3775};
3776#endif
3777
3778} // close package namespace
3779
3780
3781namespace bsl {
3782 // =============
3783 // class variant
3784 // =============
3785
3786#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3787template <class t_HEAD, class... t_TAIL>
3789: private BloombergLP::bslstl::Variant_Base<t_HEAD, t_TAIL...>
3790#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
3791,
3792 private BloombergLP::bslstl::Variant_SMFBase<
3793 BloombergLP::bslstl::Variant_IsCopyConstructibleAll<t_HEAD,
3794 t_TAIL...>::value,
3795 BloombergLP::bslstl::Variant_IsMoveConstructibleAll<t_HEAD,
3796 t_TAIL...>::value,
3797 BloombergLP::bslstl::Variant_IsCopyConstructibleAll<t_HEAD,
3798 t_TAIL...>::value &&
3799 BloombergLP::bslstl::Variant_IsCopyAssignableAll<t_HEAD,
3800 t_TAIL...>::value,
3801 BloombergLP::bslstl::Variant_IsMoveConstructibleAll<t_HEAD,
3802 t_TAIL...>::value &&
3803 BloombergLP::bslstl::Variant_IsMoveAssignableAll<t_HEAD,
3804 t_TAIL...>::value>
3805#endif // BSL_VARIANT_FULL_IMPLEMENTATION
3806{
3807 private:
3808 // PRIVATE TYPES
3809 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
3810 typedef BloombergLP::bslstl::Variant_Base<t_HEAD, t_TAIL...> Variant_Base;
3811 typedef BloombergLP::bslstl::Variant_Union<t_HEAD, t_TAIL...>
3812 Variant_Union;
3813
3814 // FRIENDS
3815 friend struct BloombergLP::bslstl::Variant_ImpUtil;
3816 // This struct contains functions that require access to the
3817 // 'Variant_Union' subobject. Note that because 'variant' is not
3818 // standard-layout in the allocator-aware case, we cannot easily cast
3819 // between the variant object and its 'Variant_Union' subobject.
3820
3821 friend struct BloombergLP::bslstl::Variant_Base<t_HEAD, t_TAIL...>;
3822 // 'Variant_Base' must be able to downcast from 'Variant_Base' to
3823 // 'variant' (which is privately derived from 'Variant_Base').
3824
3825 public:
3826 // TRAITS
3828 variant,
3829 BloombergLP::bslma::UsesBslmaAllocator,
3830 (BloombergLP::bslstl::
3831 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value));
3833 variant,
3834 BloombergLP::bslmf::UsesAllocatorArgT,
3835 (BloombergLP::bslstl::
3836 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value));
3838 variant,
3839 BloombergLP::bslmf::IsBitwiseMoveable,
3840 (BloombergLP::bslstl::Variant_IsBitwiseMoveableAll<t_HEAD,
3841 t_TAIL...>::value));
3842
3843 // TYPES
3844
3845 /// Type alias to the allocator type used by `variant`.
3846 typedef typename Variant_Base::allocator_type allocator_type;
3847
3848 // CREATORS
3849
3850 // 20.7.3.1, constructors
3851#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
3852 /// Create a `variant` object holding the 0th alternative, which is
3853 /// value-initialized. If this `variant` is allocator-aware, the
3854 /// currently installed default allocator is used to supply memory.
3855 /// This constructor participates in overload resolution only if the 0th
3856 /// alternative is default constructible. For simplicity of
3857 /// implementation, this method differs from the standard in the
3858 /// following ways:
3859 /// * `constexpr` is not implemented
3860 /// * `noexcept` specification is not implemented
3861 template <class t_FIRST_ALT = t_HEAD,
3862 class = typename bsl::enable_if_t<
3863 std::is_default_constructible<t_FIRST_ALT>::value> >
3864 variant()
3865 : Variant_Base()
3866 {
3867 // This constructor template must be defined inline inside the class
3868 // definition, as Microsoft Visual C++ does not recognize the
3869 // definition as matching this signature when placed out-of-line.
3870 }
3871
3872 /// Create a `variant` object holding the same alternative (if any) as
3873 /// the specified `original` object. If this `variant` is
3874 /// allocator-aware, the currently installed default allocator is used
3875 /// to supply memory. If the `original` object is not valueless by
3876 /// exception', the contained value is copy-constructed from the
3877 /// contained value of `original`. This constructor is deleted unless
3878 /// all alternatives are copy constructible. For simplicity of
3879 /// implementation, this method differs from the standard in the
3880 /// following ways:
3881 /// * conditional triviality is not implemented
3882 /// * `constexpr` is not implemented
3883 /// * `noexcept` specification is not implemented
3884 variant(const variant& original) = default;
3885
3886 /// Create a `variant` object holding the same alternative (if any) held
3887 /// by the specified `original`. If this `variant` is allocator-aware,
3888 /// the allocator of `original` is used to supply memory. If `original`
3889 /// is not valueless by exception, the contained value is
3890 /// move-constructed from the contained value of `original`. This
3891 /// constructor participates in overload resolution only if all
3892 /// alternatives are move constructible. For simplicity of
3893 /// implementation, this method differs from the standard in the
3894 /// following ways:
3895 /// * conditional triviality is not implemented
3896 /// * `constexpr` is not implemented
3897 /// * `noexcept` specification is not implemented
3898 variant(variant&& original) = default;
3899
3900#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3901 /// Create a `variant` object holding the same alternative (if any) held
3902 /// by the specified `original`. If this `variant` is allocator-aware,
3903 /// the specified `allocator` is used to supply memory. If `original`
3904 /// is not valueless by exception, the contained value is
3905 /// copy/move-constructed from the contained value of `original`. This
3906 /// constructor participates in overload resolution only if all
3907 /// alternatives are copy/move-constructible.
3908 template <class t_STD_VARIANT>
3909 explicit variant(
3910 t_STD_VARIANT&& original,
3912 : Variant_Base(BloombergLP::bslstl::Variant_ConstructFromStdTag(),
3913 original.index())
3914 {
3915 // MSVC 19.22 and later has a bug where if this constructor is defined
3916 // out of line, it becomes non-explicit in copy-list-initialization.
3917 if (!valueless_by_exception()) {
3918 BloombergLP::bslstl::Variant_ImpUtil::
3919 ConstructFromStdVisitor<variant, decltype(original)>
3920 visitor(*this, original);
3921 BSLSTL_VARIANT_VISITID(void, visitor, *this);
3922 }
3923 }
3924#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3925
3926 /// Create a `variant` object whose contained value is
3927 /// direct-initialized from the specified `t`. The alternative selected
3928 /// is the best match among all alternatives for which the expression
3929 /// `t_ALT_TYPE x[] = {std::forward<t_TYPE>(t)};` is well formed, and
3930 /// this constructor participates in overload resolution only if there
3931 /// is a unique best matching alternative and that alternative is
3932 /// constructible from `t`. If this `variant` is allocator-aware, the
3933 /// currently installed default allocator is used to supply memory.
3934 ///
3935 /// \note Note that the cv-qualification of an alternative type does not
3936 /// affect how well the alternative type matches an argument type. For
3937 /// simplicity of implementation, this method differs from the standard
3938 /// in the following ways:
3939 /// * `constexpr` is not implemented
3940 /// * `noexcept` specification is not implemented
3941 template <class t_TYPE>
3942 variant(t_TYPE&& t,
3944
3945 /// Create a `variant` object holding a contained value of type
3946 /// (template parameter) `t_TYPE`, direct-initialized from the specified
3947 /// `args`. If this `variant` is allocator-aware, the currently
3948 /// installed default allocator is used to supply memory. This
3949 /// constructor participates in overload resolutionly if `t_TYPE`
3950 /// designates a unique alternative and is constructible from `args`.
3951 /// For simplicity of implementation, this method differs from the
3952 /// standard in the following way:
3953 /// * `constexpr` is not implemented
3954 template <class t_TYPE,
3955 class... t_ARGS,
3956 class = typename bsl::enable_if_t<
3958 std::is_constructible<t_TYPE, t_ARGS...>::value> >
3959 explicit variant(bsl::in_place_type_t<t_TYPE>, t_ARGS&&... args)
3960 : Variant_Base(
3961 bsl::in_place_index_t<BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant)>(),
3962 std::forward<t_ARGS>(args)...)
3963 {
3964 // The implementation is placed here in the class definition to work
3965 // around a Microsoft C++ compiler (MSVC 2010) bug where the definition
3966 // cannot be matched to the declaration when an 'enable_if' is used.
3967 }
3968
3969 template <class t_TYPE,
3970 class INIT_LIST_TYPE,
3971 class... t_ARGS,
3972 class = typename bsl::enable_if_t<
3974 std::is_constructible<t_TYPE,
3975 std::initializer_list<INIT_LIST_TYPE>&,
3976 t_ARGS...>::value> >
3977 explicit variant(bsl::in_place_type_t<t_TYPE>,
3978 std::initializer_list<INIT_LIST_TYPE> il,
3979 t_ARGS&&... args)
3980 // Create a 'variant' object holding a contained value of type
3981 // (template parameter) 't_TYPE', direct-initialized from the specified
3982 // 'il' and 'args'. If this 'variant' is allocator-aware, the
3983 // currently installed default allocator is used to supply memory.
3984 // This constructor participates in overload resolutionly if 't_TYPE'
3985 // designates a unique alternative and is constructible from 'il' and
3986 // 'args'. For simplicity of implementation, this method differs from
3987 // the standard in the following way:
3988 //: o 'constexpr' is not implemented
3989 : Variant_Base(
3990 bsl::in_place_index_t<BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant)>(),
3991 il,
3992 std::forward<t_ARGS>(args)...)
3993 {
3994 // The implementation is placed here in the class definition to work
3995 // around a Microsoft C++ compiler (MSVC 2010) bug where the definition
3996 // cannot be matched to the declaration when an 'enable_if' is used.
3997 }
3998
3999 /// Create a `variant` object holding the alternative with index
4000 /// (template parameter) `t_INDEX`, direct-initialized from the
4001 /// specified `args`. If this `variant` is allocator-aware, the
4002 /// currently installed default allocator is used to supply memory.
4003 /// This constructor participates in overload resolution only if
4004 /// `t_INDEX` is a valid alternative index and the designated
4005 /// alternative is constructible from `args`. For simplicity of
4006 /// implementation, this method differs from the standard in the
4007 /// following ways:
4008 /// * `constexpr` is not implemented
4009 template <size_t t_INDEX,
4010 class... t_ARGS,
4011 class = typename bsl::enable_if_t<
4012 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
4013 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
4014 t_ARGS...>::value> >
4015 explicit variant(bsl::in_place_index_t<t_INDEX>, t_ARGS&&... args)
4016 : Variant_Base(bsl::in_place_index_t<t_INDEX>(),
4017 std::forward<t_ARGS>(args)...)
4018 {
4019 // The implementation is placed here in the class definition to work
4020 // around a Microsoft C++ compiler (MSVC 2010) bug where the definition
4021 // cannot be matched to the declaration when an 'enable_if' is used.
4022 }
4023
4024 /// Create a `variant` object holding the alternative with index (template
4025 /// parameter) `t_INDEX`, direct-initialized from the specified `il` and
4026 /// `args`. If this `variant` is allocator-aware, the currently installed
4027 /// default allocator is used to supply memory. This constructor
4028 /// participates in overload resolution only if `t_INDEX` is a valid
4029 /// alternative index and the designated alternative is constructible from
4030 /// `il` and `args`. For simplicity of implementation, this method differs
4031 /// from the standard in the following way:
4032 /// * `constexpr` is not implemented
4033 template <size_t t_INDEX,
4034 class INIT_LIST_TYPE,
4035 class... t_ARGS,
4036 class = typename bsl::enable_if_t<
4037 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
4038 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
4039 std::initializer_list<INIT_LIST_TYPE>&,
4040 t_ARGS...>::value> >
4041 explicit variant(bsl::in_place_index_t<t_INDEX>,
4042 std::initializer_list<INIT_LIST_TYPE> il,
4043 t_ARGS&&... args)
4044 : Variant_Base(bsl::in_place_index_t<t_INDEX>(),
4045 il,
4046 std::forward<t_ARGS>(args)...)
4047 {
4048 // The implementation is placed here in the class definition to work
4049 // around a Microsoft C++ compiler (MSVC 2010) bug where the definition
4050 // cannot be matched to the declaration when an 'enable_if' is used.
4051 }
4052
4053 // allocator-extended constructors
4054
4055 /// Create a `variant` object holding the 0th alternative, which is
4056 /// value-initialized. If this `variant` is allocator-aware, the specified
4057 /// `allocator` is used to supply memory. This constructor participates in
4058 /// overload resolution only if the 0th alternative is default
4059 /// constructible.
4060 template <class t_FIRST = t_HEAD,
4061 class = typename bsl::enable_if_t<
4062 std::is_default_constructible<t_FIRST>::value> >
4063 variant(bsl::allocator_arg_t, allocator_type allocator)
4064 : Variant_Base(bsl::allocator_arg_t(), allocator)
4065 {
4066 // This constructor template must be defined inline inside the class
4067 // definition, as Microsoft Visual C++ does not recognize the
4068 // definition as matching this signature when placed out-of-line.
4069 }
4070
4071 /// Create a `variant` object holding the same alternative (if any) as the
4072 /// specified `original` object. If this `variant` is allocator-aware, the
4073 /// specified `allocator` is used to supply memory. If the `original`
4074 /// object is not valueless by exception`, the contained value is
4075 /// copy-constructed from the contained value of `original`. This
4076 /// constructor is deleted unless all alternatives are copy constructible.
4077 template <
4078 class t_FIRST = t_HEAD,
4079 class = typename bsl::enable_if_t<
4080 BloombergLP::bslstl::
4081 Variant_IsCopyConstructibleAll<t_FIRST, t_TAIL...>::value> >
4082 variant(bsl::allocator_arg_t,
4083 allocator_type allocator,
4084 const variant& original)
4085 : Variant_Base(bsl::allocator_arg_t(), allocator, original)
4086 {
4087 // This constructor template must be defined inline inside the class
4088 // definition, as Microsoft Visual C++ does not recognize the
4089 // definition as matching this signature when placed out-of-line.
4090 }
4091
4092 /// Create a `variant` object holding the same alternative (if any) held
4093 /// by the specified `original`. If this `variant` is allocator-aware,
4094 /// the specified `allocator` is used to supply memory. If `original`
4095 /// is not valueless by exception, the contained value is
4096 /// move-constructed from the contained value of `original`. This
4097 /// constructor participates in overload resolution only if all
4098 /// alternatives are move constructible.
4099 template <
4100 class t_FIRST = t_HEAD,
4101 class = typename bsl::enable_if_t<
4102 BloombergLP::bslstl::
4103 Variant_IsMoveConstructibleAll<t_FIRST, t_TAIL...>::value> >
4104 variant(bsl::allocator_arg_t, allocator_type allocator, variant&& original)
4105 : Variant_Base(bsl::allocator_arg_t(), allocator, std::move(original))
4106 {
4107 // This constructor template must be defined inline inside the class
4108 // definition, as Microsoft Visual C++ does not recognize the
4109 // definition as matching this signature when placed out-of-line.
4110 }
4111
4112#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
4113 /// Create a `variant` object holding the same alternative (if any) held
4114 /// by the specified `original`. If this `variant` is allocator-aware,
4115 /// the specified `allocator` is used to supply memory. If `original`
4116 /// is not valueless by exception, the contained value is
4117 /// copy/move-constructed from the contained value of `original`. This
4118 /// constructor participates in overload resolution only if all
4119 /// alternatives are copy/move-constructible.
4120 template <class t_STD_VARIANT>
4121 explicit variant(
4123 allocator_type allocator,
4124 t_STD_VARIANT&& original,
4126 : Variant_Base(bsl::allocator_arg_t(),
4127 allocator,
4128 BloombergLP::bslstl::Variant_ConstructFromStdTag(),
4129 original.index())
4130 {
4131 // MSVC 19.22 and later has a bug where if this constructor is defined
4132 // out of line, it becomes non-explicit in copy-list-initialization.
4133 if (!valueless_by_exception()) {
4134 BloombergLP::bslstl::Variant_ImpUtil::
4135 ConstructFromStdVisitor<variant, decltype(original)>
4136 visitor(*this, original);
4137 BSLSTL_VARIANT_VISITID(void, visitor, *this);
4138 }
4139 }
4140#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
4141
4142 /// Create a `variant` object whose contained value is
4143 /// direct-initialized from the specified `t`. The alternative selected
4144 /// is the best match among all alternatives for which the expression
4145 /// `t_ALT_TYPE x[] = {std::forward<t_TYPE>(t)};` is well formed, and
4146 /// this constructor participates in overload resolution only if there
4147 /// is a unique best matching alternative and that alternative is
4148 /// constructible from `t`. If this `variant` is allocator-aware, the specified `allocator` is used to supply memory.
4149 ///
4150 /// \note Note that the
4151 /// cv-qualification of an alternative type does not affect how well the
4152 /// alternative type matches an argument type.
4153 template <class t_TYPE>
4154 variant(
4156 allocator_type allocator,
4157 t_TYPE&& t,
4159
4160 /// Create a `variant` object holding a contained value of type
4161 /// (template parameter) `t_TYPE`, direct-initialized from the specified
4162 /// `args`. If this `variant` is allocator-aware, the specified
4163 /// `allocator `is used to supply memory. This constructor participates
4164 /// in overload resolutionly if `t_TYPE` designates a unique alternative
4165 /// and is constructible from `args`.
4166 template <class t_TYPE,
4167 class... t_ARGS,
4168 class = typename bsl::enable_if_t<
4170 std::is_constructible<t_TYPE, t_ARGS...>::value> >
4171 explicit variant(bsl::allocator_arg_t,
4172 allocator_type allocator,
4174 t_ARGS&&... args)
4175 : Variant_Base(
4176 bsl::allocator_arg_t{},
4177 allocator,
4178 bsl::in_place_index_t<BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant)>(),
4179 std::forward<t_ARGS>(args)...)
4180 {
4181 // This constructor template must be defined inline inside the class
4182 // definition, as Microsoft Visual C++ does not recognize the
4183 // definition as matching this signature when placed out-of-line.
4184 }
4185
4186 /// Create a `variant` object holding a contained value of type (template
4187 /// parameter) `t_TYPE`, direct-initialized from the specified `il` and
4188 /// `args`. If this `variant` is allocator-aware, the specified `allocator
4189 /// `is used to supply memory. This constructor participates in overload
4190 /// resolutionly if `t_TYPE` designates a unique alternative and is
4191 /// constructible from `il` and `args`.
4192 template <class t_TYPE,
4193 class INIT_LIST_TYPE,
4194 class... t_ARGS,
4195 class = typename bsl::enable_if_t<
4197 std::is_constructible<t_TYPE,
4198 std::initializer_list<INIT_LIST_TYPE>&,
4199 t_ARGS...>::value> >
4200 explicit variant(bsl::allocator_arg_t,
4201 allocator_type allocator,
4203 std::initializer_list<INIT_LIST_TYPE> il,
4204 t_ARGS&&... args)
4205 : Variant_Base(
4206 bsl::allocator_arg_t{},
4207 allocator,
4208 bsl::in_place_index_t<BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant)>(),
4209 il,
4210 std::forward<t_ARGS>(args)...)
4211 {
4212 // This constructor template must be defined inline inside the class
4213 // definition, as Microsoft Visual C++ does not recognize the
4214 // definition as matching this signature when placed out-of-line.
4215 }
4216
4217 /// Create a `variant` object holding the alternative with index (template
4218 /// parameter) `t_INDEX`, direct-initialized from the specified `args`. If
4219 /// this `variant` is allocator-aware, the specified `allocator` is used to
4220 /// supply memory. This constructor participates in overload resolution
4221 /// only if `t_INDEX` is a valid alternative index and the designated
4222 /// alternative is constructible from `args`.
4223 template <size_t t_INDEX,
4224 class... t_ARGS,
4225 class = typename bsl::enable_if_t<
4226 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
4227 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
4228 t_ARGS...>::value> >
4229 explicit variant(bsl::allocator_arg_t,
4230 allocator_type allocator,
4232 t_ARGS&&... args)
4233 : Variant_Base(bsl::allocator_arg_t{},
4234 allocator,
4235 bsl::in_place_index_t<t_INDEX>(),
4236 std::forward<t_ARGS>(args)...)
4237 {
4238 // This constructor template must be defined inline inside the class
4239 // definition, as Microsoft Visual C++ does not recognize the
4240 // definition as matching this signature when placed out-of-line.
4241 }
4242
4243 /// Create a `variant` object holding the alternative with index (template
4244 /// parameter) `t_INDEX`, direct-initialized from the specified `il` and
4245 /// `args`. If this `variant` is allocator-aware, the specified
4246 /// `allocator` is used to supply memory. This constructor participates in
4247 /// overload resolution only if `t_INDEX` is a valid alternative index and
4248 /// the designated alternative is constructible from `il` and `args`.
4249 template <size_t t_INDEX,
4250 class INIT_LIST_TYPE,
4251 class... t_ARGS,
4252 class = typename bsl::enable_if_t<
4253 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
4254 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
4255 std::initializer_list<INIT_LIST_TYPE>&,
4256 t_ARGS...>::value> >
4257 explicit variant(bsl::allocator_arg_t,
4258 allocator_type allocator,
4260 std::initializer_list<INIT_LIST_TYPE> il,
4261 t_ARGS&&... args)
4262 : Variant_Base(bsl::allocator_arg_t{},
4263 allocator,
4264 bsl::in_place_index_t<t_INDEX>(),
4265 il,
4266 std::forward<t_ARGS>(args)...)
4267 {
4268 // This constructor template must be defined inline inside the class
4269 // definition, as Microsoft Visual C++ does not recognize the
4270 // definition as matching this signature when placed out-of-line.
4271 }
4272
4273#else // BSL_VARIANT_FULL_IMPLEMENTATION
4274
4275 /// Create a `variant` object holding the 0th alternative, which is
4276 /// value-initialized. If this `variant` is allocator-aware, the
4277 /// currently installed default allocator is used to supply memory.
4279
4280 // Create a `variant` object holding the same alternative (if any) as the
4281 // specified `original` object. If this `variant` is allocator-aware, the
4282 // currently installed default allocator is used to supply memory. If the
4283 // `original` object is not valueless by exception, the contained value is
4284 // copy-constructed from the contained value of `original`. All
4285 // alternatives shall be copy constructible.
4286 variant(const variant& original);
4287
4288 /// Create a `variant` object holding the same alternative (if any) held by
4289 /// the specified `original`. If this `variant` is allocator-aware, the
4290 /// allocator of `original` is used to supply memory. If `original` is not
4291 /// valueless by exception, the contained value is move-constructed from
4292 /// the contained value of `original`. All alternatives shall be move
4293 /// constructible.
4294 variant(BloombergLP::bslmf::MovableRef<variant> original);
4295
4296 /// Create a `variant` object whose contained value is copy or move
4297 /// constructed from the specified `value`. If (template parameter)
4298 /// `t_TYPE` is `bslmf::MovableRef<T>`, then the selected alternative is
4299 /// the one whose type is the same as `T` (modulo cv-qualification);
4300 /// otherwise, the selected alternative is the one that is the same as
4301 /// `t_TYPE` (modulo cv-qualification). This constructor participates
4302 /// in overload resolution only if there is a unique such alternative.
4303 /// If this `variant` is allocator-aware, the current installed default
4304 /// allocator is used to supply memory.
4305 template <class t_TYPE>
4306 variant(const t_TYPE& value,
4308
4309 /// Create a `variant` object holding a contained value of type (template
4310 /// parameter) `t_TYPE`, which is value-initialized. If this `variant` is
4311 /// allocator-aware, the currently installed default allocator is used to
4312 /// supply memory. This constructor participates in overload resolutionly
4313 /// if `t_TYPE` designates a unique alternative.
4314 template <class t_TYPE>
4317
4318 /// Create a `variant` object holding a contained value of type (template
4319 /// parameter) `t_TYPE`, which is direct-initialized from the specified
4320 /// `arg`. If this `variant` is allocator-aware, the currently installed
4321 /// default allocator is used to supply memory. This constructor
4322 /// participates in overload resolution only if `t_TYPE` designates a
4323 /// unique alternative.
4324 template <class t_TYPE, class t_ARG_01>
4326 const t_ARG_01& arg_01,
4328
4329 template <class t_TYPE, class t_ARG_01, class t_ARG_02>
4331 const t_ARG_01& arg_01,
4332 const t_ARG_02& arg_02,
4334
4335 template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
4337 const t_ARG_01& arg_01,
4338 const t_ARG_02& arg_02,
4339 const t_ARG_03& arg_03,
4341
4342 template <class t_TYPE,
4343 class t_ARG_01,
4344 class t_ARG_02,
4345 class t_ARG_03,
4346 class t_ARG_04>
4348 const t_ARG_01& arg_01,
4349 const t_ARG_02& arg_02,
4350 const t_ARG_03& arg_03,
4351 const t_ARG_04& arg_04,
4353
4354 template <class t_TYPE,
4355 class t_ARG_01,
4356 class t_ARG_02,
4357 class t_ARG_03,
4358 class t_ARG_04,
4359 class t_ARG_05>
4361 const t_ARG_01& arg_01,
4362 const t_ARG_02& arg_02,
4363 const t_ARG_03& arg_03,
4364 const t_ARG_04& arg_04,
4365 const t_ARG_05& arg_05,
4367
4368 template <class t_TYPE,
4369 class t_ARG_01,
4370 class t_ARG_02,
4371 class t_ARG_03,
4372 class t_ARG_04,
4373 class t_ARG_05,
4374 class t_ARG_06>
4376 const t_ARG_01& arg_01,
4377 const t_ARG_02& arg_02,
4378 const t_ARG_03& arg_03,
4379 const t_ARG_04& arg_04,
4380 const t_ARG_05& arg_05,
4381 const t_ARG_06& arg_06,
4383
4384 template <class t_TYPE,
4385 class t_ARG_01,
4386 class t_ARG_02,
4387 class t_ARG_03,
4388 class t_ARG_04,
4389 class t_ARG_05,
4390 class t_ARG_06,
4391 class t_ARG_07>
4393 const t_ARG_01& arg_01,
4394 const t_ARG_02& arg_02,
4395 const t_ARG_03& arg_03,
4396 const t_ARG_04& arg_04,
4397 const t_ARG_05& arg_05,
4398 const t_ARG_06& arg_06,
4399 const t_ARG_07& arg_07,
4401
4402 template <class t_TYPE,
4403 class t_ARG_01,
4404 class t_ARG_02,
4405 class t_ARG_03,
4406 class t_ARG_04,
4407 class t_ARG_05,
4408 class t_ARG_06,
4409 class t_ARG_07,
4410 class t_ARG_08>
4412 const t_ARG_01& arg_01,
4413 const t_ARG_02& arg_02,
4414 const t_ARG_03& arg_03,
4415 const t_ARG_04& arg_04,
4416 const t_ARG_05& arg_05,
4417 const t_ARG_06& arg_06,
4418 const t_ARG_07& arg_07,
4419 const t_ARG_08& arg_08,
4421
4422 template <class t_TYPE,
4423 class t_ARG_01,
4424 class t_ARG_02,
4425 class t_ARG_03,
4426 class t_ARG_04,
4427 class t_ARG_05,
4428 class t_ARG_06,
4429 class t_ARG_07,
4430 class t_ARG_08,
4431 class t_ARG_09>
4433 const t_ARG_01& arg_01,
4434 const t_ARG_02& arg_02,
4435 const t_ARG_03& arg_03,
4436 const t_ARG_04& arg_04,
4437 const t_ARG_05& arg_05,
4438 const t_ARG_06& arg_06,
4439 const t_ARG_07& arg_07,
4440 const t_ARG_08& arg_08,
4441 const t_ARG_09& arg_09,
4443
4444 template <class t_TYPE,
4445 class t_ARG_01,
4446 class t_ARG_02,
4447 class t_ARG_03,
4448 class t_ARG_04,
4449 class t_ARG_05,
4450 class t_ARG_06,
4451 class t_ARG_07,
4452 class t_ARG_08,
4453 class t_ARG_09,
4454 class t_ARG_10>
4456 const t_ARG_01& arg_01,
4457 const t_ARG_02& arg_02,
4458 const t_ARG_03& arg_03,
4459 const t_ARG_04& arg_04,
4460 const t_ARG_05& arg_05,
4461 const t_ARG_06& arg_06,
4462 const t_ARG_07& arg_07,
4463 const t_ARG_08& arg_08,
4464 const t_ARG_09& arg_09,
4465 const t_ARG_10& arg_10,
4467
4468 /// Create a `variant` object holding the alternative with index (template
4469 /// parameter) `t_INDEX`, which is value-initialized. If this `variant` is
4470 /// allocator-aware, the currently installed default allocator is used to
4471 /// supply memory. `t_INDEX` shall be a valid alternative index.
4472 template <size_t t_INDEX>
4474
4475 /// Create a `variant` object holding the alternative with index (template
4476 /// parameter) `t_INDEX`, which is direct-initialized from the specified
4477 /// `arg`. If this `variant` is allocator-aware, the currently installed
4478 /// default allocator is used to supply memory. `t_INDEX` shall be a valid
4479 /// alternative index.
4480 template <size_t t_INDEX, class t_ARG_01>
4481 explicit variant(bsl::in_place_index_t<t_INDEX>, const t_ARG_01& arg_01);
4482
4483 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
4485 const t_ARG_01& arg_01,
4486 const t_ARG_02& arg_02);
4487
4488 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
4490 const t_ARG_01& arg_01,
4491 const t_ARG_02& arg_02,
4492 const t_ARG_03& arg_03);
4493
4494 template <size_t t_INDEX,
4495 class t_ARG_01,
4496 class t_ARG_02,
4497 class t_ARG_03,
4498 class t_ARG_04>
4500 const t_ARG_01& arg_01,
4501 const t_ARG_02& arg_02,
4502 const t_ARG_03& arg_03,
4503 const t_ARG_04& arg_04);
4504
4505 template <size_t t_INDEX,
4506 class t_ARG_01,
4507 class t_ARG_02,
4508 class t_ARG_03,
4509 class t_ARG_04,
4510 class t_ARG_05>
4512 const t_ARG_01& arg_01,
4513 const t_ARG_02& arg_02,
4514 const t_ARG_03& arg_03,
4515 const t_ARG_04& arg_04,
4516 const t_ARG_05& arg_05);
4517
4518 template <size_t t_INDEX,
4519 class t_ARG_01,
4520 class t_ARG_02,
4521 class t_ARG_03,
4522 class t_ARG_04,
4523 class t_ARG_05,
4524 class t_ARG_06>
4526 const t_ARG_01& arg_01,
4527 const t_ARG_02& arg_02,
4528 const t_ARG_03& arg_03,
4529 const t_ARG_04& arg_04,
4530 const t_ARG_05& arg_05,
4531 const t_ARG_06& arg_06);
4532
4533 template <size_t t_INDEX,
4534 class t_ARG_01,
4535 class t_ARG_02,
4536 class t_ARG_03,
4537 class t_ARG_04,
4538 class t_ARG_05,
4539 class t_ARG_06,
4540 class t_ARG_07>
4542 const t_ARG_01& arg_01,
4543 const t_ARG_02& arg_02,
4544 const t_ARG_03& arg_03,
4545 const t_ARG_04& arg_04,
4546 const t_ARG_05& arg_05,
4547 const t_ARG_06& arg_06,
4548 const t_ARG_07& arg_07);
4549
4550 template <size_t t_INDEX,
4551 class t_ARG_01,
4552 class t_ARG_02,
4553 class t_ARG_03,
4554 class t_ARG_04,
4555 class t_ARG_05,
4556 class t_ARG_06,
4557 class t_ARG_07,
4558 class t_ARG_08>
4560 const t_ARG_01& arg_01,
4561 const t_ARG_02& arg_02,
4562 const t_ARG_03& arg_03,
4563 const t_ARG_04& arg_04,
4564 const t_ARG_05& arg_05,
4565 const t_ARG_06& arg_06,
4566 const t_ARG_07& arg_07,
4567 const t_ARG_08& arg_08);
4568
4569 template <size_t t_INDEX,
4570 class t_ARG_01,
4571 class t_ARG_02,
4572 class t_ARG_03,
4573 class t_ARG_04,
4574 class t_ARG_05,
4575 class t_ARG_06,
4576 class t_ARG_07,
4577 class t_ARG_08,
4578 class t_ARG_09>
4580 const t_ARG_01& arg_01,
4581 const t_ARG_02& arg_02,
4582 const t_ARG_03& arg_03,
4583 const t_ARG_04& arg_04,
4584 const t_ARG_05& arg_05,
4585 const t_ARG_06& arg_06,
4586 const t_ARG_07& arg_07,
4587 const t_ARG_08& arg_08,
4588 const t_ARG_09& arg_09);
4589
4590 template <size_t t_INDEX,
4591 class t_ARG_01,
4592 class t_ARG_02,
4593 class t_ARG_03,
4594 class t_ARG_04,
4595 class t_ARG_05,
4596 class t_ARG_06,
4597 class t_ARG_07,
4598 class t_ARG_08,
4599 class t_ARG_09,
4600 class t_ARG_10>
4602 const t_ARG_01& arg_01,
4603 const t_ARG_02& arg_02,
4604 const t_ARG_03& arg_03,
4605 const t_ARG_04& arg_04,
4606 const t_ARG_05& arg_05,
4607 const t_ARG_06& arg_06,
4608 const t_ARG_07& arg_07,
4609 const t_ARG_08& arg_08,
4610 const t_ARG_09& arg_09,
4611 const t_ARG_10& arg_10);
4612
4613 // allocator-extended constructors
4614
4615 /// Create a `variant` object holding the 0th alternative, which is
4616 /// value-initialized. If this `variant` is allocator-aware, the
4617 /// specified `allocator` is used to supply memory.
4619
4620 /// Create a `variant` object holding the same alternative as the
4621 /// specified `original` object. If this `variant` is allocator-aware,
4622 /// the specified `allocator` is used to supply memory. If the
4623 /// `original` object is not valueless by exception, the contained value
4624 /// is copy/move constructed from the contained value of `original`.
4625 /// All alternatives shall be copy/move constructible.
4628 const variant& original);
4631 BloombergLP::bslmf::MovableRef<variant> original);
4632
4633 /// Create a `variant` object whose contained value is copy or move
4634 /// constructed from the specified `value`. If (template parameter)
4635 /// `t_TYPE` is `bslmf::MovableRef<T>`, then the selected alternative is
4636 /// the one whose type is the same as `T` (modulo cv-qualification);
4637 /// otherwise, the selected alternative is the one that is the same as
4638 /// `t_TYPE` (modulo cv-qualification). This constructor participates in
4639 /// overload resolution only if there is a unique such alternative. If
4640 /// this `variant` is allocator-aware, the specified `allocator` is used to
4641 /// supply memory.
4642 template <class t_TYPE>
4646 const t_TYPE& value,
4648
4649 /// Create a `variant` object holding a contained value of type
4650 /// (template parameter) `t_TYPE`, which is value-initialized. If this
4651 /// `variant` is allocator-aware, the currently installed default
4652 /// allocator is used to supply memory. If this `variant` is
4653 /// allocator-aware, the specified `allocator` is used to supply memory.
4654 /// This constructor participates in overload resolution only if
4655 /// `t_TYPE` designates a unique alternative.
4656 template <class t_TYPE>
4657 explicit variant(
4662
4663 /// Create a `variant` object holding a contained value of type (template
4664 /// parameter) `t_TYPE`, which is direct-initialized from the specified
4665 /// `arg`. If this `variant` is allocator-aware, the specified `allocator`
4666 /// is used to supply memory. This constructor participates in overload
4667 /// resolution only if `t_TYPE` designates a unique alternative.
4668 template <class t_TYPE, class t_ARG_01>
4669 explicit variant(
4673 const t_ARG_01& arg_01,
4675
4676 template <class t_TYPE, class t_ARG_01, class t_ARG_02>
4677 explicit variant(
4681 const t_ARG_01& arg_01,
4682 const t_ARG_02& arg_02,
4684
4685 template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
4686 explicit variant(
4690 const t_ARG_01& arg_01,
4691 const t_ARG_02& arg_02,
4692 const t_ARG_03& arg_03,
4694
4695 template <class t_TYPE,
4696 class t_ARG_01,
4697 class t_ARG_02,
4698 class t_ARG_03,
4699 class t_ARG_04>
4703 const t_ARG_01& arg_01,
4704 const t_ARG_02& arg_02,
4705 const t_ARG_03& arg_03,
4706 const t_ARG_04& arg_04,
4708
4709 template <class t_TYPE,
4710 class t_ARG_01,
4711 class t_ARG_02,
4712 class t_ARG_03,
4713 class t_ARG_04,
4714 class t_ARG_05>
4718 const t_ARG_01& arg_01,
4719 const t_ARG_02& arg_02,
4720 const t_ARG_03& arg_03,
4721 const t_ARG_04& arg_04,
4722 const t_ARG_05& arg_05,
4724
4725 template <class t_TYPE,
4726 class t_ARG_01,
4727 class t_ARG_02,
4728 class t_ARG_03,
4729 class t_ARG_04,
4730 class t_ARG_05,
4731 class t_ARG_06>
4735 const t_ARG_01& arg_01,
4736 const t_ARG_02& arg_02,
4737 const t_ARG_03& arg_03,
4738 const t_ARG_04& arg_04,
4739 const t_ARG_05& arg_05,
4740 const t_ARG_06& arg_06,
4742
4743 template <class t_TYPE,
4744 class t_ARG_01,
4745 class t_ARG_02,
4746 class t_ARG_03,
4747 class t_ARG_04,
4748 class t_ARG_05,
4749 class t_ARG_06,
4750 class t_ARG_07>
4754 const t_ARG_01& arg_01,
4755 const t_ARG_02& arg_02,
4756 const t_ARG_03& arg_03,
4757 const t_ARG_04& arg_04,
4758 const t_ARG_05& arg_05,
4759 const t_ARG_06& arg_06,
4760 const t_ARG_07& arg_07,
4762
4763 template <class t_TYPE,
4764 class t_ARG_01,
4765 class t_ARG_02,
4766 class t_ARG_03,
4767 class t_ARG_04,
4768 class t_ARG_05,
4769 class t_ARG_06,
4770 class t_ARG_07,
4771 class t_ARG_08>
4775 const t_ARG_01& arg_01,
4776 const t_ARG_02& arg_02,
4777 const t_ARG_03& arg_03,
4778 const t_ARG_04& arg_04,
4779 const t_ARG_05& arg_05,
4780 const t_ARG_06& arg_06,
4781 const t_ARG_07& arg_07,
4782 const t_ARG_08& arg_08,
4784
4785 template <class t_TYPE,
4786 class t_ARG_01,
4787 class t_ARG_02,
4788 class t_ARG_03,
4789 class t_ARG_04,
4790 class t_ARG_05,
4791 class t_ARG_06,
4792 class t_ARG_07,
4793 class t_ARG_08,
4794 class t_ARG_09>
4798 const t_ARG_01& arg_01,
4799 const t_ARG_02& arg_02,
4800 const t_ARG_03& arg_03,
4801 const t_ARG_04& arg_04,
4802 const t_ARG_05& arg_05,
4803 const t_ARG_06& arg_06,
4804 const t_ARG_07& arg_07,
4805 const t_ARG_08& arg_08,
4806 const t_ARG_09& arg_09,
4808
4809 template <class t_TYPE,
4810 class t_ARG_01,
4811 class t_ARG_02,
4812 class t_ARG_03,
4813 class t_ARG_04,
4814 class t_ARG_05,
4815 class t_ARG_06,
4816 class t_ARG_07,
4817 class t_ARG_08,
4818 class t_ARG_09,
4819 class t_ARG_10>
4823 const t_ARG_01& arg_01,
4824 const t_ARG_02& arg_02,
4825 const t_ARG_03& arg_03,
4826 const t_ARG_04& arg_04,
4827 const t_ARG_05& arg_05,
4828 const t_ARG_06& arg_06,
4829 const t_ARG_07& arg_07,
4830 const t_ARG_08& arg_08,
4831 const t_ARG_09& arg_09,
4832 const t_ARG_10& arg_10,
4834
4835 /// Create a `variant` object holding the alternative with index (template
4836 /// parameter) `t_INDEX`, which is value-initialized. If this `variant` is
4837 /// allocator-aware, the specified `allocator` is used to supply memory.
4838 /// `t_INDEX` shall be a valid alternative index.
4839 template <size_t t_INDEX>
4843
4844 /// Create a `variant` object holding the alternative with index (template
4845 /// parameter) `t_INDEX`, which is direct-initialized from the specified
4846 /// `arg`. If this `variant` is allocator-aware, the specified `allocator`
4847 /// is used to supply memory. `t_INDEX` shall be a valid alternative
4848 /// index.
4849 template <size_t t_INDEX, class t_ARG_01>
4853 const t_ARG_01& arg_01);
4854
4855 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
4859 const t_ARG_01& arg_01,
4860 const t_ARG_02& arg_02);
4861
4862 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
4866 const t_ARG_01& arg_01,
4867 const t_ARG_02& arg_02,
4868 const t_ARG_03& arg_03);
4869
4870 template <size_t t_INDEX,
4871 class t_ARG_01,
4872 class t_ARG_02,
4873 class t_ARG_03,
4874 class t_ARG_04>
4878 const t_ARG_01& arg_01,
4879 const t_ARG_02& arg_02,
4880 const t_ARG_03& arg_03,
4881 const t_ARG_04& arg_04);
4882
4883 template <size_t t_INDEX,
4884 class t_ARG_01,
4885 class t_ARG_02,
4886 class t_ARG_03,
4887 class t_ARG_04,
4888 class t_ARG_05>
4892 const t_ARG_01& arg_01,
4893 const t_ARG_02& arg_02,
4894 const t_ARG_03& arg_03,
4895 const t_ARG_04& arg_04,
4896 const t_ARG_05& arg_05);
4897
4898 template <size_t t_INDEX,
4899 class t_ARG_01,
4900 class t_ARG_02,
4901 class t_ARG_03,
4902 class t_ARG_04,
4903 class t_ARG_05,
4904 class t_ARG_06>
4908 const t_ARG_01& arg_01,
4909 const t_ARG_02& arg_02,
4910 const t_ARG_03& arg_03,
4911 const t_ARG_04& arg_04,
4912 const t_ARG_05& arg_05,
4913 const t_ARG_06& arg_06);
4914
4915 template <size_t t_INDEX,
4916 class t_ARG_01,
4917 class t_ARG_02,
4918 class t_ARG_03,
4919 class t_ARG_04,
4920 class t_ARG_05,
4921 class t_ARG_06,
4922 class t_ARG_07>
4926 const t_ARG_01& arg_01,
4927 const t_ARG_02& arg_02,
4928 const t_ARG_03& arg_03,
4929 const t_ARG_04& arg_04,
4930 const t_ARG_05& arg_05,
4931 const t_ARG_06& arg_06,
4932 const t_ARG_07& arg_07);
4933
4934 template <size_t t_INDEX,
4935 class t_ARG_01,
4936 class t_ARG_02,
4937 class t_ARG_03,
4938 class t_ARG_04,
4939 class t_ARG_05,
4940 class t_ARG_06,
4941 class t_ARG_07,
4942 class t_ARG_08>
4946 const t_ARG_01& arg_01,
4947 const t_ARG_02& arg_02,
4948 const t_ARG_03& arg_03,
4949 const t_ARG_04& arg_04,
4950 const t_ARG_05& arg_05,
4951 const t_ARG_06& arg_06,
4952 const t_ARG_07& arg_07,
4953 const t_ARG_08& arg_08);
4954
4955 template <size_t t_INDEX,
4956 class t_ARG_01,
4957 class t_ARG_02,
4958 class t_ARG_03,
4959 class t_ARG_04,
4960 class t_ARG_05,
4961 class t_ARG_06,
4962 class t_ARG_07,
4963 class t_ARG_08,
4964 class t_ARG_09>
4968 const t_ARG_01& arg_01,
4969 const t_ARG_02& arg_02,
4970 const t_ARG_03& arg_03,
4971 const t_ARG_04& arg_04,
4972 const t_ARG_05& arg_05,
4973 const t_ARG_06& arg_06,
4974 const t_ARG_07& arg_07,
4975 const t_ARG_08& arg_08,
4976 const t_ARG_09& arg_09);
4977
4978 template <size_t t_INDEX,
4979 class t_ARG_01,
4980 class t_ARG_02,
4981 class t_ARG_03,
4982 class t_ARG_04,
4983 class t_ARG_05,
4984 class t_ARG_06,
4985 class t_ARG_07,
4986 class t_ARG_08,
4987 class t_ARG_09,
4988 class t_ARG_10>
4992 const t_ARG_01& arg_01,
4993 const t_ARG_02& arg_02,
4994 const t_ARG_03& arg_03,
4995 const t_ARG_04& arg_04,
4996 const t_ARG_05& arg_05,
4997 const t_ARG_06& arg_06,
4998 const t_ARG_07& arg_07,
4999 const t_ARG_08& arg_08,
5000 const t_ARG_09& arg_09,
5001 const t_ARG_10& arg_10);
5002
5003#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5004
5005 // 20.7.3.2, destructor
5006 /// Destroy this object. The contained value (if any) is destroyed.
5007 /// For simplicity of implementation, this method differs from the
5008 /// standard in the following ways:
5009 /// * conditional triviality is not implemented
5010 /// * 'constexpr' is not implemented
5011 ~variant() = default;
5012
5013 // MANIPULATORS
5014 // 20.7.3.4, modifiers
5015#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5016 /// Create an object of alternative (template parameter) `t_TYPE` in
5017 /// place, direct-initialized from the specified `args`, destroying any
5018 /// previously contained value first. Return a reference to the newly
5019 /// created `t_TYPE` object. If `t_TYPE` is allocator-aware, it uses
5020 /// the allocator specified upon the construction of this `variant`
5021 /// object to supply memory; passing an allocator argument to this
5022 /// method results in two allocators being passed to the alternative
5023 /// constructor, resulting in a likely compilation error. If the
5024 /// constructor of `t_TYPE` exits via an exception, this object may be
5025 /// left in the valueless by exception state. This method participates
5026 /// in overload resolution only if `t_TYPE` designates a unique
5027 /// alternative and is constructible from `args`. For simplicity of
5028 /// implementation, this method differs from the standard in the
5029 /// following way:
5030 /// * `constexpr` is not implemented
5031 template <class t_TYPE,
5032 class... t_ARGS,
5033 class = typename bsl::enable_if_t<
5035 std::is_constructible<t_TYPE, t_ARGS...>::value> >
5036 t_TYPE& emplace(t_ARGS&&... args)
5037 {
5038 // This function template must be defined inline inside the class
5039 // definition, as Microsoft Visual C++ does not recognize the
5040 // definition as matching this signature when placed out-of-line.
5041 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
5042 Variant_Base::template baseEmplace<index>(
5043 std::forward<t_ARGS>(args)...);
5044
5045 return bsl::get<index>(*this);
5046 }
5047
5048 /// Create an object of alternative (template parameter) `t_TYPE` in
5049 /// place, direct-initialized from the specified `il` and `args`,
5050 /// destroying any previously contained value first. Return a reference
5051 /// to the newly created `t_TYPE` object. If `t_TYPE` is
5052 /// allocator-aware, it uses the allocator specified upon the
5053 /// construction of this `variant` object to supply memory; passing an
5054 /// allocator argument to this method results in two allocators being
5055 /// passed to the alternative constructor, resulting in a likely
5056 /// compilation error. If the constructor of `t_TYPE` exits via an
5057 /// exception, this object may be left in the valueless by exception
5058 /// state. This method participates in overload resolution only if
5059 /// `t_TYPE` designates a unique alternative and is constructible from
5060 /// `il` and `args`. For simplicity of implementation, this method
5061 /// differs from the standard in the following way:
5062 /// * `constexpr` is not implemented
5063 template <class t_TYPE,
5064 class INIT_LIST_TYPE,
5065 class... t_ARGS,
5066 class = typename bsl::enable_if_t<
5068 std::is_constructible<t_TYPE,
5069 std::initializer_list<INIT_LIST_TYPE>&,
5070 t_ARGS...>::value> >
5071 t_TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args)
5072 {
5073 // This function template must be defined inline inside the class
5074 // definition, as Microsoft Visual C++ does not recognize the
5075 // definition as matching this signature when placed out-of-line.
5076 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
5077 Variant_Base::template baseEmplace<index>(
5078 il, std::forward<t_ARGS>(args)...);
5079
5080 return bsl::get<index>(*this);
5081 }
5082
5083 /// Create the alternative with index (template parameter) `t_INDEX` in
5084 /// place, direct-initialized from the specified `args`, destroying any
5085 /// previously contained value first. Return a reference to the newly
5086 /// created contained value. If the alternative is allocator-aware, it
5087 /// uses the allocator specified upon the construction of this `variant`
5088 /// object to supply memory; passing an allocator argument to this
5089 /// method results in two allocators being passed to the alternative
5090 /// constructor, resulting in a likely compilation error. If the
5091 /// alternative constructor exits via an exception, this object may be
5092 /// left in the valueless by exception state. This method participates
5093 /// in overload resolution only if `t_INDEX` is a valid alternative
5094 /// index and the designated alternative is constructible from `args`.
5095 /// For simplicity of implementation, this method differs from the
5096 /// standard in the following way:
5097 /// * `constexpr` is not implemented
5098 template <size_t t_INDEX,
5099 class... t_ARGS,
5100 class = typename bsl::enable_if_t<
5101 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
5102 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
5103 t_ARGS...>::value> >
5104 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5105 emplace(t_ARGS&&... args)
5106 {
5107 // This function template must be defined inline inside the class
5108 // definition, as Microsoft Visual C++ does not recognize the
5109 // definition as matching this signature when placed out-of-line.
5110 Variant_Base::template baseEmplace<t_INDEX>(
5111 std::forward<t_ARGS>(args)...);
5112
5113 return bsl::get<t_INDEX>(*this);
5114 }
5115
5116 /// Create the alternative with index (template parameter) `t_INDEX` in
5117 /// place, direct-initialized from the specified `il` and args',
5118 /// destroying any previously contained value first. Return a reference
5119 /// to the newly created contained value. If the alternative is
5120 /// allocator-aware, it uses the allocator specified upon the
5121 /// construction of this `variant` object to supply memory; passing an
5122 /// allocator argument to this method results in two allocators being
5123 /// passed to the alternative constructor, resulting in a likely
5124 /// compilation error. If the alternative constructor exits via an
5125 /// exception, this object may be left in the valueless by exception
5126 /// state. This method participates in overload resolution only if
5127 /// `t_INDEX` is a valid alternative index and the designated
5128 /// alternative is constructible from `il` and `args`. For simplicity
5129 /// of implementation, this method differs from the standard in the
5130 /// following way:
5131 /// * `constexpr` is not implemented
5132 template <size_t t_INDEX,
5133 class INIT_LIST_TYPE,
5134 class... t_ARGS,
5135 class = typename bsl::enable_if_t<
5136 (t_INDEX < 1 + sizeof...(t_TAIL)) &&
5137 std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
5138 std::initializer_list<INIT_LIST_TYPE>&,
5139 t_ARGS...>::value> >
5140 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5141 emplace(std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args)
5142 {
5143 // This function template must be defined inline inside the class
5144 // definition, as Microsoft Visual C++ does not recognize the
5145 // definition as matching this signature when placed out-of-line.
5146 Variant_Base::template baseEmplace<t_INDEX>(
5147 il, std::forward<t_ARGS>(args)...);
5148
5149 return bsl::get<t_INDEX>(*this);
5150 }
5151
5152#else // BSL_VARIANT_FULL_IMPLEMENTATION
5153
5154 /// Create an object of alternative (template parameter) `t_TYPE` in
5155 /// place, which is value-initialized; any previously contained value is
5156 /// destroyed first. Return a reference to the newly created `t_TYPE`
5157 /// object. If `t_TYPE` is allocator-aware, it uses the allocator
5158 /// specified upon the construction of this `variant` object to supply
5159 /// memory; passing an allocator argument to this method results in two
5160 /// allocators being passed to the alternative constructor, resulting in a likely compilation error.
5161 ///
5162 /// \note Note that if the constructor of
5163 /// `t_TYPE` exits via an exception, this object is left in a valueless
5164 /// by exception state. This function participates in overload
5165 /// resolution only if `t_TYPE` is a unique alternative.
5166 template <class t_TYPE>
5167 typename bsl::enable_if<
5168 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5169 t_TYPE&>::type
5171
5172 /// Create an object of alternative (template parameter) `t_TYPE` in
5173 /// place, which is direct-initialized from `arg`; any previously
5174 /// contained value is destroyed first. Return a reference to the newly
5175 /// created `t_TYPE` object. If `t_TYPE` is allocator-aware, it uses
5176 /// the allocator specified upon the construction of this `variant`
5177 /// object to supply memory; passing an allocator argument to this
5178 /// method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error.
5179 ///
5180 /// \note Note that if
5181 /// the constructor of `t_TYPE` exits via an exception, this object is
5182 /// left in a valueless by exception state. This function participates
5183 /// in overload resolution only if `t_TYPE` is a unique alternative.
5184 template <class t_TYPE, class t_ARG_01>
5185 typename bsl::enable_if<
5186 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5187 t_TYPE&>::type
5188 emplace(const t_ARG_01& arg_01);
5189
5190 template <class t_TYPE, class t_ARG_01, class t_ARG_02>
5191 typename bsl::enable_if<
5192 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5193 t_TYPE&>::type
5194 emplace(const t_ARG_01& arg_01, const t_ARG_02& arg_02);
5195
5196 template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
5197 typename bsl::enable_if<
5198 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5199 t_TYPE&>::type
5200 emplace(const t_ARG_01& arg_01,
5201 const t_ARG_02& arg_02,
5202 const t_ARG_03& arg_03);
5203
5204 template <class t_TYPE,
5205 class t_ARG_01,
5206 class t_ARG_02,
5207 class t_ARG_03,
5208 class t_ARG_04>
5209 typename bsl::enable_if<
5210 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5211 t_TYPE&>::type
5212 emplace(const t_ARG_01& arg_01,
5213 const t_ARG_02& arg_02,
5214 const t_ARG_03& arg_03,
5215 const t_ARG_04& arg_04);
5216
5217 template <class t_TYPE,
5218 class t_ARG_01,
5219 class t_ARG_02,
5220 class t_ARG_03,
5221 class t_ARG_04,
5222 class t_ARG_05>
5223 typename bsl::enable_if<
5224 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5225 t_TYPE&>::type
5226 emplace(const t_ARG_01& arg_01,
5227 const t_ARG_02& arg_02,
5228 const t_ARG_03& arg_03,
5229 const t_ARG_04& arg_04,
5230 const t_ARG_05& arg_05);
5231
5232 template <class t_TYPE,
5233 class t_ARG_01,
5234 class t_ARG_02,
5235 class t_ARG_03,
5236 class t_ARG_04,
5237 class t_ARG_05,
5238 class t_ARG_06>
5239 typename bsl::enable_if<
5240 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5241 t_TYPE&>::type
5242 emplace(const t_ARG_01& arg_01,
5243 const t_ARG_02& arg_02,
5244 const t_ARG_03& arg_03,
5245 const t_ARG_04& arg_04,
5246 const t_ARG_05& arg_05,
5247 const t_ARG_06& arg_06);
5248
5249 template <class t_TYPE,
5250 class t_ARG_01,
5251 class t_ARG_02,
5252 class t_ARG_03,
5253 class t_ARG_04,
5254 class t_ARG_05,
5255 class t_ARG_06,
5256 class t_ARG_07>
5257 typename bsl::enable_if<
5258 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5259 t_TYPE&>::type
5260 emplace(const t_ARG_01& arg_01,
5261 const t_ARG_02& arg_02,
5262 const t_ARG_03& arg_03,
5263 const t_ARG_04& arg_04,
5264 const t_ARG_05& arg_05,
5265 const t_ARG_06& arg_06,
5266 const t_ARG_07& arg_07);
5267
5268 template <class t_TYPE,
5269 class t_ARG_01,
5270 class t_ARG_02,
5271 class t_ARG_03,
5272 class t_ARG_04,
5273 class t_ARG_05,
5274 class t_ARG_06,
5275 class t_ARG_07,
5276 class t_ARG_08>
5277 typename bsl::enable_if<
5278 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5279 t_TYPE&>::type
5280 emplace(const t_ARG_01& arg_01,
5281 const t_ARG_02& arg_02,
5282 const t_ARG_03& arg_03,
5283 const t_ARG_04& arg_04,
5284 const t_ARG_05& arg_05,
5285 const t_ARG_06& arg_06,
5286 const t_ARG_07& arg_07,
5287 const t_ARG_08& arg_08);
5288
5289 template <class t_TYPE,
5290 class t_ARG_01,
5291 class t_ARG_02,
5292 class t_ARG_03,
5293 class t_ARG_04,
5294 class t_ARG_05,
5295 class t_ARG_06,
5296 class t_ARG_07,
5297 class t_ARG_08,
5298 class t_ARG_09>
5299 typename bsl::enable_if<
5300 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5301 t_TYPE&>::type
5302 emplace(const t_ARG_01& arg_01,
5303 const t_ARG_02& arg_02,
5304 const t_ARG_03& arg_03,
5305 const t_ARG_04& arg_04,
5306 const t_ARG_05& arg_05,
5307 const t_ARG_06& arg_06,
5308 const t_ARG_07& arg_07,
5309 const t_ARG_08& arg_08,
5310 const t_ARG_09& arg_09);
5311
5312 template <class t_TYPE,
5313 class t_ARG_01,
5314 class t_ARG_02,
5315 class t_ARG_03,
5316 class t_ARG_04,
5317 class t_ARG_05,
5318 class t_ARG_06,
5319 class t_ARG_07,
5320 class t_ARG_08,
5321 class t_ARG_09,
5322 class t_ARG_10>
5323 typename bsl::enable_if<
5324 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, variant>::value,
5325 t_TYPE&>::type
5326 emplace(const t_ARG_01& arg_01,
5327 const t_ARG_02& arg_02,
5328 const t_ARG_03& arg_03,
5329 const t_ARG_04& arg_04,
5330 const t_ARG_05& arg_05,
5331 const t_ARG_06& arg_06,
5332 const t_ARG_07& arg_07,
5333 const t_ARG_08& arg_08,
5334 const t_ARG_09& arg_09,
5335 const t_ARG_10& arg_10);
5336
5337 /// Create the alternative with index (template parameter) `t_INDEX` in
5338 /// place, which is value-initialized; any previously contained value is
5339 /// destroyed first. Return a reference to the newly created contained
5340 /// value. If the alternative is allocator-aware, it uses the allocator
5341 /// specified upon the construction of this `variant` object to supply
5342 /// memory; passing an allocator argument to this method results in two
5343 /// allocators being passed to the alternative constructor, resulting in a likely compilation error.
5344 ///
5345 /// \note Note that if the alternative
5346 /// constructor exits via an exception, this object is left in the
5347 /// valueless by exception state. `t_INDEX` shall be a valid
5348 /// alternative index.
5349 template <size_t t_INDEX>
5350 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5352
5353 /// Create the alternative with index (template parameter) `t_INDEX` in
5354 /// place, direct-initialized from the specified `arg`; any previously
5355 /// contained value is destroyed first. Return a reference to the newly
5356 /// created contained value. If the alternative is allocator-aware, it
5357 /// uses the allocator specified upon the construction of this `variant`
5358 /// object to supply memory; passing an allocator argument to this
5359 /// method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error.
5360 ///
5361 /// \note Note that if
5362 /// the alternative constructor exits via an exception, this object is
5363 /// left in the valueless by exception state. `t_INDEX` shall be a
5364 /// valid alternative index.
5365 template <size_t t_INDEX, class t_ARG_01>
5366 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5367 emplace(const t_ARG_01& arg_01);
5368
5369 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
5370 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5371 emplace(const t_ARG_01& arg_01, const t_ARG_02& arg_02);
5372
5373 template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
5374 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5375 emplace(const t_ARG_01& arg_01,
5376 const t_ARG_02& arg_02,
5377 const t_ARG_03& arg_03);
5378
5379 template <size_t t_INDEX,
5380 class t_ARG_01,
5381 class t_ARG_02,
5382 class t_ARG_03,
5383 class t_ARG_04>
5384 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5385 emplace(const t_ARG_01& arg_01,
5386 const t_ARG_02& arg_02,
5387 const t_ARG_03& arg_03,
5388 const t_ARG_04& arg_04);
5389
5390 template <size_t t_INDEX,
5391 class t_ARG_01,
5392 class t_ARG_02,
5393 class t_ARG_03,
5394 class t_ARG_04,
5395 class t_ARG_05>
5396 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5397 emplace(const t_ARG_01& arg_01,
5398 const t_ARG_02& arg_02,
5399 const t_ARG_03& arg_03,
5400 const t_ARG_04& arg_04,
5401 const t_ARG_05& arg_05);
5402
5403 template <size_t t_INDEX,
5404 class t_ARG_01,
5405 class t_ARG_02,
5406 class t_ARG_03,
5407 class t_ARG_04,
5408 class t_ARG_05,
5409 class t_ARG_06>
5410 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5411 emplace(const t_ARG_01& arg_01,
5412 const t_ARG_02& arg_02,
5413 const t_ARG_03& arg_03,
5414 const t_ARG_04& arg_04,
5415 const t_ARG_05& arg_05,
5416 const t_ARG_06& arg_06);
5417
5418 template <size_t t_INDEX,
5419 class t_ARG_01,
5420 class t_ARG_02,
5421 class t_ARG_03,
5422 class t_ARG_04,
5423 class t_ARG_05,
5424 class t_ARG_06,
5425 class t_ARG_07>
5426 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5427 emplace(const t_ARG_01& arg_01,
5428 const t_ARG_02& arg_02,
5429 const t_ARG_03& arg_03,
5430 const t_ARG_04& arg_04,
5431 const t_ARG_05& arg_05,
5432 const t_ARG_06& arg_06,
5433 const t_ARG_07& arg_07);
5434
5435 template <size_t t_INDEX,
5436 class t_ARG_01,
5437 class t_ARG_02,
5438 class t_ARG_03,
5439 class t_ARG_04,
5440 class t_ARG_05,
5441 class t_ARG_06,
5442 class t_ARG_07,
5443 class t_ARG_08>
5444 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5445 emplace(const t_ARG_01& arg_01,
5446 const t_ARG_02& arg_02,
5447 const t_ARG_03& arg_03,
5448 const t_ARG_04& arg_04,
5449 const t_ARG_05& arg_05,
5450 const t_ARG_06& arg_06,
5451 const t_ARG_07& arg_07,
5452 const t_ARG_08& arg_08);
5453
5454 template <size_t t_INDEX,
5455 class t_ARG_01,
5456 class t_ARG_02,
5457 class t_ARG_03,
5458 class t_ARG_04,
5459 class t_ARG_05,
5460 class t_ARG_06,
5461 class t_ARG_07,
5462 class t_ARG_08,
5463 class t_ARG_09>
5464 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5465 emplace(const t_ARG_01& arg_01,
5466 const t_ARG_02& arg_02,
5467 const t_ARG_03& arg_03,
5468 const t_ARG_04& arg_04,
5469 const t_ARG_05& arg_05,
5470 const t_ARG_06& arg_06,
5471 const t_ARG_07& arg_07,
5472 const t_ARG_08& arg_08,
5473 const t_ARG_09& arg_09);
5474
5475 template <size_t t_INDEX,
5476 class t_ARG_01,
5477 class t_ARG_02,
5478 class t_ARG_03,
5479 class t_ARG_04,
5480 class t_ARG_05,
5481 class t_ARG_06,
5482 class t_ARG_07,
5483 class t_ARG_08,
5484 class t_ARG_09,
5485 class t_ARG_10>
5486 typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
5487 emplace(const t_ARG_01& arg_01,
5488 const t_ARG_02& arg_02,
5489 const t_ARG_03& arg_03,
5490 const t_ARG_04& arg_04,
5491 const t_ARG_05& arg_05,
5492 const t_ARG_06& arg_06,
5493 const t_ARG_07& arg_07,
5494 const t_ARG_08& arg_08,
5495 const t_ARG_09& arg_09,
5496 const t_ARG_10& arg_10);
5497#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5498
5499 // MANIPULATORS
5500 // 20.7.3.3, assignment
5501#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5502 /// If `rhs` holds the same alternative type as this object, copy assign
5503 /// the contained value of `rhs` to the contained value of this object.
5504 /// Otherwise, destroy the contained value of this object (if any) and, if
5505 /// `rhs` holds a value, copy-construct the corresponding alternative of
5506 /// this object from the contained value of `rhs`. The allocators of this
5507 /// object and `rhs` both remain unchanged. This operator is deleted
5508 /// unless all alternatives are copy constructible and copy assignable. If
5509 /// the construction of a new alternative object exits via an exception,
5510 /// this `variant` object is left in a valueless by exception state. This
5511 /// is different from the standard, which requires a temporary copy of
5512 /// `rhs` to be made if copy construction of the active alternative is not
5513 /// `noexcept` (see [variant.assign] for details). The standard behavior
5514 /// causes unnecessary performance degradation in cases where the
5515 /// alternative constructor does not throw, yet is not marked `noexcept`;
5516 /// this behavior is therefore not implemented in `bsl::variant`. For
5517 /// simplicity of implementation, this method also differs from the
5518 /// standard in the following ways:
5519 /// * conditional triviality is not implemented
5520 /// * `constexpr` is not implemented
5521 /// * `noexcept` specification is not implemented
5522 variant& operator=(const variant& rhs) = default;
5523
5524 /// If `rhs` holds the same alternative type as this object, move assign
5525 /// the contained value of `rhs` to the contained value of this object.
5526 /// Otherwise, destroy the contained value of this object (if any) and, if
5527 /// `rhs` holds a value, move-construct the corresponding alternative of
5528 /// this object from the contained value of `rhs`. The allocators of this
5529 /// object and `rhs` both remain unchanged. If the construction of a new
5530 /// alternative object throws an exception, this `variant` object is left
5531 /// in a valueless by exception state. This operator participes in
5532 /// overload resolution only if all alternatives are move constructible and
5533 /// mvoe assignable. For simplicity of implementation, this method differs
5534 /// from the standard in the following ways:
5535 /// * conditional triviality is not implemented
5536 /// * `constexpr` is not implemented
5537 /// * `noexcept` specification is not implemented
5538 variant& operator=(variant&& rhs) = default;
5539
5540 /// Assign to this object the specified `value`. The alternative
5541 /// corresponding to `value` is the best match among all alternatives
5542 /// for which the expression
5543 /// `t_ALT_TYPE x[] = {std::forward<t_TYPE>(value)};` is well formed,
5544 /// and this operator participates in overload resolution only if there
5545 /// is a unique best matching alternative and that alternative is both
5546 /// constructible and assignable from `value`. If this `variant`
5547 /// already holds the alternative corresponding to `value`, the
5548 /// contained value is assigned to from `value`; otherwise, any
5549 /// contained value is destroyed and the alternative corresponding to `value` is direct-initialized from `value`.
5550 ///
5551 /// \note Note that if the
5552 /// construction of a new alternative object exits via an exception,
5553 /// this `variant` object may be left in a valueless by exception state.
5554 /// This is different from the standard, which requires a temporary
5555 /// alternative object to be constructed if such construction is not
5556 /// `noexcept` (see [variant.assign] for details). The standard
5557 /// behavior causes unnecessary performance degradation in cases where
5558 /// the alternative constructor does not throw, yet is not marked
5559 /// `noexcept`; this behavior is therefore not implemented in
5560 /// `bsl::variant`. For simplicity of implementation, this method also
5561 /// differs from the standard in the following ways:
5562 /// * `constexpr` is not implemented
5563 /// * `noexcept` specification is not implemented
5564 template <class t_TYPE>
5565 typename bsl::enable_if<
5566 BloombergLP::bslstl::Variant_AssignsFromType<variant, t_TYPE>::value,
5567 variant&>::type
5568 operator=(t_TYPE&& value)
5569 {
5570 // This function template must be defined inline inside the class
5571 // definition, as Microsoft Visual C++ does not recognize the
5572 // definition as matching this signature when placed out-of-line.
5573 const size_t altIndex =
5575
5576 if (index() == altIndex) {
5577 bsl::get<altIndex>(*this) = std::forward<t_TYPE>(value);
5578 }
5579 else {
5580 // 'altIndex' can not be @ref variant_npos if
5581 // 'Variant_AssignsFromType' is satisfied
5582 Variant_Base::template baseEmplace<altIndex>(
5583 std::forward<t_TYPE>(value));
5584 }
5585
5586 return *this;
5587 }
5588#else // BSL_VARIANT_FULL_IMPLEMENTATION
5589 /// If 'rhs' holds the same alternative type as this object, copy assign
5590 /// the contained value of 'rhs' to the contained value of this object.
5591 /// Otherwise, destroy the contained value of this object (if any) and, if
5592 /// 'rhs' holds a value, copy-construct the corresponding alternative of
5593 /// this object from the contained value of 'rhs'. The allocators of this
5594 /// object and 'rhs' both remain unchanged. If the construction of a new
5595 /// alternative object exits via an exception, this 'variant' object is
5596 /// left in a valueless by exception state. All alternatives shall be copy
5597 /// constructible and copy assignable.
5598 variant& operator=(const variant& rhs);
5599
5600 /// If `rhs` holds the same alternative type as this object, move assign
5601 /// the contained value of `rhs` to the contained value of this object.
5602 /// Otherwise, destroy the contained value of this object (if any) and, if
5603 /// `rhs` holds a value, move-construct the corresponding alternative of
5604 /// this object from the contained value of `rhs`. The allocators of this
5605 /// object and `rhs` both remain unchanged. If the construction of a new
5606 /// alternative object throws an exception, this `variant` object is left
5607 /// in a valueless by exception state. All alternatives shall be move
5608 /// constructible and move assignable.
5609 variant& operator=(BloombergLP::bslmf::MovableRef<variant> rhs);
5610
5611 /// Assign to this object the specified `value`. If (template parameter)
5612 /// `t_TYPE` is `bslmf::MovableRef<T>`, then the alternative corresponding
5613 /// to `value` is the one whose type is the same as `T` (modulo
5614 /// cv-qualification); otherwise, the selected alternative is the one that
5615 /// is the same as `t_TYPE` (modulo cv-qualification). This operator
5616 /// participates in overload resolution only if there is a unique such
5617 /// alternative. If this `variant` object already holds that alternative,
5618 /// then the contained value is assigned from `value`; otherwise, any
5619 /// contained value is destroyed and the selected alternative is
5620 /// direct-initialized from `value`. The selected alternative shall be
5621 /// constructible and assignable from `value`. If the construction of a
5622 /// new alternative object exits via an exception, this `variant` object is
5623 /// left in the valueless by exception state.
5624 template <class t_TYPE>
5625 typename bsl::enable_if<
5626 BloombergLP::bslstl::Variant_AssignsFromType<variant, t_TYPE>::value,
5627 variant&>::type
5628 operator=(const t_TYPE& value);
5629
5630#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5631 // 20.7.3.6, swap
5632
5633 /// Efficiently exchange the value of this object with the value of the
5634 /// specified `other` object. This method provides the no-throw
5635 /// exception-safety guarantee if the two swapped objects contain the
5636 /// same alternative and if that alternative `t_TYPE` provides that
5637 /// guarantee. If `*this` and `other` do not have the same active
5638 /// alternative and this method exits via an exception, either or both
5639 /// `variant` objects may be left in a valueless state or with an
5640 /// contained value in a moved-from state.
5641 ///
5642 /// \pre The behavior is undefined unless `*this` has the same allocator as `other`. All alternatives
5643 /// shall be move constructible and swappable. For simplicity of
5644 /// implementation, this method differs from the standard in the
5645 /// following ways:
5646 /// * `constexpr` is not implemented
5647 /// * `noexcept` specification is not implemented
5648 void swap(variant& other);
5649
5650 // ACCESSORS
5651#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5652 template <bool t_USES_BSLMA_ALLOC = BloombergLP::bslstl::
5653 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value,
5654 class = typename bsl::enable_if_t<t_USES_BSLMA_ALLOC> >
5655#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5656 /// Return a copy of this object's allocator. At least one alternative of
5657 /// this `variant` object shall be allocator-aware; in C++03, due to
5658 /// language limitations, this method can be called even if no alternative
5659 /// is allocator-aware, but returns a non-allocator type in that case.
5660 allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
5661 {
5662 // This function template must be defined inline inside the class
5663 // definition, as Microsoft Visual C++ does not recognize the
5664 // definition as matching this signature when placed out-of-line.
5665 return allocator_type(Variant_Base::AllocBase::mechanism());
5666 }
5667
5668 // 20.7.3.5, value status
5669
5670 /// Return the index of the alternative currently managed by this
5671 /// `variant` object, or `bsl::variant_npos` if this object is valueless
5672 /// by exception. This method differs from the standard in the
5673 /// following way:
5674 /// * `constexpr` is not implemented
5675 /// This is because no constructors are currently constexpr and there is no
5676 /// way to test the constexpr property of this function.
5678
5679 /// Return `false` if there is an alternative object currently managed
5680 /// by this `variant` object, and `true` otherwise. A `variant` object
5681 /// can become valueless by exception if the creation of an alternative
5682 /// object exits via an exception, or if it is copied or assigned from
5683 /// another `variant` object that is valueless by exception. This
5684 /// method differs from the standard in the following way:
5685 /// * `constexpr` is not implemented
5686 /// This is because no constructors are currently constexpr and there is no
5687 /// way to test the constexpr property of this function.
5688 bool valueless_by_exception() const BSLS_KEYWORD_NOEXCEPT;
5689};
5690
5691#endif
5692
5693} // close namespace bsl
5694
5695// ============================================================================
5696// INLINE DEFINITIONS
5697// ============================================================================
5698
5699
5700namespace bslstl {
5701
5702 // ---------------------
5703 // class Variant_ImpUtil
5704 // ---------------------
5705
5706template <class t_RET, class t_VARIANT_UNION>
5707t_RET& Variant_ImpUtil::getAlternative(
5709 t_VARIANT_UNION& variantUnion) BSLS_KEYWORD_NOEXCEPT
5710{
5711 return variantUnion.d_head.value();
5712}
5713
5714template <class t_RET, size_t t_INDEX, class t_VARIANT_UNION>
5715t_RET& Variant_ImpUtil::getAlternative(
5717 t_VARIANT_UNION& variantUnion) BSLS_KEYWORD_NOEXCEPT
5718{
5719 return getAlternative<t_RET>(bsl::in_place_index_t<t_INDEX - 1>(),
5720 variantUnion.d_tail);
5721}
5722
5723template <class t_RET, size_t t_INDEX, class t_VARIANT>
5724t_RET& Variant_ImpUtil::get(t_VARIANT& variant)
5725{
5726 if (variant.index() != t_INDEX) {
5727 BSLS_THROW(bsl::bad_variant_access());
5728 }
5729
5730 return getAlternative<t_RET>(bsl::in_place_index_t<t_INDEX>(),
5731 variant.d_union);
5732}
5733
5734template <class t_RET, size_t t_INDEX, class t_VARIANT>
5735t_RET& Variant_ImpUtil::get(const t_VARIANT& variant)
5736{
5737 if (variant.index() != t_INDEX) {
5738 BSLS_THROW(bsl::bad_variant_access());
5739 }
5740
5741 return getAlternative<t_RET>(bsl::in_place_index_t<t_INDEX>(),
5742 variant.d_union);
5743}
5744
5745#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5746template <class t_RET, class t_VISITOR, class t_VARIANT>
5747t_RET Variant_ImpUtil::visit(t_VISITOR&& visitor, t_VARIANT&& variant)
5748{
5749 static constexpr size_t varSize =
5751
5752 typedef typename Variant_VTable<
5753 t_RET,
5754 t_VISITOR&&,
5755 t_VARIANT&&,
5756 bslmf::MakeIntegerSequence<std::size_t, varSize> >::FuncPtr FuncPtr;
5757
5758 // Generate the table of all function pointers for 't_VISITOR' and
5759 // 't_VARIANT', then invoke the one corresponding to the active index.
5760 FuncPtr funcPtr =
5761 Variant_VTable<t_RET,
5762 t_VISITOR&&,
5763 t_VARIANT&&,
5764 bslmf::MakeIntegerSequence<std::size_t, varSize> >::
5765 s_map[variant.index()];
5766
5767 return (*funcPtr)(std::forward<t_VISITOR>(visitor),
5768 std::forward<t_VARIANT>(variant));
5769}
5770template <class t_RET, class t_VISITOR, class t_VARIANT>
5771t_RET Variant_ImpUtil::visitId(t_VISITOR&& visitor, t_VARIANT&& variant)
5772{
5773 static constexpr size_t varSize =
5775
5776 typedef typename Variant_VTableId<
5777 t_RET,
5778 t_VISITOR&&,
5779 t_VARIANT&&,
5780 bslmf::MakeIntegerSequence<std::size_t, varSize> >::FuncPtr FuncPtr;
5781
5782 FuncPtr funcPtr =
5783 Variant_VTableId<t_RET,
5784 t_VISITOR&&,
5785 t_VARIANT&&,
5786 bslmf::MakeIntegerSequence<std::size_t, varSize> >::
5787 s_mapId[variant.index()];
5788
5789 return (*funcPtr)(std::forward<t_VISITOR>(visitor),
5790 std::forward<t_VARIANT>(variant));
5791}
5792
5793#else
5794template <class t_RET, size_t t_INDEX, class t_VARIANT>
5795t_RET& Variant_ImpUtil::unsafeGet(t_VARIANT& variant)
5796{
5797 return getAlternative<t_RET>(bsl::in_place_index_t<t_INDEX>(),
5798 variant.d_union);
5799}
5800
5801template <class t_RET, size_t t_INDEX, class t_VARIANT>
5802t_RET& Variant_ImpUtil::unsafeGet(const t_VARIANT& variant)
5803{
5804 return getAlternative<t_RET>(bsl::in_place_index_t<t_INDEX>(),
5805 variant.d_union);
5806}
5807
5808template <class t_TYPE, class t_VARIANT>
5809t_TYPE& Variant_ImpUtil::unsafeGet(t_VARIANT& obj)
5810{
5811 return unsafeGet<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
5812 obj);
5813}
5814
5815template <class t_TYPE, class t_VARIANT>
5816const t_TYPE& Variant_ImpUtil::unsafeGet(const t_VARIANT& obj)
5817{
5818 return unsafeGet<const t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
5819 obj);
5820}
5821
5822template <class t_RET, class t_VISITOR, class t_VARIANT>
5823t_RET Variant_ImpUtil::visit(t_VISITOR& visitor, t_VARIANT& variant)
5824{
5825 typedef
5827
5828 // Generate the table of all function pointers for 't_VISITOR' and
5829 // 't_VARIANT', then invoke the one corresponding to the active index.
5830 FuncPtr funcPtr =
5832
5833 return (*funcPtr)(visitor, variant);
5834}
5835
5836template <class t_RET, class t_VISITOR, class t_VARIANT>
5837t_RET Variant_ImpUtil::visit(t_VISITOR& visitor, const t_VARIANT& variant)
5838{
5840 FuncPtr;
5841
5842 // Generate the table of all function pointers for 't_VISITOR' and
5843 // 't_VARIANT', then invoke the one corresponding to the active index.
5844 FuncPtr funcPtr =
5846 .index()];
5847
5848 return (*funcPtr)(visitor, variant);
5849}
5850
5851template <class t_RET, class t_VISITOR, class t_VARIANT>
5852t_RET Variant_ImpUtil::moveVisit(t_VISITOR& visitor, t_VARIANT& variant)
5853{
5854 typedef
5856
5857 // Generate the table of all function pointers for 't_VISITOR' and
5858 // 't_VARIANT', then invoke the one corresponding to the active index.
5859 FuncPtr funcPtr =
5861 .index()];
5862
5863 return (*funcPtr)(visitor, variant);
5864}
5865
5866// The visitation functions below are the same as the ones above except that
5867// the visitor is invoked with an additional argument of type
5868// 'bsl::in_place_index_t'. They are used internally for visitors that
5869// participate in the 'variant' implementation.
5870template <class t_RET, class t_VISITOR, class t_VARIANT>
5871t_RET Variant_ImpUtil::visitId(t_VISITOR& visitor, t_VARIANT& variant)
5872{
5873 typedef
5875
5876 FuncPtr funcPtr =
5878
5879 return (*funcPtr)(visitor, variant);
5880}
5881
5882template <class t_RET, class t_VISITOR, class t_VARIANT>
5883t_RET Variant_ImpUtil::visitId(t_VISITOR& visitor, const t_VARIANT& variant)
5884{
5886 FuncPtr;
5887
5889 mapId()[variant.index()];
5890
5891 return (*funcPtr)(visitor, variant);
5892}
5893
5894#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5895
5896#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
5897 // ----------------------------------------------
5898 // class Variant_ImpUtil::ConstructFromStdVisitor
5899 // ----------------------------------------------
5900
5901template <class t_VARIANT, class t_STD_VARIANT>
5902Variant_ImpUtil::ConstructFromStdVisitor<t_VARIANT, t_STD_VARIANT>::
5903 ConstructFromStdVisitor(t_VARIANT& target, t_STD_VARIANT& original)
5904: d_target(target)
5905, d_original(original)
5906{
5907}
5908
5909template <class t_VARIANT, class t_STD_VARIANT>
5910template <size_t t_INDEX, class t_TYPE>
5911void
5912Variant_ImpUtil::ConstructFromStdVisitor<t_VARIANT, t_STD_VARIANT>::
5913 operator()(bsl::in_place_index_t<t_INDEX>, t_TYPE&) const
5914{
5915 // Implementation note: calling the correct overload of 'operator()' is
5916 // made possible only by the fact that we have set 'd_target.d_type' to
5917 // 'd_original.index()' prior to invoking the visitor. But we must now use
5918 // private access to 'd_target' to set the index to -1 before we call
5919 // 'baseEmplace' (otherwise, 'baseEmplace' would attempt to destroy the
5920 // alternative first before constructing a new one).
5921
5922 d_target.d_type = bsl::variant_npos;
5923 d_target.template baseEmplace<t_INDEX>(
5924 std::get<t_INDEX>(std::forward<t_STD_VARIANT>(d_original)));
5925}
5926#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
5927
5928 // ------------------------
5929 // class Variant_NoSuchType
5930 // ------------------------
5931
5932// CREATORS
5933inline
5938
5939 // ---------------------
5940 // class Variant_DataImp
5941 // ---------------------
5942
5943#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5944// CREATORS
5945template <class t_TYPE>
5946template <class... t_ARGS>
5947inline
5949{
5950 BloombergLP::bslma::ConstructionUtil::construct(
5951 d_buffer.address(), std::forward<t_ARGS>(args)...);
5952}
5953#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5954
5955// MANIPULATORS
5956#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5957template <class t_TYPE>
5958inline
5960{
5961 return d_buffer.object();
5962}
5963
5964template <class t_TYPE>
5965inline
5967{
5968 return std::move(d_buffer.object());
5969}
5970#else // BSL_VARIANT_FULL_IMPLEMENTATION
5971template <class t_TYPE>
5972inline
5974{
5975 return d_buffer.object();
5976}
5977#endif // BSL_VARIANT_FULL_IMPLEMENTATION
5978
5979// ACCESSORS
5980#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
5981template <class t_TYPE>
5982inline
5984const&
5985{
5986 return d_buffer.object();
5987}
5988
5989template <class t_TYPE>
5990inline
5992const&&
5993{
5994 return std::move(d_buffer.object());
5995}
5996#else // BSL_VARIANT_FULL_IMPLEMENTATION
5997template <class t_TYPE>
5998inline
6000{
6001 return d_buffer.object();
6002}
6003#endif // BSL_VARIANT_FULL_IMPLEMENTATION
6004
6005/// This component-private function swaps the values of the specified `lhs`
6006/// and `rhs` when the type (template parameter) `t_VARIANT` is an
6007/// allocator-aware variant.
6008template <class t_VARIANT>
6009void variant_swapImpl(bsl::true_type, t_VARIANT& lhs, t_VARIANT& rhs)
6010{
6011 if (lhs.get_allocator() == rhs.get_allocator()) {
6012 lhs.swap(rhs);
6013 return; // RETURN
6014 }
6015
6016 t_VARIANT futureLhs(bsl::allocator_arg, lhs.get_allocator(), rhs);
6017 t_VARIANT futureRhs(bsl::allocator_arg, rhs.get_allocator(), lhs);
6018
6019 futureLhs.swap(lhs);
6020 futureRhs.swap(rhs);
6021}
6022
6023/// This component-private function swaps the values of the specified `lhs`
6024/// and `rhs` when the type (template parameter) `t_VARIANT` is a
6025/// non-allocator-aware variant.
6026template <class t_VARIANT>
6027void variant_swapImpl(bsl::false_type, t_VARIANT& lhs, t_VARIANT& rhs)
6028{
6029 lhs.swap(rhs);
6030}
6031
6032 // -------------------
6033 // struct Variant_Base
6034 // -------------------
6035
6036// CREATORS
6037#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
6038template <class t_HEAD, class... t_TAIL>
6039inline
6041: AllocBase()
6042, d_type(0)
6043, d_union(bsl::in_place_index_t<0>(), AllocBase::mechanism())
6044{
6045}
6046
6047template <class t_HEAD, class... t_TAIL>
6048inline
6049Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(const Variant_Base& original)
6050: AllocBase()
6051, d_type(bsl::variant_npos)
6052{
6053 if (original.d_type != bsl::variant_npos) {
6054 BloombergLP::bslstl::Variant_CopyConstructVisitor<Variant_Base>
6055 copyConstructor(this);
6057 void, copyConstructor, static_cast<const Variant&>(original));
6058 }
6059}
6060
6061template <class t_HEAD, class... t_TAIL>
6062inline
6063Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(Variant_Base&& original)
6064: AllocBase(original)
6065, d_type(bsl::variant_npos)
6066{
6067 if (original.d_type != bsl::variant_npos) {
6068 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
6069 moveConstructor(this);
6071 void, moveConstructor, static_cast<Variant&>(original));
6072 }
6073}
6074
6075#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
6076template <class t_HEAD, class... t_TAIL>
6077Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(Variant_ConstructFromStdTag,
6078 size_t index)
6079: AllocBase()
6080, d_type(index)
6081{
6082}
6083#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
6084
6085template <class t_HEAD, class... t_TAIL>
6086inline
6087Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::allocator_arg_t,
6088 allocator_type allocator)
6089: AllocBase(allocator)
6090, d_type(0)
6091, d_union(bsl::in_place_index_t<0>(), AllocBase::mechanism())
6092{
6093}
6094
6095template <class t_HEAD, class... t_TAIL>
6096inline
6097Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::allocator_arg_t,
6098 allocator_type allocator,
6099 const Variant& original)
6100: AllocBase(allocator)
6101, d_type(bsl::variant_npos)
6102{
6103 if (original.index() != bsl::variant_npos) {
6104 BloombergLP::bslstl::Variant_CopyConstructVisitor<Variant_Base>
6105 copyConstructor(this);
6106 BSLSTL_VARIANT_VISITID(void, copyConstructor, original);
6107 }
6108}
6109
6110template <class t_HEAD, class... t_TAIL>
6111inline
6112Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::allocator_arg_t,
6113 allocator_type allocator,
6114 Variant&& original)
6115: AllocBase(allocator)
6116, d_type(bsl::variant_npos)
6117{
6118 if (original.index() != bsl::variant_npos) {
6119 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
6120 moveConstructor(this);
6121 BSLSTL_VARIANT_VISITID(void, moveConstructor, original);
6122 }
6123}
6124
6125#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
6126template <class t_HEAD, class... t_TAIL>
6127Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::allocator_arg_t,
6128 allocator_type allocator,
6129 Variant_ConstructFromStdTag,
6130 size_t index)
6131: AllocBase(allocator)
6132, d_type(index)
6133{
6134}
6135#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
6136
6137template <class t_HEAD, class... t_TAIL>
6138template <size_t t_INDEX, class... t_ARGS>
6139inline
6140Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::in_place_index_t<t_INDEX>,
6141 t_ARGS&&... args)
6142: d_type(t_INDEX)
6143, d_union(bsl::in_place_index_t<t_INDEX>(),
6144 AllocBase::mechanism(),
6145 std::forward<t_ARGS>(args)...)
6146{
6147}
6148
6149template <class t_HEAD, class... t_TAIL>
6150template <size_t t_INDEX, class... t_ARGS>
6151inline
6152Variant_Base<t_HEAD, t_TAIL...>::Variant_Base(bsl::allocator_arg_t,
6153 allocator_type allocator,
6155 t_ARGS&&... args)
6156: AllocBase(allocator)
6157, d_type(t_INDEX)
6158, d_union(bsl::in_place_index_t<t_INDEX>(),
6159 AllocBase::mechanism(),
6160 std::forward<t_ARGS>(args)...)
6161{
6162}
6163#else // BSL_VARIANT_FULL_IMPLEMENTATION
6164#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6165template <class t_HEAD, class... t_TAIL>
6166inline
6168: AllocBase()
6169, d_type(0)
6170{
6171 typedef typename bsl::remove_cv<t_HEAD>::type Alt_Type;
6172
6173 BloombergLP::bslma::ConstructionUtil::construct(
6174 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6175 AllocBase::mechanism());
6176}
6177
6178template <class t_HEAD, class... t_TAIL>
6179inline
6181: AllocBase()
6182, d_type(bsl::variant_npos)
6183{
6184 if (!original.valueless_by_exception()) {
6185 BloombergLP::bslstl::Variant_CopyConstructVisitor<Variant_Base>
6186 copyConstructor(this);
6187 BSLSTL_VARIANT_VISITID(void, copyConstructor, original);
6188 // In C++03, if there are nonunique alternatives,
6189 // 'BSLSTL_VARIANT_VISITID' will always use the first nonunique
6190 // alternative, which may result in the wrong 'd_type' being set.
6191 d_type = original.d_type;
6192 }
6193}
6194
6195template <class t_HEAD, class... t_TAIL>
6196inline
6198 BloombergLP::bslmf::MovableRef<Variant> original)
6199: AllocBase(MoveUtil::access(original))
6200, d_type(bsl::variant_npos)
6201{
6202 Variant& lvalue = original;
6203 if (!lvalue.valueless_by_exception()) {
6204 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
6205 moveConstructor(this);
6206 BSLSTL_VARIANT_VISITID(void, moveConstructor, lvalue);
6207 // In C++03, if there are nonunique alternatives,
6208 // 'BSLSTL_VARIANT_VISITID' will always use the first nonunique
6209 // alternative, which may result in the wrong 'd_type' being set.
6210 d_type = lvalue.d_type;
6211 }
6212}
6213
6214template <class t_HEAD, class... t_TAIL>
6215template <size_t t_INDEX>
6216inline
6218: AllocBase()
6219, d_type(t_INDEX)
6220{
6221 typedef typename bsl::remove_cv<
6223 Alt_Type;
6224
6225 BloombergLP::bslma::ConstructionUtil::construct(
6226 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6227 AllocBase::mechanism());
6228}
6229
6230template <class t_HEAD, class... t_TAIL>
6231template <size_t t_INDEX, class t_ARG_01>
6232inline
6235 const t_ARG_01& arg_01)
6236: AllocBase()
6237, d_type(t_INDEX)
6238{
6239 typedef typename bsl::remove_cv<
6241 Alt_Type;
6242
6243 BloombergLP::bslma::ConstructionUtil::construct(
6244 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6245 AllocBase::mechanism(),
6246 arg_01);
6247}
6248
6249template <class t_HEAD, class... t_TAIL>
6250template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
6251inline
6254 const t_ARG_01& arg_01,
6255 const t_ARG_02& arg_02)
6256: AllocBase()
6257, d_type(t_INDEX)
6258{
6259 typedef typename bsl::remove_cv<
6261 Alt_Type;
6262
6263 BloombergLP::bslma::ConstructionUtil::construct(
6264 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6265 AllocBase::mechanism(),
6266 arg_01,
6267 arg_02);
6268}
6269
6270template <class t_HEAD, class... t_TAIL>
6271template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
6272inline
6275 const t_ARG_01& arg_01,
6276 const t_ARG_02& arg_02,
6277 const t_ARG_03& arg_03)
6278: AllocBase()
6279, d_type(t_INDEX)
6280{
6281 typedef typename bsl::remove_cv<
6283 Alt_Type;
6284
6285 BloombergLP::bslma::ConstructionUtil::construct(
6286 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6287 AllocBase::mechanism(),
6288 arg_01,
6289 arg_02,
6290 arg_03);
6291}
6292
6293template <class t_HEAD, class... t_TAIL>
6294template <size_t t_INDEX,
6295 class t_ARG_01,
6296 class t_ARG_02,
6297 class t_ARG_03,
6298 class t_ARG_04>
6299inline
6301 const t_ARG_01& arg_01,
6302 const t_ARG_02& arg_02,
6303 const t_ARG_03& arg_03,
6304 const t_ARG_04& arg_04)
6305: AllocBase()
6306, d_type(t_INDEX)
6307{
6308 typedef typename bsl::remove_cv<
6310 Alt_Type;
6311
6312 BloombergLP::bslma::ConstructionUtil::construct(
6313 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6314 AllocBase::mechanism(),
6315 arg_01,
6316 arg_02,
6317 arg_03,
6318 arg_04);
6319}
6320
6321template <class t_HEAD, class... t_TAIL>
6322template <size_t t_INDEX,
6323 class t_ARG_01,
6324 class t_ARG_02,
6325 class t_ARG_03,
6326 class t_ARG_04,
6327 class t_ARG_05>
6328inline
6330 const t_ARG_01& arg_01,
6331 const t_ARG_02& arg_02,
6332 const t_ARG_03& arg_03,
6333 const t_ARG_04& arg_04,
6334 const t_ARG_05& arg_05)
6335: AllocBase()
6336, d_type(t_INDEX)
6337{
6338 typedef typename bsl::remove_cv<
6340 Alt_Type;
6341
6342 BloombergLP::bslma::ConstructionUtil::construct(
6343 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6344 AllocBase::mechanism(),
6345 arg_01,
6346 arg_02,
6347 arg_03,
6348 arg_04,
6349 arg_05);
6350}
6351
6352template <class t_HEAD, class... t_TAIL>
6353template <size_t t_INDEX,
6354 class t_ARG_01,
6355 class t_ARG_02,
6356 class t_ARG_03,
6357 class t_ARG_04,
6358 class t_ARG_05,
6359 class t_ARG_06>
6360inline
6362 const t_ARG_01& arg_01,
6363 const t_ARG_02& arg_02,
6364 const t_ARG_03& arg_03,
6365 const t_ARG_04& arg_04,
6366 const t_ARG_05& arg_05,
6367 const t_ARG_06& arg_06)
6368: AllocBase()
6369, d_type(t_INDEX)
6370{
6371 typedef typename bsl::remove_cv<
6373 Alt_Type;
6374
6375 BloombergLP::bslma::ConstructionUtil::construct(
6376 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6377 AllocBase::mechanism(),
6378 arg_01,
6379 arg_02,
6380 arg_03,
6381 arg_04,
6382 arg_05,
6383 arg_06);
6384}
6385
6386template <class t_HEAD, class... t_TAIL>
6387template <size_t t_INDEX,
6388 class t_ARG_01,
6389 class t_ARG_02,
6390 class t_ARG_03,
6391 class t_ARG_04,
6392 class t_ARG_05,
6393 class t_ARG_06,
6394 class t_ARG_07>
6395inline
6397 const t_ARG_01& arg_01,
6398 const t_ARG_02& arg_02,
6399 const t_ARG_03& arg_03,
6400 const t_ARG_04& arg_04,
6401 const t_ARG_05& arg_05,
6402 const t_ARG_06& arg_06,
6403 const t_ARG_07& arg_07)
6404: AllocBase()
6405, d_type(t_INDEX)
6406{
6407 typedef typename bsl::remove_cv<
6409 Alt_Type;
6410
6411 BloombergLP::bslma::ConstructionUtil::construct(
6412 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6413 AllocBase::mechanism(),
6414 arg_01,
6415 arg_02,
6416 arg_03,
6417 arg_04,
6418 arg_05,
6419 arg_06,
6420 arg_07);
6421}
6422
6423template <class t_HEAD, class... t_TAIL>
6424template <size_t t_INDEX,
6425 class t_ARG_01,
6426 class t_ARG_02,
6427 class t_ARG_03,
6428 class t_ARG_04,
6429 class t_ARG_05,
6430 class t_ARG_06,
6431 class t_ARG_07,
6432 class t_ARG_08>
6433inline
6435 const t_ARG_01& arg_01,
6436 const t_ARG_02& arg_02,
6437 const t_ARG_03& arg_03,
6438 const t_ARG_04& arg_04,
6439 const t_ARG_05& arg_05,
6440 const t_ARG_06& arg_06,
6441 const t_ARG_07& arg_07,
6442 const t_ARG_08& arg_08)
6443: AllocBase()
6444, d_type(t_INDEX)
6445{
6446 typedef typename bsl::remove_cv<
6448 Alt_Type;
6449
6450 BloombergLP::bslma::ConstructionUtil::construct(
6451 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6452 AllocBase::mechanism(),
6453 arg_01,
6454 arg_02,
6455 arg_03,
6456 arg_04,
6457 arg_05,
6458 arg_06,
6459 arg_07,
6460 arg_08);
6461}
6462
6463template <class t_HEAD, class... t_TAIL>
6464template <size_t t_INDEX,
6465 class t_ARG_01,
6466 class t_ARG_02,
6467 class t_ARG_03,
6468 class t_ARG_04,
6469 class t_ARG_05,
6470 class t_ARG_06,
6471 class t_ARG_07,
6472 class t_ARG_08,
6473 class t_ARG_09>
6474inline
6476 const t_ARG_01& arg_01,
6477 const t_ARG_02& arg_02,
6478 const t_ARG_03& arg_03,
6479 const t_ARG_04& arg_04,
6480 const t_ARG_05& arg_05,
6481 const t_ARG_06& arg_06,
6482 const t_ARG_07& arg_07,
6483 const t_ARG_08& arg_08,
6484 const t_ARG_09& arg_09)
6485: AllocBase()
6486, d_type(t_INDEX)
6487{
6488 typedef typename bsl::remove_cv<
6490 Alt_Type;
6491
6492 BloombergLP::bslma::ConstructionUtil::construct(
6493 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6494 AllocBase::mechanism(),
6495 arg_01,
6496 arg_02,
6497 arg_03,
6498 arg_04,
6499 arg_05,
6500 arg_06,
6501 arg_07,
6502 arg_08,
6503 arg_09);
6504}
6505
6506template <class t_HEAD, class... t_TAIL>
6507template <size_t t_INDEX,
6508 class t_ARG_01,
6509 class t_ARG_02,
6510 class t_ARG_03,
6511 class t_ARG_04,
6512 class t_ARG_05,
6513 class t_ARG_06,
6514 class t_ARG_07,
6515 class t_ARG_08,
6516 class t_ARG_09,
6517 class t_ARG_10>
6518inline
6520 const t_ARG_01& arg_01,
6521 const t_ARG_02& arg_02,
6522 const t_ARG_03& arg_03,
6523 const t_ARG_04& arg_04,
6524 const t_ARG_05& arg_05,
6525 const t_ARG_06& arg_06,
6526 const t_ARG_07& arg_07,
6527 const t_ARG_08& arg_08,
6528 const t_ARG_09& arg_09,
6529 const t_ARG_10& arg_10)
6530: AllocBase()
6531, d_type(t_INDEX)
6532{
6533 typedef typename bsl::remove_cv<
6535 Alt_Type;
6536
6537 BloombergLP::bslma::ConstructionUtil::construct(
6538 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6539 AllocBase::mechanism(),
6540 arg_01,
6541 arg_02,
6542 arg_03,
6543 arg_04,
6544 arg_05,
6545 arg_06,
6546 arg_07,
6547 arg_08,
6548 arg_09,
6549 arg_10);
6550}
6551
6552template <class t_HEAD, class... t_TAIL>
6553inline
6555 allocator_type allocator)
6556: AllocBase(allocator)
6557, d_type(0)
6558{
6559 BloombergLP::bslma::ConstructionUtil::construct(
6560 reinterpret_cast<t_HEAD *>(BSLS_UTIL_ADDRESSOF(d_union)),
6561 AllocBase::mechanism());
6562}
6563
6564template <class t_HEAD, class... t_TAIL>
6565inline
6567 allocator_type allocator,
6568 const Variant& original)
6569: AllocBase(allocator)
6570, d_type(bsl::variant_npos)
6571{
6572 if (!original.valueless_by_exception()) {
6573 BloombergLP::bslstl::Variant_CopyConstructVisitor<Variant_Base>
6574 copyConstructor(this);
6575 BSLSTL_VARIANT_VISITID(void, copyConstructor, original);
6576
6577 // In C++03, if there are nonunique alternatives,
6578 // 'BSLSTL_VARIANT_VISITID' will always use the first nonunique
6579 // alternative, which may result in the wrong 'd_type' being set.
6580 d_type = original.d_type;
6581 }
6582}
6583
6584template <class t_HEAD, class... t_TAIL>
6585inline
6588 allocator_type allocator,
6589 BloombergLP::bslmf::MovableRef<Variant> original)
6590: AllocBase(allocator)
6591, d_type(bsl::variant_npos)
6592{
6593 Variant& lvalue = original;
6594 if (!lvalue.valueless_by_exception()) {
6595 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
6596 moveConstructor(this);
6597 BSLSTL_VARIANT_VISITID(void, moveConstructor, lvalue);
6598
6599 // In C++03, if there are nonunique alternatives,
6600 // 'BSLSTL_VARIANT_VISITID' will always use the first nonunique
6601 // alternative, which may result in the wrong 'd_type' being set.
6602 d_type = lvalue.d_type;
6603 }
6604}
6605
6606template <class t_HEAD, class... t_TAIL>
6607template <size_t t_INDEX>
6608inline
6611 allocator_type allocator,
6613: AllocBase(allocator)
6614, d_type(t_INDEX)
6615{
6616 typedef typename bsl::remove_cv<
6618 Alt_Type;
6619
6620 BloombergLP::bslma::ConstructionUtil::construct(
6621 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6622 AllocBase::mechanism());
6623}
6624
6625template <class t_HEAD, class... t_TAIL>
6626template <size_t t_INDEX, class t_ARG_01>
6627inline
6630 allocator_type allocator,
6632 const t_ARG_01& arg_01)
6633: AllocBase(allocator)
6634, d_type(t_INDEX)
6635{
6636 typedef typename bsl::remove_cv<
6638 Alt_Type;
6639
6640 BloombergLP::bslma::ConstructionUtil::construct(
6641 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6642 AllocBase::mechanism(),
6643 arg_01);
6644}
6645
6646template <class t_HEAD, class... t_TAIL>
6647template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
6648inline
6651 allocator_type allocator,
6653 const t_ARG_01& arg_01,
6654 const t_ARG_02& arg_02)
6655: AllocBase(allocator)
6656, d_type(t_INDEX)
6657{
6658 typedef typename bsl::remove_cv<
6660 Alt_Type;
6661
6662 BloombergLP::bslma::ConstructionUtil::construct(
6663 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6664 AllocBase::mechanism(),
6665 arg_01,
6666 arg_02);
6667}
6668
6669template <class t_HEAD, class... t_TAIL>
6670template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
6671inline
6674 allocator_type allocator,
6676 const t_ARG_01& arg_01,
6677 const t_ARG_02& arg_02,
6678 const t_ARG_03& arg_03)
6679: AllocBase(allocator)
6680, d_type(t_INDEX)
6681{
6682 typedef typename bsl::remove_cv<
6684 Alt_Type;
6685
6686 BloombergLP::bslma::ConstructionUtil::construct(
6687 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6688 AllocBase::mechanism(),
6689 arg_01,
6690 arg_02,
6691 arg_03);
6692}
6693
6694template <class t_HEAD, class... t_TAIL>
6695template <size_t t_INDEX,
6696 class t_ARG_01,
6697 class t_ARG_02,
6698 class t_ARG_03,
6699 class t_ARG_04>
6700inline
6702 allocator_type allocator,
6704 const t_ARG_01& arg_01,
6705 const t_ARG_02& arg_02,
6706 const t_ARG_03& arg_03,
6707 const t_ARG_04& arg_04)
6708: AllocBase(allocator)
6709, d_type(t_INDEX)
6710{
6711 typedef typename bsl::remove_cv<
6713 Alt_Type;
6714
6715 BloombergLP::bslma::ConstructionUtil::construct(
6716 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6717 AllocBase::mechanism(),
6718 arg_01,
6719 arg_02,
6720 arg_03,
6721 arg_04);
6722}
6723
6724template <class t_HEAD, class... t_TAIL>
6725template <size_t t_INDEX,
6726 class t_ARG_01,
6727 class t_ARG_02,
6728 class t_ARG_03,
6729 class t_ARG_04,
6730 class t_ARG_05>
6731inline
6733 allocator_type allocator,
6735 const t_ARG_01& arg_01,
6736 const t_ARG_02& arg_02,
6737 const t_ARG_03& arg_03,
6738 const t_ARG_04& arg_04,
6739 const t_ARG_05& arg_05)
6740: AllocBase(allocator)
6741, d_type(t_INDEX)
6742{
6743 typedef typename bsl::remove_cv<
6745 Alt_Type;
6746
6747 BloombergLP::bslma::ConstructionUtil::construct(
6748 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6749 AllocBase::mechanism(),
6750 arg_01,
6751 arg_02,
6752 arg_03,
6753 arg_04,
6754 arg_05);
6755}
6756
6757template <class t_HEAD, class... t_TAIL>
6758template <size_t t_INDEX,
6759 class t_ARG_01,
6760 class t_ARG_02,
6761 class t_ARG_03,
6762 class t_ARG_04,
6763 class t_ARG_05,
6764 class t_ARG_06>
6765inline
6767 allocator_type allocator,
6769 const t_ARG_01& arg_01,
6770 const t_ARG_02& arg_02,
6771 const t_ARG_03& arg_03,
6772 const t_ARG_04& arg_04,
6773 const t_ARG_05& arg_05,
6774 const t_ARG_06& arg_06)
6775: AllocBase(allocator)
6776, d_type(t_INDEX)
6777{
6778 typedef typename bsl::remove_cv<
6780 Alt_Type;
6781
6782 BloombergLP::bslma::ConstructionUtil::construct(
6783 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6784 AllocBase::mechanism(),
6785 arg_01,
6786 arg_02,
6787 arg_03,
6788 arg_04,
6789 arg_05,
6790 arg_06);
6791}
6792
6793template <class t_HEAD, class... t_TAIL>
6794template <size_t t_INDEX,
6795 class t_ARG_01,
6796 class t_ARG_02,
6797 class t_ARG_03,
6798 class t_ARG_04,
6799 class t_ARG_05,
6800 class t_ARG_06,
6801 class t_ARG_07>
6802inline
6804 allocator_type allocator,
6806 const t_ARG_01& arg_01,
6807 const t_ARG_02& arg_02,
6808 const t_ARG_03& arg_03,
6809 const t_ARG_04& arg_04,
6810 const t_ARG_05& arg_05,
6811 const t_ARG_06& arg_06,
6812 const t_ARG_07& arg_07)
6813: AllocBase(allocator)
6814, d_type(t_INDEX)
6815{
6816 typedef typename bsl::remove_cv<
6818 Alt_Type;
6819
6820 BloombergLP::bslma::ConstructionUtil::construct(
6821 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6822 AllocBase::mechanism(),
6823 arg_01,
6824 arg_02,
6825 arg_03,
6826 arg_04,
6827 arg_05,
6828 arg_06,
6829 arg_07);
6830}
6831
6832template <class t_HEAD, class... t_TAIL>
6833template <size_t t_INDEX,
6834 class t_ARG_01,
6835 class t_ARG_02,
6836 class t_ARG_03,
6837 class t_ARG_04,
6838 class t_ARG_05,
6839 class t_ARG_06,
6840 class t_ARG_07,
6841 class t_ARG_08>
6842inline
6844 allocator_type allocator,
6846 const t_ARG_01& arg_01,
6847 const t_ARG_02& arg_02,
6848 const t_ARG_03& arg_03,
6849 const t_ARG_04& arg_04,
6850 const t_ARG_05& arg_05,
6851 const t_ARG_06& arg_06,
6852 const t_ARG_07& arg_07,
6853 const t_ARG_08& arg_08)
6854: AllocBase(allocator)
6855, d_type(t_INDEX)
6856{
6857 typedef typename bsl::remove_cv<
6859 Alt_Type;
6860
6861 BloombergLP::bslma::ConstructionUtil::construct(
6862 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6863 AllocBase::mechanism(),
6864 arg_01,
6865 arg_02,
6866 arg_03,
6867 arg_04,
6868 arg_05,
6869 arg_06,
6870 arg_07,
6871 arg_08);
6872}
6873
6874template <class t_HEAD, class... t_TAIL>
6875template <size_t t_INDEX,
6876 class t_ARG_01,
6877 class t_ARG_02,
6878 class t_ARG_03,
6879 class t_ARG_04,
6880 class t_ARG_05,
6881 class t_ARG_06,
6882 class t_ARG_07,
6883 class t_ARG_08,
6884 class t_ARG_09>
6885inline
6887 allocator_type allocator,
6889 const t_ARG_01& arg_01,
6890 const t_ARG_02& arg_02,
6891 const t_ARG_03& arg_03,
6892 const t_ARG_04& arg_04,
6893 const t_ARG_05& arg_05,
6894 const t_ARG_06& arg_06,
6895 const t_ARG_07& arg_07,
6896 const t_ARG_08& arg_08,
6897 const t_ARG_09& arg_09)
6898: AllocBase(allocator)
6899, d_type(t_INDEX)
6900{
6901 typedef typename bsl::remove_cv<
6903 Alt_Type;
6904
6905 BloombergLP::bslma::ConstructionUtil::construct(
6906 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6907 AllocBase::mechanism(),
6908 arg_01,
6909 arg_02,
6910 arg_03,
6911 arg_04,
6912 arg_05,
6913 arg_06,
6914 arg_07,
6915 arg_08,
6916 arg_09);
6917}
6918
6919template <class t_HEAD, class... t_TAIL>
6920template <size_t t_INDEX,
6921 class t_ARG_01,
6922 class t_ARG_02,
6923 class t_ARG_03,
6924 class t_ARG_04,
6925 class t_ARG_05,
6926 class t_ARG_06,
6927 class t_ARG_07,
6928 class t_ARG_08,
6929 class t_ARG_09,
6930 class t_ARG_10>
6931inline
6933 allocator_type allocator,
6935 const t_ARG_01& arg_01,
6936 const t_ARG_02& arg_02,
6937 const t_ARG_03& arg_03,
6938 const t_ARG_04& arg_04,
6939 const t_ARG_05& arg_05,
6940 const t_ARG_06& arg_06,
6941 const t_ARG_07& arg_07,
6942 const t_ARG_08& arg_08,
6943 const t_ARG_09& arg_09,
6944 const t_ARG_10& arg_10)
6945: AllocBase(allocator)
6946, d_type(t_INDEX)
6947{
6948 typedef typename bsl::remove_cv<
6950 Alt_Type;
6951
6952 BloombergLP::bslma::ConstructionUtil::construct(
6953 reinterpret_cast<Alt_Type *>(BSLS_UTIL_ADDRESSOF(d_union)),
6954 AllocBase::mechanism(),
6955 arg_01,
6956 arg_02,
6957 arg_03,
6958 arg_04,
6959 arg_05,
6960 arg_06,
6961 arg_07,
6962 arg_08,
6963 arg_09,
6964 arg_10);
6965}
6966#endif
6967#endif // BSL_VARIANT_FULL_IMPLEMENTATION
6968
6969#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6970template <class t_HEAD, class... t_TAIL>
6975#endif
6976// MANIPULATORS
6977#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
6978template <class t_HEAD, class... t_TAIL>
6979template <size_t t_INDEX, class... t_ARGS>
6981{
6982 reset();
6983
6984 // We need to assemble the construction arguments for the underlying
6985 //'Variant_DataImp' object here. They require that allocator pointer is
6986 // the leading argument after 'Variant_Union' strips the 't_INDEX'. To be
6987 // able to get such argument set, we say that 'Variant_Union' is not
6988 // allocator aware. If we were to have 'Variant_Union' be allocator aware
6989 // and use trailing allocator construction, we wouldn't be able to extract
6990 // the allocator to move it to the right position for the 'Variant_DataImp'
6991 // construct invocation. If we were to have either 'Variant_Union' or
6992 // 'Variant_DataImp' use @ref allocator_arg_t semantics, it wouldn't work for
6993 // the non allocator aware variant where there is no allocator object.
6994 BloombergLP::bslma::ConstructionUtil::construct(
6995 BSLS_UTIL_ADDRESSOF(d_union),
6996 (void *)0,
6998 AllocBase::mechanism(),
6999 std::forward<t_ARGS>(args)...);
7000 d_type = t_INDEX;
7001}
7002
7003#else // BSL_VARIANT_FULL_IMPLEMENTATION
7004#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
7005template <class t_HEAD, class... t_TAIL>
7006template <size_t t_INDEX>
7008{
7009 typedef typename bsl::remove_cv<
7011 Alt_Type;
7012
7013 reset();
7014
7015 BloombergLP::bslma::ConstructionUtil::construct(
7016 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7017 AllocBase::mechanism());
7018 d_type = t_INDEX;
7019}
7020
7021template <class t_HEAD, class... t_TAIL>
7022template <size_t t_INDEX, class t_ARG_01>
7024{
7025 typedef typename bsl::remove_cv<
7027 Alt_Type;
7028
7029 reset();
7030
7031 BloombergLP::bslma::ConstructionUtil::construct(
7032 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7033 AllocBase::mechanism(),
7034 arg_01);
7035 d_type = t_INDEX;
7036}
7037
7038template <class t_HEAD, class... t_TAIL>
7039template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
7041 const t_ARG_02& arg_02)
7042{
7043 typedef typename bsl::remove_cv<
7045 Alt_Type;
7046
7047 reset();
7048
7049 BloombergLP::bslma::ConstructionUtil::construct(
7050 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7051 AllocBase::mechanism(),
7052 arg_01,
7053 arg_02);
7054 d_type = t_INDEX;
7055}
7056
7057template <class t_HEAD, class... t_TAIL>
7058template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
7060 const t_ARG_02& arg_02,
7061 const t_ARG_03& arg_03)
7062{
7063 typedef typename bsl::remove_cv<
7065 Alt_Type;
7066
7067 reset();
7068
7069 BloombergLP::bslma::ConstructionUtil::construct(
7070 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7071 AllocBase::mechanism(),
7072 arg_01,
7073 arg_02,
7074 arg_03);
7075 d_type = t_INDEX;
7076}
7077
7078template <class t_HEAD, class... t_TAIL>
7079template <size_t t_INDEX,
7080 class t_ARG_01,
7081 class t_ARG_02,
7082 class t_ARG_03,
7083 class t_ARG_04>
7085 const t_ARG_02& arg_02,
7086 const t_ARG_03& arg_03,
7087 const t_ARG_04& arg_04)
7088{
7089 typedef typename bsl::remove_cv<
7091 Alt_Type;
7092
7093 reset();
7094
7095 BloombergLP::bslma::ConstructionUtil::construct(
7096 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7097 AllocBase::mechanism(),
7098 arg_01,
7099 arg_02,
7100 arg_03,
7101 arg_04);
7102 d_type = t_INDEX;
7103}
7104
7105template <class t_HEAD, class... t_TAIL>
7106template <size_t t_INDEX,
7107 class t_ARG_01,
7108 class t_ARG_02,
7109 class t_ARG_03,
7110 class t_ARG_04,
7111 class t_ARG_05>
7113 const t_ARG_02& arg_02,
7114 const t_ARG_03& arg_03,
7115 const t_ARG_04& arg_04,
7116 const t_ARG_05& arg_05)
7117{
7118 typedef typename bsl::remove_cv<
7120 Alt_Type;
7121
7122 reset();
7123
7124 BloombergLP::bslma::ConstructionUtil::construct(
7125 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7126 AllocBase::mechanism(),
7127 arg_01,
7128 arg_02,
7129 arg_03,
7130 arg_04,
7131 arg_05);
7132 d_type = t_INDEX;
7133}
7134
7135template <class t_HEAD, class... t_TAIL>
7136template <size_t t_INDEX,
7137 class t_ARG_01,
7138 class t_ARG_02,
7139 class t_ARG_03,
7140 class t_ARG_04,
7141 class t_ARG_05,
7142 class t_ARG_06>
7144 const t_ARG_02& arg_02,
7145 const t_ARG_03& arg_03,
7146 const t_ARG_04& arg_04,
7147 const t_ARG_05& arg_05,
7148 const t_ARG_06& arg_06)
7149{
7150 typedef typename bsl::remove_cv<
7152 Alt_Type;
7153
7154 reset();
7155
7156 BloombergLP::bslma::ConstructionUtil::construct(
7157 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7158 AllocBase::mechanism(),
7159 arg_01,
7160 arg_02,
7161 arg_03,
7162 arg_04,
7163 arg_05,
7164 arg_06);
7165 d_type = t_INDEX;
7166}
7167
7168template <class t_HEAD, class... t_TAIL>
7169template <size_t t_INDEX,
7170 class t_ARG_01,
7171 class t_ARG_02,
7172 class t_ARG_03,
7173 class t_ARG_04,
7174 class t_ARG_05,
7175 class t_ARG_06,
7176 class t_ARG_07>
7178 const t_ARG_02& arg_02,
7179 const t_ARG_03& arg_03,
7180 const t_ARG_04& arg_04,
7181 const t_ARG_05& arg_05,
7182 const t_ARG_06& arg_06,
7183 const t_ARG_07& arg_07)
7184{
7185 typedef typename bsl::remove_cv<
7187 Alt_Type;
7188
7189 reset();
7190
7191 BloombergLP::bslma::ConstructionUtil::construct(
7192 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7193 AllocBase::mechanism(),
7194 arg_01,
7195 arg_02,
7196 arg_03,
7197 arg_04,
7198 arg_05,
7199 arg_06,
7200 arg_07);
7201 d_type = t_INDEX;
7202}
7203
7204template <class t_HEAD, class... t_TAIL>
7205template <size_t t_INDEX,
7206 class t_ARG_01,
7207 class t_ARG_02,
7208 class t_ARG_03,
7209 class t_ARG_04,
7210 class t_ARG_05,
7211 class t_ARG_06,
7212 class t_ARG_07,
7213 class t_ARG_08>
7215 const t_ARG_02& arg_02,
7216 const t_ARG_03& arg_03,
7217 const t_ARG_04& arg_04,
7218 const t_ARG_05& arg_05,
7219 const t_ARG_06& arg_06,
7220 const t_ARG_07& arg_07,
7221 const t_ARG_08& arg_08)
7222{
7223 typedef typename bsl::remove_cv<
7225 Alt_Type;
7226
7227 reset();
7228
7229 BloombergLP::bslma::ConstructionUtil::construct(
7230 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7231 AllocBase::mechanism(),
7232 arg_01,
7233 arg_02,
7234 arg_03,
7235 arg_04,
7236 arg_05,
7237 arg_06,
7238 arg_07,
7239 arg_08);
7240 d_type = t_INDEX;
7241}
7242
7243template <class t_HEAD, class... t_TAIL>
7244template <size_t t_INDEX,
7245 class t_ARG_01,
7246 class t_ARG_02,
7247 class t_ARG_03,
7248 class t_ARG_04,
7249 class t_ARG_05,
7250 class t_ARG_06,
7251 class t_ARG_07,
7252 class t_ARG_08,
7253 class t_ARG_09>
7255 const t_ARG_02& arg_02,
7256 const t_ARG_03& arg_03,
7257 const t_ARG_04& arg_04,
7258 const t_ARG_05& arg_05,
7259 const t_ARG_06& arg_06,
7260 const t_ARG_07& arg_07,
7261 const t_ARG_08& arg_08,
7262 const t_ARG_09& arg_09)
7263{
7264 typedef typename bsl::remove_cv<
7266 Alt_Type;
7267
7268 reset();
7269
7270 BloombergLP::bslma::ConstructionUtil::construct(
7271 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7272 AllocBase::mechanism(),
7273 arg_01,
7274 arg_02,
7275 arg_03,
7276 arg_04,
7277 arg_05,
7278 arg_06,
7279 arg_07,
7280 arg_08,
7281 arg_09);
7282 d_type = t_INDEX;
7283}
7284
7285template <class t_HEAD, class... t_TAIL>
7286template <size_t t_INDEX,
7287 class t_ARG_01,
7288 class t_ARG_02,
7289 class t_ARG_03,
7290 class t_ARG_04,
7291 class t_ARG_05,
7292 class t_ARG_06,
7293 class t_ARG_07,
7294 class t_ARG_08,
7295 class t_ARG_09,
7296 class t_ARG_10>
7298 const t_ARG_02& arg_02,
7299 const t_ARG_03& arg_03,
7300 const t_ARG_04& arg_04,
7301 const t_ARG_05& arg_05,
7302 const t_ARG_06& arg_06,
7303 const t_ARG_07& arg_07,
7304 const t_ARG_08& arg_08,
7305 const t_ARG_09& arg_09,
7306 const t_ARG_10& arg_10)
7307{
7308 typedef typename bsl::remove_cv<
7310 Alt_Type;
7311
7312 reset();
7313
7314 BloombergLP::bslma::ConstructionUtil::construct(
7315 reinterpret_cast<Alt_Type *> BSLS_UTIL_ADDRESSOF(d_union),
7316 AllocBase::mechanism(),
7317 arg_01,
7318 arg_02,
7319 arg_03,
7320 arg_04,
7321 arg_05,
7322 arg_06,
7323 arg_07,
7324 arg_08,
7325 arg_09,
7326 arg_10);
7327 d_type = t_INDEX;
7328}
7329#endif
7330#endif // BSL_VARIANT_FULL_IMPLEMENTATION
7331
7332#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
7333template <class t_HEAD, class... t_TAIL>
7334inline
7336 const Variant_Base& rhs)
7337{
7338 if (&rhs != this) {
7339 if (this->d_type == rhs.d_type) {
7340 if (d_type != bsl::variant_npos) {
7341 Variant& self = static_cast<Variant&>(*this);
7342 BloombergLP::bslstl::Variant_CopyAssignVisitor<Variant>
7343 copyAssign(BSLS_UTIL_ADDRESSOF(self));
7345 void, copyAssign, static_cast<const Variant&>(rhs));
7346 }
7347 }
7348 else {
7349 reset();
7350 if (rhs.d_type != bsl::variant_npos) {
7351 BloombergLP::bslstl::Variant_CopyConstructVisitor<Variant_Base>
7352 copyConstructor(this);
7354 void, copyConstructor, static_cast<const Variant&>(rhs));
7355 }
7356 d_type = rhs.d_type;
7357 }
7358 }
7359 return *this;
7360}
7361
7362template <class t_HEAD, class... t_TAIL>
7363inline
7365 BloombergLP::bslmf::MovableRef<Variant_Base> rhs)
7366{
7367 Variant_Base& lvalue = rhs;
7368 if (&lvalue != this) {
7369 if (this->d_type == lvalue.d_type) {
7370 if (d_type != bsl::variant_npos) {
7371 Variant& self = static_cast<Variant&>(*this);
7372 BloombergLP::bslstl::Variant_MoveAssignVisitor<Variant>
7373 moveAssign(BSLS_UTIL_ADDRESSOF(self));
7375 void, moveAssign, static_cast<Variant&>(lvalue));
7376 }
7377 }
7378 else {
7379 reset();
7380 if (lvalue.d_type != bsl::variant_npos) {
7381 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
7382 moveConstructor(this);
7384 void, moveConstructor, static_cast<Variant&>(lvalue));
7385 }
7386 d_type = lvalue.d_type;
7387 }
7388 }
7389 return *this;
7390}
7391template <class t_HEAD, class... t_TAIL>
7393{
7394 if (d_type != bsl::variant_npos) {
7395 BloombergLP::bslstl::Variant_DestructorVisitor destructor;
7396 bsl::visit(destructor, static_cast<Variant&>(*this));
7397 d_type = bsl::variant_npos;
7398 }
7399}
7400#endif
7401} // close package namespace
7402
7403
7404namespace bsl {
7405
7406 // -------------
7407 // class variant
7408 // -------------
7409
7410// CREATORS
7411#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
7412template <class t_HEAD, class... t_TAIL>
7413template <class t_TYPE>
7414inline
7415variant<t_HEAD, t_TAIL...>::variant(
7416 t_TYPE&& value,
7418: Variant_Base(
7419 bsl::in_place_index_t<BSLSTL_VARIANT_CONVERT_INDEX_OF(t_TYPE,
7420 variant)>(),
7421 std::forward<t_TYPE>(value))
7422{
7423}
7424
7425template <class t_HEAD, class... t_TAIL>
7426template <class t_TYPE>
7427inline
7428variant<t_HEAD, t_TAIL...>::variant(
7430 allocator_type allocator,
7431 t_TYPE&& value,
7433: Variant_Base(
7434 bsl::allocator_arg_t{},
7435 allocator,
7436 bsl::in_place_index_t<BSLSTL_VARIANT_CONVERT_INDEX_OF(t_TYPE,
7437 variant)>(),
7438 std::forward<t_TYPE>(value))
7439{
7440}
7441#else // BSL_VARIANT_FULL_IMPLEMENTATION
7442#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
7443template <class t_HEAD, class... t_TAIL>
7444inline
7446: Variant_Base()
7447{
7448}
7449
7450template <class t_HEAD, class... t_TAIL>
7451inline
7453: Variant_Base(original)
7454{
7455}
7456
7457template <class t_HEAD, class... t_TAIL>
7458inline
7460 BloombergLP::bslmf::MovableRef<variant> original)
7461: Variant_Base(original)
7462{
7463}
7464
7465template <class t_HEAD, class... t_TAIL>
7466template <class t_TYPE>
7467inline
7469 const t_TYPE& value,
7471: Variant_Base(
7473 variant)>(),
7474 value)
7475{
7476}
7477
7478template <class t_HEAD, class... t_TAIL>
7479template <class t_TYPE>
7480inline
7488
7489template <class t_HEAD, class... t_TAIL>
7490template <class t_TYPE, class t_ARG_01>
7491inline
7494 const t_ARG_01& arg_01,
7496: Variant_Base(
7498 arg_01)
7499{
7500}
7501
7502template <class t_HEAD, class... t_TAIL>
7503template <class t_TYPE, class t_ARG_01, class t_ARG_02>
7504inline
7507 const t_ARG_01& arg_01,
7508 const t_ARG_02& arg_02,
7510: Variant_Base(
7512 arg_01,
7513 arg_02)
7514{
7515}
7516
7517template <class t_HEAD, class... t_TAIL>
7518template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
7519inline
7522 const t_ARG_01& arg_01,
7523 const t_ARG_02& arg_02,
7524 const t_ARG_03& arg_03,
7526: Variant_Base(
7528 arg_01,
7529 arg_02,
7530 arg_03)
7531{
7532}
7533
7534template <class t_HEAD, class... t_TAIL>
7535template <class t_TYPE,
7536 class t_ARG_01,
7537 class t_ARG_02,
7538 class t_ARG_03,
7539 class t_ARG_04>
7540inline
7543 const t_ARG_01& arg_01,
7544 const t_ARG_02& arg_02,
7545 const t_ARG_03& arg_03,
7546 const t_ARG_04& arg_04,
7548: Variant_Base(
7550 arg_01,
7551 arg_02,
7552 arg_03,
7553 arg_04)
7554{
7555}
7556
7557template <class t_HEAD, class... t_TAIL>
7558template <class t_TYPE,
7559 class t_ARG_01,
7560 class t_ARG_02,
7561 class t_ARG_03,
7562 class t_ARG_04,
7563 class t_ARG_05>
7564inline
7567 const t_ARG_01& arg_01,
7568 const t_ARG_02& arg_02,
7569 const t_ARG_03& arg_03,
7570 const t_ARG_04& arg_04,
7571 const t_ARG_05& arg_05,
7573: Variant_Base(
7575 arg_01,
7576 arg_02,
7577 arg_03,
7578 arg_04,
7579 arg_05)
7580{
7581}
7582
7583template <class t_HEAD, class... t_TAIL>
7584template <class t_TYPE,
7585 class t_ARG_01,
7586 class t_ARG_02,
7587 class t_ARG_03,
7588 class t_ARG_04,
7589 class t_ARG_05,
7590 class t_ARG_06>
7591inline
7594 const t_ARG_01& arg_01,
7595 const t_ARG_02& arg_02,
7596 const t_ARG_03& arg_03,
7597 const t_ARG_04& arg_04,
7598 const t_ARG_05& arg_05,
7599 const t_ARG_06& arg_06,
7601: Variant_Base(
7603 arg_01,
7604 arg_02,
7605 arg_03,
7606 arg_04,
7607 arg_05,
7608 arg_06)
7609{
7610}
7611
7612template <class t_HEAD, class... t_TAIL>
7613template <class t_TYPE,
7614 class t_ARG_01,
7615 class t_ARG_02,
7616 class t_ARG_03,
7617 class t_ARG_04,
7618 class t_ARG_05,
7619 class t_ARG_06,
7620 class t_ARG_07>
7621inline
7624 const t_ARG_01& arg_01,
7625 const t_ARG_02& arg_02,
7626 const t_ARG_03& arg_03,
7627 const t_ARG_04& arg_04,
7628 const t_ARG_05& arg_05,
7629 const t_ARG_06& arg_06,
7630 const t_ARG_07& arg_07,
7632: Variant_Base(
7634 arg_01,
7635 arg_02,
7636 arg_03,
7637 arg_04,
7638 arg_05,
7639 arg_06,
7640 arg_07)
7641{
7642}
7643
7644template <class t_HEAD, class... t_TAIL>
7645template <class t_TYPE,
7646 class t_ARG_01,
7647 class t_ARG_02,
7648 class t_ARG_03,
7649 class t_ARG_04,
7650 class t_ARG_05,
7651 class t_ARG_06,
7652 class t_ARG_07,
7653 class t_ARG_08>
7654inline
7657 const t_ARG_01& arg_01,
7658 const t_ARG_02& arg_02,
7659 const t_ARG_03& arg_03,
7660 const t_ARG_04& arg_04,
7661 const t_ARG_05& arg_05,
7662 const t_ARG_06& arg_06,
7663 const t_ARG_07& arg_07,
7664 const t_ARG_08& arg_08,
7666: Variant_Base(
7668 arg_01,
7669 arg_02,
7670 arg_03,
7671 arg_04,
7672 arg_05,
7673 arg_06,
7674 arg_07,
7675 arg_08)
7676{
7677}
7678
7679template <class t_HEAD, class... t_TAIL>
7680template <class t_TYPE,
7681 class t_ARG_01,
7682 class t_ARG_02,
7683 class t_ARG_03,
7684 class t_ARG_04,
7685 class t_ARG_05,
7686 class t_ARG_06,
7687 class t_ARG_07,
7688 class t_ARG_08,
7689 class t_ARG_09>
7690inline
7693 const t_ARG_01& arg_01,
7694 const t_ARG_02& arg_02,
7695 const t_ARG_03& arg_03,
7696 const t_ARG_04& arg_04,
7697 const t_ARG_05& arg_05,
7698 const t_ARG_06& arg_06,
7699 const t_ARG_07& arg_07,
7700 const t_ARG_08& arg_08,
7701 const t_ARG_09& arg_09,
7703: Variant_Base(
7705 arg_01,
7706 arg_02,
7707 arg_03,
7708 arg_04,
7709 arg_05,
7710 arg_06,
7711 arg_07,
7712 arg_08,
7713 arg_09)
7714{
7715}
7716
7717template <class t_HEAD, class... t_TAIL>
7718template <class t_TYPE,
7719 class t_ARG_01,
7720 class t_ARG_02,
7721 class t_ARG_03,
7722 class t_ARG_04,
7723 class t_ARG_05,
7724 class t_ARG_06,
7725 class t_ARG_07,
7726 class t_ARG_08,
7727 class t_ARG_09,
7728 class t_ARG_10>
7729inline
7732 const t_ARG_01& arg_01,
7733 const t_ARG_02& arg_02,
7734 const t_ARG_03& arg_03,
7735 const t_ARG_04& arg_04,
7736 const t_ARG_05& arg_05,
7737 const t_ARG_06& arg_06,
7738 const t_ARG_07& arg_07,
7739 const t_ARG_08& arg_08,
7740 const t_ARG_09& arg_09,
7741 const t_ARG_10& arg_10,
7743: Variant_Base(
7745 arg_01,
7746 arg_02,
7747 arg_03,
7748 arg_04,
7749 arg_05,
7750 arg_06,
7751 arg_07,
7752 arg_08,
7753 arg_09,
7754 arg_10)
7755{
7756}
7757
7758template <class t_HEAD, class... t_TAIL>
7759template <size_t t_INDEX>
7760inline
7765
7766template <class t_HEAD, class... t_TAIL>
7767template <size_t t_INDEX, class t_ARG_01>
7768inline
7770 const t_ARG_01& arg_01)
7771: Variant_Base(bsl::in_place_index_t<t_INDEX>(), arg_01)
7772{
7773}
7774
7775template <class t_HEAD, class... t_TAIL>
7776template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
7777inline
7779 const t_ARG_01& arg_01,
7780 const t_ARG_02& arg_02)
7781: Variant_Base(bsl::in_place_index_t<t_INDEX>(), arg_01, arg_02)
7782{
7783}
7784
7785template <class t_HEAD, class... t_TAIL>
7786template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
7787inline
7789 const t_ARG_01& arg_01,
7790 const t_ARG_02& arg_02,
7791 const t_ARG_03& arg_03)
7792: Variant_Base(bsl::in_place_index_t<t_INDEX>(), arg_01, arg_02, arg_03)
7793{
7794}
7795
7796template <class t_HEAD, class... t_TAIL>
7797template <size_t t_INDEX,
7798 class t_ARG_01,
7799 class t_ARG_02,
7800 class t_ARG_03,
7801 class t_ARG_04>
7802inline
7804 const t_ARG_01& arg_01,
7805 const t_ARG_02& arg_02,
7806 const t_ARG_03& arg_03,
7807 const t_ARG_04& arg_04)
7808: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7809 arg_01,
7810 arg_02,
7811 arg_03,
7812 arg_04)
7813{
7814}
7815
7816template <class t_HEAD, class... t_TAIL>
7817template <size_t t_INDEX,
7818 class t_ARG_01,
7819 class t_ARG_02,
7820 class t_ARG_03,
7821 class t_ARG_04,
7822 class t_ARG_05>
7823inline
7825 const t_ARG_01& arg_01,
7826 const t_ARG_02& arg_02,
7827 const t_ARG_03& arg_03,
7828 const t_ARG_04& arg_04,
7829 const t_ARG_05& arg_05)
7830: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7831 arg_01,
7832 arg_02,
7833 arg_03,
7834 arg_04,
7835 arg_05)
7836{
7837}
7838
7839template <class t_HEAD, class... t_TAIL>
7840template <size_t t_INDEX,
7841 class t_ARG_01,
7842 class t_ARG_02,
7843 class t_ARG_03,
7844 class t_ARG_04,
7845 class t_ARG_05,
7846 class t_ARG_06>
7847inline
7849 const t_ARG_01& arg_01,
7850 const t_ARG_02& arg_02,
7851 const t_ARG_03& arg_03,
7852 const t_ARG_04& arg_04,
7853 const t_ARG_05& arg_05,
7854 const t_ARG_06& arg_06)
7855: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7856 arg_01,
7857 arg_02,
7858 arg_03,
7859 arg_04,
7860 arg_05,
7861 arg_06)
7862{
7863}
7864
7865template <class t_HEAD, class... t_TAIL>
7866template <size_t t_INDEX,
7867 class t_ARG_01,
7868 class t_ARG_02,
7869 class t_ARG_03,
7870 class t_ARG_04,
7871 class t_ARG_05,
7872 class t_ARG_06,
7873 class t_ARG_07>
7874inline
7876 const t_ARG_01& arg_01,
7877 const t_ARG_02& arg_02,
7878 const t_ARG_03& arg_03,
7879 const t_ARG_04& arg_04,
7880 const t_ARG_05& arg_05,
7881 const t_ARG_06& arg_06,
7882 const t_ARG_07& arg_07)
7883: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7884 arg_01,
7885 arg_02,
7886 arg_03,
7887 arg_04,
7888 arg_05,
7889 arg_06,
7890 arg_07)
7891{
7892}
7893
7894template <class t_HEAD, class... t_TAIL>
7895template <size_t t_INDEX,
7896 class t_ARG_01,
7897 class t_ARG_02,
7898 class t_ARG_03,
7899 class t_ARG_04,
7900 class t_ARG_05,
7901 class t_ARG_06,
7902 class t_ARG_07,
7903 class t_ARG_08>
7904inline
7906 const t_ARG_01& arg_01,
7907 const t_ARG_02& arg_02,
7908 const t_ARG_03& arg_03,
7909 const t_ARG_04& arg_04,
7910 const t_ARG_05& arg_05,
7911 const t_ARG_06& arg_06,
7912 const t_ARG_07& arg_07,
7913 const t_ARG_08& arg_08)
7914: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7915 arg_01,
7916 arg_02,
7917 arg_03,
7918 arg_04,
7919 arg_05,
7920 arg_06,
7921 arg_07,
7922 arg_08)
7923{
7924}
7925
7926template <class t_HEAD, class... t_TAIL>
7927template <size_t t_INDEX,
7928 class t_ARG_01,
7929 class t_ARG_02,
7930 class t_ARG_03,
7931 class t_ARG_04,
7932 class t_ARG_05,
7933 class t_ARG_06,
7934 class t_ARG_07,
7935 class t_ARG_08,
7936 class t_ARG_09>
7937inline
7939 const t_ARG_01& arg_01,
7940 const t_ARG_02& arg_02,
7941 const t_ARG_03& arg_03,
7942 const t_ARG_04& arg_04,
7943 const t_ARG_05& arg_05,
7944 const t_ARG_06& arg_06,
7945 const t_ARG_07& arg_07,
7946 const t_ARG_08& arg_08,
7947 const t_ARG_09& arg_09)
7948: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7949 arg_01,
7950 arg_02,
7951 arg_03,
7952 arg_04,
7953 arg_05,
7954 arg_06,
7955 arg_07,
7956 arg_08,
7957 arg_09)
7958{
7959}
7960
7961template <class t_HEAD, class... t_TAIL>
7962template <size_t t_INDEX,
7963 class t_ARG_01,
7964 class t_ARG_02,
7965 class t_ARG_03,
7966 class t_ARG_04,
7967 class t_ARG_05,
7968 class t_ARG_06,
7969 class t_ARG_07,
7970 class t_ARG_08,
7971 class t_ARG_09,
7972 class t_ARG_10>
7973inline
7975 const t_ARG_01& arg_01,
7976 const t_ARG_02& arg_02,
7977 const t_ARG_03& arg_03,
7978 const t_ARG_04& arg_04,
7979 const t_ARG_05& arg_05,
7980 const t_ARG_06& arg_06,
7981 const t_ARG_07& arg_07,
7982 const t_ARG_08& arg_08,
7983 const t_ARG_09& arg_09,
7984 const t_ARG_10& arg_10)
7985: Variant_Base(bsl::in_place_index_t<t_INDEX>(),
7986 arg_01,
7987 arg_02,
7988 arg_03,
7989 arg_04,
7990 arg_05,
7991 arg_06,
7992 arg_07,
7993 arg_08,
7994 arg_09,
7995 arg_10)
7996{
7997}
7998
7999template <class t_HEAD, class... t_TAIL>
8000inline
8006
8007template <class t_HEAD, class... t_TAIL>
8008inline
8011 const variant& original)
8012: Variant_Base(bsl::allocator_arg_t(), allocator, original)
8013{
8014}
8015
8016template <class t_HEAD, class... t_TAIL>
8017inline
8021 BloombergLP::bslmf::MovableRef<variant> original)
8022: Variant_Base(bsl::allocator_arg_t(), allocator, original)
8023{
8024}
8025
8026template <class t_HEAD, class... t_TAIL>
8027template <class t_TYPE>
8028inline
8032 const t_TYPE& value,
8034: Variant_Base(
8036 allocator,
8038 variant)>(),
8039 value)
8040{
8041}
8042
8043template <class t_HEAD, class... t_TAIL>
8044template <class t_TYPE>
8045inline
8057
8058template <class t_HEAD, class... t_TAIL>
8059template <class t_TYPE, class t_ARG_01>
8060inline
8065 const t_ARG_01& arg_01,
8067: Variant_Base(
8069 allocator,
8071 arg_01)
8072{
8073}
8074
8075template <class t_HEAD, class... t_TAIL>
8076template <class t_TYPE, class t_ARG_01, class t_ARG_02>
8077inline
8082 const t_ARG_01& arg_01,
8083 const t_ARG_02& arg_02,
8085: Variant_Base(
8087 allocator,
8089 arg_01,
8090 arg_02)
8091{
8092}
8093
8094template <class t_HEAD, class... t_TAIL>
8095template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
8096inline
8101 const t_ARG_01& arg_01,
8102 const t_ARG_02& arg_02,
8103 const t_ARG_03& arg_03,
8105: Variant_Base(
8107 allocator,
8109 arg_01,
8110 arg_02,
8111 arg_03)
8112{
8113}
8114
8115template <class t_HEAD, class... t_TAIL>
8116template <class t_TYPE,
8117 class t_ARG_01,
8118 class t_ARG_02,
8119 class t_ARG_03,
8120 class t_ARG_04>
8121inline
8126 const t_ARG_01& arg_01,
8127 const t_ARG_02& arg_02,
8128 const t_ARG_03& arg_03,
8129 const t_ARG_04& arg_04,
8131: Variant_Base(
8133 allocator,
8135 arg_01,
8136 arg_02,
8137 arg_03,
8138 arg_04)
8139{
8140}
8141
8142template <class t_HEAD, class... t_TAIL>
8143template <class t_TYPE,
8144 class t_ARG_01,
8145 class t_ARG_02,
8146 class t_ARG_03,
8147 class t_ARG_04,
8148 class t_ARG_05>
8149inline
8154 const t_ARG_01& arg_01,
8155 const t_ARG_02& arg_02,
8156 const t_ARG_03& arg_03,
8157 const t_ARG_04& arg_04,
8158 const t_ARG_05& arg_05,
8160: Variant_Base(
8162 allocator,
8164 arg_01,
8165 arg_02,
8166 arg_03,
8167 arg_04,
8168 arg_05)
8169{
8170}
8171
8172template <class t_HEAD, class... t_TAIL>
8173template <class t_TYPE,
8174 class t_ARG_01,
8175 class t_ARG_02,
8176 class t_ARG_03,
8177 class t_ARG_04,
8178 class t_ARG_05,
8179 class t_ARG_06>
8180inline
8185 const t_ARG_01& arg_01,
8186 const t_ARG_02& arg_02,
8187 const t_ARG_03& arg_03,
8188 const t_ARG_04& arg_04,
8189 const t_ARG_05& arg_05,
8190 const t_ARG_06& arg_06,
8192: Variant_Base(
8194 allocator,
8196 arg_01,
8197 arg_02,
8198 arg_03,
8199 arg_04,
8200 arg_05,
8201 arg_06)
8202{
8203}
8204
8205template <class t_HEAD, class... t_TAIL>
8206template <class t_TYPE,
8207 class t_ARG_01,
8208 class t_ARG_02,
8209 class t_ARG_03,
8210 class t_ARG_04,
8211 class t_ARG_05,
8212 class t_ARG_06,
8213 class t_ARG_07>
8214inline
8219 const t_ARG_01& arg_01,
8220 const t_ARG_02& arg_02,
8221 const t_ARG_03& arg_03,
8222 const t_ARG_04& arg_04,
8223 const t_ARG_05& arg_05,
8224 const t_ARG_06& arg_06,
8225 const t_ARG_07& arg_07,
8227: Variant_Base(
8229 allocator,
8231 arg_01,
8232 arg_02,
8233 arg_03,
8234 arg_04,
8235 arg_05,
8236 arg_06,
8237 arg_07)
8238{
8239}
8240
8241template <class t_HEAD, class... t_TAIL>
8242template <class t_TYPE,
8243 class t_ARG_01,
8244 class t_ARG_02,
8245 class t_ARG_03,
8246 class t_ARG_04,
8247 class t_ARG_05,
8248 class t_ARG_06,
8249 class t_ARG_07,
8250 class t_ARG_08>
8251inline
8256 const t_ARG_01& arg_01,
8257 const t_ARG_02& arg_02,
8258 const t_ARG_03& arg_03,
8259 const t_ARG_04& arg_04,
8260 const t_ARG_05& arg_05,
8261 const t_ARG_06& arg_06,
8262 const t_ARG_07& arg_07,
8263 const t_ARG_08& arg_08,
8265: Variant_Base(
8267 allocator,
8269 arg_01,
8270 arg_02,
8271 arg_03,
8272 arg_04,
8273 arg_05,
8274 arg_06,
8275 arg_07,
8276 arg_08)
8277{
8278}
8279
8280template <class t_HEAD, class... t_TAIL>
8281template <class t_TYPE,
8282 class t_ARG_01,
8283 class t_ARG_02,
8284 class t_ARG_03,
8285 class t_ARG_04,
8286 class t_ARG_05,
8287 class t_ARG_06,
8288 class t_ARG_07,
8289 class t_ARG_08,
8290 class t_ARG_09>
8291inline
8296 const t_ARG_01& arg_01,
8297 const t_ARG_02& arg_02,
8298 const t_ARG_03& arg_03,
8299 const t_ARG_04& arg_04,
8300 const t_ARG_05& arg_05,
8301 const t_ARG_06& arg_06,
8302 const t_ARG_07& arg_07,
8303 const t_ARG_08& arg_08,
8304 const t_ARG_09& arg_09,
8306: Variant_Base(
8308 allocator,
8310 arg_01,
8311 arg_02,
8312 arg_03,
8313 arg_04,
8314 arg_05,
8315 arg_06,
8316 arg_07,
8317 arg_08,
8318 arg_09)
8319{
8320}
8321
8322template <class t_HEAD, class... t_TAIL>
8323template <class t_TYPE,
8324 class t_ARG_01,
8325 class t_ARG_02,
8326 class t_ARG_03,
8327 class t_ARG_04,
8328 class t_ARG_05,
8329 class t_ARG_06,
8330 class t_ARG_07,
8331 class t_ARG_08,
8332 class t_ARG_09,
8333 class t_ARG_10>
8334inline
8339 const t_ARG_01& arg_01,
8340 const t_ARG_02& arg_02,
8341 const t_ARG_03& arg_03,
8342 const t_ARG_04& arg_04,
8343 const t_ARG_05& arg_05,
8344 const t_ARG_06& arg_06,
8345 const t_ARG_07& arg_07,
8346 const t_ARG_08& arg_08,
8347 const t_ARG_09& arg_09,
8348 const t_ARG_10& arg_10,
8350: Variant_Base(
8352 allocator,
8354 arg_01,
8355 arg_02,
8356 arg_03,
8357 arg_04,
8358 arg_05,
8359 arg_06,
8360 arg_07,
8361 arg_08,
8362 arg_09,
8363 arg_10)
8364{
8365}
8366
8367template <class t_HEAD, class... t_TAIL>
8368template <size_t t_INDEX>
8369inline
8378
8379template <class t_HEAD, class... t_TAIL>
8380template <size_t t_INDEX, class t_ARG_01>
8381inline
8385 const t_ARG_01& arg_01)
8386: Variant_Base(bsl::allocator_arg_t(),
8387 allocator,
8388 bsl::in_place_index_t<t_INDEX>(),
8389 arg_01)
8390{
8391}
8392
8393template <class t_HEAD, class... t_TAIL>
8394template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
8395inline
8399 const t_ARG_01& arg_01,
8400 const t_ARG_02& arg_02)
8401: Variant_Base(bsl::allocator_arg_t(),
8402 allocator,
8403 bsl::in_place_index_t<t_INDEX>(),
8404 arg_01,
8405 arg_02)
8406{
8407}
8408
8409template <class t_HEAD, class... t_TAIL>
8410template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
8411inline
8415 const t_ARG_01& arg_01,
8416 const t_ARG_02& arg_02,
8417 const t_ARG_03& arg_03)
8418: Variant_Base(bsl::allocator_arg_t(),
8419 allocator,
8420 bsl::in_place_index_t<t_INDEX>(),
8421 arg_01,
8422 arg_02,
8423 arg_03)
8424{
8425}
8426
8427template <class t_HEAD, class... t_TAIL>
8428template <size_t t_INDEX,
8429 class t_ARG_01,
8430 class t_ARG_02,
8431 class t_ARG_03,
8432 class t_ARG_04>
8433inline
8437 const t_ARG_01& arg_01,
8438 const t_ARG_02& arg_02,
8439 const t_ARG_03& arg_03,
8440 const t_ARG_04& arg_04)
8441: Variant_Base(bsl::allocator_arg_t(),
8442 allocator,
8443 bsl::in_place_index_t<t_INDEX>(),
8444 arg_01,
8445 arg_02,
8446 arg_03,
8447 arg_04)
8448{
8449}
8450
8451template <class t_HEAD, class... t_TAIL>
8452template <size_t t_INDEX,
8453 class t_ARG_01,
8454 class t_ARG_02,
8455 class t_ARG_03,
8456 class t_ARG_04,
8457 class t_ARG_05>
8458inline
8462 const t_ARG_01& arg_01,
8463 const t_ARG_02& arg_02,
8464 const t_ARG_03& arg_03,
8465 const t_ARG_04& arg_04,
8466 const t_ARG_05& arg_05)
8467: Variant_Base(bsl::allocator_arg_t(),
8468 allocator,
8469 bsl::in_place_index_t<t_INDEX>(),
8470 arg_01,
8471 arg_02,
8472 arg_03,
8473 arg_04,
8474 arg_05)
8475{
8476}
8477
8478template <class t_HEAD, class... t_TAIL>
8479template <size_t t_INDEX,
8480 class t_ARG_01,
8481 class t_ARG_02,
8482 class t_ARG_03,
8483 class t_ARG_04,
8484 class t_ARG_05,
8485 class t_ARG_06>
8486inline
8490 const t_ARG_01& arg_01,
8491 const t_ARG_02& arg_02,
8492 const t_ARG_03& arg_03,
8493 const t_ARG_04& arg_04,
8494 const t_ARG_05& arg_05,
8495 const t_ARG_06& arg_06)
8496: Variant_Base(bsl::allocator_arg_t(),
8497 allocator,
8498 bsl::in_place_index_t<t_INDEX>(),
8499 arg_01,
8500 arg_02,
8501 arg_03,
8502 arg_04,
8503 arg_05,
8504 arg_06)
8505{
8506}
8507
8508template <class t_HEAD, class... t_TAIL>
8509template <size_t t_INDEX,
8510 class t_ARG_01,
8511 class t_ARG_02,
8512 class t_ARG_03,
8513 class t_ARG_04,
8514 class t_ARG_05,
8515 class t_ARG_06,
8516 class t_ARG_07>
8517inline
8521 const t_ARG_01& arg_01,
8522 const t_ARG_02& arg_02,
8523 const t_ARG_03& arg_03,
8524 const t_ARG_04& arg_04,
8525 const t_ARG_05& arg_05,
8526 const t_ARG_06& arg_06,
8527 const t_ARG_07& arg_07)
8528: Variant_Base(bsl::allocator_arg_t(),
8529 allocator,
8530 bsl::in_place_index_t<t_INDEX>(),
8531 arg_01,
8532 arg_02,
8533 arg_03,
8534 arg_04,
8535 arg_05,
8536 arg_06,
8537 arg_07)
8538{
8539}
8540
8541template <class t_HEAD, class... t_TAIL>
8542template <size_t t_INDEX,
8543 class t_ARG_01,
8544 class t_ARG_02,
8545 class t_ARG_03,
8546 class t_ARG_04,
8547 class t_ARG_05,
8548 class t_ARG_06,
8549 class t_ARG_07,
8550 class t_ARG_08>
8551inline
8555 const t_ARG_01& arg_01,
8556 const t_ARG_02& arg_02,
8557 const t_ARG_03& arg_03,
8558 const t_ARG_04& arg_04,
8559 const t_ARG_05& arg_05,
8560 const t_ARG_06& arg_06,
8561 const t_ARG_07& arg_07,
8562 const t_ARG_08& arg_08)
8563: Variant_Base(bsl::allocator_arg_t(),
8564 allocator,
8565 bsl::in_place_index_t<t_INDEX>(),
8566 arg_01,
8567 arg_02,
8568 arg_03,
8569 arg_04,
8570 arg_05,
8571 arg_06,
8572 arg_07,
8573 arg_08)
8574{
8575}
8576
8577template <class t_HEAD, class... t_TAIL>
8578template <size_t t_INDEX,
8579 class t_ARG_01,
8580 class t_ARG_02,
8581 class t_ARG_03,
8582 class t_ARG_04,
8583 class t_ARG_05,
8584 class t_ARG_06,
8585 class t_ARG_07,
8586 class t_ARG_08,
8587 class t_ARG_09>
8588inline
8592 const t_ARG_01& arg_01,
8593 const t_ARG_02& arg_02,
8594 const t_ARG_03& arg_03,
8595 const t_ARG_04& arg_04,
8596 const t_ARG_05& arg_05,
8597 const t_ARG_06& arg_06,
8598 const t_ARG_07& arg_07,
8599 const t_ARG_08& arg_08,
8600 const t_ARG_09& arg_09)
8601: Variant_Base(bsl::allocator_arg_t(),
8602 allocator,
8603 bsl::in_place_index_t<t_INDEX>(),
8604 arg_01,
8605 arg_02,
8606 arg_03,
8607 arg_04,
8608 arg_05,
8609 arg_06,
8610 arg_07,
8611 arg_08,
8612 arg_09)
8613{
8614}
8615
8616template <class t_HEAD, class... t_TAIL>
8617template <size_t t_INDEX,
8618 class t_ARG_01,
8619 class t_ARG_02,
8620 class t_ARG_03,
8621 class t_ARG_04,
8622 class t_ARG_05,
8623 class t_ARG_06,
8624 class t_ARG_07,
8625 class t_ARG_08,
8626 class t_ARG_09,
8627 class t_ARG_10>
8628inline
8632 const t_ARG_01& arg_01,
8633 const t_ARG_02& arg_02,
8634 const t_ARG_03& arg_03,
8635 const t_ARG_04& arg_04,
8636 const t_ARG_05& arg_05,
8637 const t_ARG_06& arg_06,
8638 const t_ARG_07& arg_07,
8639 const t_ARG_08& arg_08,
8640 const t_ARG_09& arg_09,
8641 const t_ARG_10& arg_10)
8642: Variant_Base(bsl::allocator_arg_t(),
8643 allocator,
8644 bsl::in_place_index_t<t_INDEX>(),
8645 arg_01,
8646 arg_02,
8647 arg_03,
8648 arg_04,
8649 arg_05,
8650 arg_06,
8651 arg_07,
8652 arg_08,
8653 arg_09,
8654 arg_10)
8655{
8656}
8657
8658template <class t_HEAD, class... t_TAIL>
8659template <class t_TYPE>
8660typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8661 t_TYPE,
8662 variant<t_HEAD, t_TAIL...> >::value,
8663 t_TYPE&>::type
8665{
8666 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8667
8668 Variant_Base::template baseEmplace<index>();
8669
8670 return bsl::get<index>(*this);
8671}
8672
8673template <class t_HEAD, class... t_TAIL>
8674template <class t_TYPE, class t_ARG_01>
8675typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8676 t_TYPE,
8677 variant<t_HEAD, t_TAIL...> >::value,
8678 t_TYPE&>::type
8680{
8681 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8682
8683 Variant_Base::template baseEmplace<index>(arg_01);
8684
8685 return bsl::get<index>(*this);
8686}
8687
8688template <class t_HEAD, class... t_TAIL>
8689template <class t_TYPE, class t_ARG_01, class t_ARG_02>
8690typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8691 t_TYPE,
8692 variant<t_HEAD, t_TAIL...> >::value,
8693 t_TYPE&>::type
8695 const t_ARG_02& arg_02)
8696{
8697 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8698
8699 Variant_Base::template baseEmplace<index>(arg_01, arg_02);
8700
8701 return bsl::get<index>(*this);
8702}
8703
8704template <class t_HEAD, class... t_TAIL>
8705template <class t_TYPE, class t_ARG_01, class t_ARG_02, class t_ARG_03>
8706typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8707 t_TYPE,
8708 variant<t_HEAD, t_TAIL...> >::value,
8709 t_TYPE&>::type
8711 const t_ARG_02& arg_02,
8712 const t_ARG_03& arg_03)
8713{
8714 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8715
8716 Variant_Base::template baseEmplace<index>(arg_01, arg_02, arg_03);
8717
8718 return bsl::get<index>(*this);
8719}
8720
8721template <class t_HEAD, class... t_TAIL>
8722template <class t_TYPE,
8723 class t_ARG_01,
8724 class t_ARG_02,
8725 class t_ARG_03,
8726 class t_ARG_04>
8727typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8728 t_TYPE,
8729 variant<t_HEAD, t_TAIL...> >::value,
8730 t_TYPE&>::type
8732 const t_ARG_02& arg_02,
8733 const t_ARG_03& arg_03,
8734 const t_ARG_04& arg_04)
8735{
8736 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8737
8738 Variant_Base::template baseEmplace<index>(arg_01, arg_02, arg_03, arg_04);
8739
8740 return bsl::get<index>(*this);
8741}
8742
8743template <class t_HEAD, class... t_TAIL>
8744template <class t_TYPE,
8745 class t_ARG_01,
8746 class t_ARG_02,
8747 class t_ARG_03,
8748 class t_ARG_04,
8749 class t_ARG_05>
8750typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8751 t_TYPE,
8752 variant<t_HEAD, t_TAIL...> >::value,
8753 t_TYPE&>::type
8755 const t_ARG_02& arg_02,
8756 const t_ARG_03& arg_03,
8757 const t_ARG_04& arg_04,
8758 const t_ARG_05& arg_05)
8759{
8760 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8761
8762 Variant_Base::template baseEmplace<index>(
8763 arg_01, arg_02, arg_03, arg_04, arg_05);
8764
8765 return bsl::get<index>(*this);
8766}
8767
8768template <class t_HEAD, class... t_TAIL>
8769template <class t_TYPE,
8770 class t_ARG_01,
8771 class t_ARG_02,
8772 class t_ARG_03,
8773 class t_ARG_04,
8774 class t_ARG_05,
8775 class t_ARG_06>
8776typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8777 t_TYPE,
8778 variant<t_HEAD, t_TAIL...> >::value,
8779 t_TYPE&>::type
8781 const t_ARG_02& arg_02,
8782 const t_ARG_03& arg_03,
8783 const t_ARG_04& arg_04,
8784 const t_ARG_05& arg_05,
8785 const t_ARG_06& arg_06)
8786{
8787 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8788
8789 Variant_Base::template baseEmplace<index>(
8790 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06);
8791
8792 return bsl::get<index>(*this);
8793}
8794
8795template <class t_HEAD, class... t_TAIL>
8796template <class t_TYPE,
8797 class t_ARG_01,
8798 class t_ARG_02,
8799 class t_ARG_03,
8800 class t_ARG_04,
8801 class t_ARG_05,
8802 class t_ARG_06,
8803 class t_ARG_07>
8804typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8805 t_TYPE,
8806 variant<t_HEAD, t_TAIL...> >::value,
8807 t_TYPE&>::type
8809 const t_ARG_02& arg_02,
8810 const t_ARG_03& arg_03,
8811 const t_ARG_04& arg_04,
8812 const t_ARG_05& arg_05,
8813 const t_ARG_06& arg_06,
8814 const t_ARG_07& arg_07)
8815{
8816 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8817
8818 Variant_Base::template baseEmplace<index>(
8819 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06, arg_07);
8820
8821 return bsl::get<index>(*this);
8822}
8823
8824template <class t_HEAD, class... t_TAIL>
8825template <class t_TYPE,
8826 class t_ARG_01,
8827 class t_ARG_02,
8828 class t_ARG_03,
8829 class t_ARG_04,
8830 class t_ARG_05,
8831 class t_ARG_06,
8832 class t_ARG_07,
8833 class t_ARG_08>
8834typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8835 t_TYPE,
8836 variant<t_HEAD, t_TAIL...> >::value,
8837 t_TYPE&>::type
8839 const t_ARG_02& arg_02,
8840 const t_ARG_03& arg_03,
8841 const t_ARG_04& arg_04,
8842 const t_ARG_05& arg_05,
8843 const t_ARG_06& arg_06,
8844 const t_ARG_07& arg_07,
8845 const t_ARG_08& arg_08)
8846{
8847 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8848
8849 Variant_Base::template baseEmplace<index>(
8850 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06, arg_07, arg_08);
8851
8852 return bsl::get<index>(*this);
8853}
8854
8855template <class t_HEAD, class... t_TAIL>
8856template <class t_TYPE,
8857 class t_ARG_01,
8858 class t_ARG_02,
8859 class t_ARG_03,
8860 class t_ARG_04,
8861 class t_ARG_05,
8862 class t_ARG_06,
8863 class t_ARG_07,
8864 class t_ARG_08,
8865 class t_ARG_09>
8866typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8867 t_TYPE,
8868 variant<t_HEAD, t_TAIL...> >::value,
8869 t_TYPE&>::type
8871 const t_ARG_02& arg_02,
8872 const t_ARG_03& arg_03,
8873 const t_ARG_04& arg_04,
8874 const t_ARG_05& arg_05,
8875 const t_ARG_06& arg_06,
8876 const t_ARG_07& arg_07,
8877 const t_ARG_08& arg_08,
8878 const t_ARG_09& arg_09)
8879{
8880 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8881
8882 Variant_Base::template baseEmplace<index>(arg_01,
8883 arg_02,
8884 arg_03,
8885 arg_04,
8886 arg_05,
8887 arg_06,
8888 arg_07,
8889 arg_08,
8890 arg_09);
8891
8892 return bsl::get<index>(*this);
8893}
8894
8895template <class t_HEAD, class... t_TAIL>
8896template <class t_TYPE,
8897 class t_ARG_01,
8898 class t_ARG_02,
8899 class t_ARG_03,
8900 class t_ARG_04,
8901 class t_ARG_05,
8902 class t_ARG_06,
8903 class t_ARG_07,
8904 class t_ARG_08,
8905 class t_ARG_09,
8906 class t_ARG_10>
8907typename bsl::enable_if<BloombergLP::bslstl::Variant_HasUniqueType<
8908 t_TYPE,
8909 variant<t_HEAD, t_TAIL...> >::value,
8910 t_TYPE&>::type
8912 const t_ARG_02& arg_02,
8913 const t_ARG_03& arg_03,
8914 const t_ARG_04& arg_04,
8915 const t_ARG_05& arg_05,
8916 const t_ARG_06& arg_06,
8917 const t_ARG_07& arg_07,
8918 const t_ARG_08& arg_08,
8919 const t_ARG_09& arg_09,
8920 const t_ARG_10& arg_10)
8921{
8922 const size_t index = BSLSTL_VARIANT_INDEX_OF(t_TYPE, variant);
8923
8924 Variant_Base::template baseEmplace<index>(arg_01,
8925 arg_02,
8926 arg_03,
8927 arg_04,
8928 arg_05,
8929 arg_06,
8930 arg_07,
8931 arg_08,
8932 arg_09,
8933 arg_10);
8934
8935 return bsl::get<index>(*this);
8936}
8937
8938template <class t_HEAD, class... t_TAIL>
8939template <size_t t_INDEX>
8940typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
8942{
8943 Variant_Base::template baseEmplace<t_INDEX>();
8944
8945 return bsl::get<t_INDEX>(*this);
8946}
8947
8948template <class t_HEAD, class... t_TAIL>
8949template <size_t t_INDEX, class t_ARG_01>
8950typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
8952{
8953 Variant_Base::template baseEmplace<t_INDEX>(arg_01);
8954
8955 return bsl::get<t_INDEX>(*this);
8956}
8957
8958template <class t_HEAD, class... t_TAIL>
8959template <size_t t_INDEX, class t_ARG_01, class t_ARG_02>
8960typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
8962 const t_ARG_02& arg_02)
8963{
8964 Variant_Base::template baseEmplace<t_INDEX>(arg_01, arg_02);
8965
8966 return bsl::get<t_INDEX>(*this);
8967}
8968
8969template <class t_HEAD, class... t_TAIL>
8970template <size_t t_INDEX, class t_ARG_01, class t_ARG_02, class t_ARG_03>
8971typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
8973 const t_ARG_02& arg_02,
8974 const t_ARG_03& arg_03)
8975{
8976 Variant_Base::template baseEmplace<t_INDEX>(arg_01, arg_02, arg_03);
8977
8978 return bsl::get<t_INDEX>(*this);
8979}
8980
8981template <class t_HEAD, class... t_TAIL>
8982template <size_t t_INDEX,
8983 class t_ARG_01,
8984 class t_ARG_02,
8985 class t_ARG_03,
8986 class t_ARG_04>
8987typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
8989 const t_ARG_02& arg_02,
8990 const t_ARG_03& arg_03,
8991 const t_ARG_04& arg_04)
8992{
8993 Variant_Base::template baseEmplace<t_INDEX>(
8994 arg_01, arg_02, arg_03, arg_04);
8995
8996 return bsl::get<t_INDEX>(*this);
8997}
8998
8999template <class t_HEAD, class... t_TAIL>
9000template <size_t t_INDEX,
9001 class t_ARG_01,
9002 class t_ARG_02,
9003 class t_ARG_03,
9004 class t_ARG_04,
9005 class t_ARG_05>
9006typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9008 const t_ARG_02& arg_02,
9009 const t_ARG_03& arg_03,
9010 const t_ARG_04& arg_04,
9011 const t_ARG_05& arg_05)
9012{
9013 Variant_Base::template baseEmplace<t_INDEX>(
9014 arg_01, arg_02, arg_03, arg_04, arg_05);
9015
9016 return bsl::get<t_INDEX>(*this);
9017}
9018
9019template <class t_HEAD, class... t_TAIL>
9020template <size_t t_INDEX,
9021 class t_ARG_01,
9022 class t_ARG_02,
9023 class t_ARG_03,
9024 class t_ARG_04,
9025 class t_ARG_05,
9026 class t_ARG_06>
9027typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9029 const t_ARG_02& arg_02,
9030 const t_ARG_03& arg_03,
9031 const t_ARG_04& arg_04,
9032 const t_ARG_05& arg_05,
9033 const t_ARG_06& arg_06)
9034{
9035 Variant_Base::template baseEmplace<t_INDEX>(
9036 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06);
9037
9038 return bsl::get<t_INDEX>(*this);
9039}
9040
9041template <class t_HEAD, class... t_TAIL>
9042template <size_t t_INDEX,
9043 class t_ARG_01,
9044 class t_ARG_02,
9045 class t_ARG_03,
9046 class t_ARG_04,
9047 class t_ARG_05,
9048 class t_ARG_06,
9049 class t_ARG_07>
9050typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9052 const t_ARG_02& arg_02,
9053 const t_ARG_03& arg_03,
9054 const t_ARG_04& arg_04,
9055 const t_ARG_05& arg_05,
9056 const t_ARG_06& arg_06,
9057 const t_ARG_07& arg_07)
9058{
9059 Variant_Base::template baseEmplace<t_INDEX>(
9060 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06, arg_07);
9061
9062 return bsl::get<t_INDEX>(*this);
9063}
9064
9065template <class t_HEAD, class... t_TAIL>
9066template <size_t t_INDEX,
9067 class t_ARG_01,
9068 class t_ARG_02,
9069 class t_ARG_03,
9070 class t_ARG_04,
9071 class t_ARG_05,
9072 class t_ARG_06,
9073 class t_ARG_07,
9074 class t_ARG_08>
9075typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9077 const t_ARG_02& arg_02,
9078 const t_ARG_03& arg_03,
9079 const t_ARG_04& arg_04,
9080 const t_ARG_05& arg_05,
9081 const t_ARG_06& arg_06,
9082 const t_ARG_07& arg_07,
9083 const t_ARG_08& arg_08)
9084{
9085 Variant_Base::template baseEmplace<t_INDEX>(
9086 arg_01, arg_02, arg_03, arg_04, arg_05, arg_06, arg_07, arg_08);
9087
9088 return bsl::get<t_INDEX>(*this);
9089}
9090
9091template <class t_HEAD, class... t_TAIL>
9092template <size_t t_INDEX,
9093 class t_ARG_01,
9094 class t_ARG_02,
9095 class t_ARG_03,
9096 class t_ARG_04,
9097 class t_ARG_05,
9098 class t_ARG_06,
9099 class t_ARG_07,
9100 class t_ARG_08,
9101 class t_ARG_09>
9102typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9104 const t_ARG_02& arg_02,
9105 const t_ARG_03& arg_03,
9106 const t_ARG_04& arg_04,
9107 const t_ARG_05& arg_05,
9108 const t_ARG_06& arg_06,
9109 const t_ARG_07& arg_07,
9110 const t_ARG_08& arg_08,
9111 const t_ARG_09& arg_09)
9112{
9113 Variant_Base::template baseEmplace<t_INDEX>(arg_01,
9114 arg_02,
9115 arg_03,
9116 arg_04,
9117 arg_05,
9118 arg_06,
9119 arg_07,
9120 arg_08,
9121 arg_09);
9122
9123 return bsl::get<t_INDEX>(*this);
9124}
9125
9126template <class t_HEAD, class... t_TAIL>
9127template <size_t t_INDEX,
9128 class t_ARG_01,
9129 class t_ARG_02,
9130 class t_ARG_03,
9131 class t_ARG_04,
9132 class t_ARG_05,
9133 class t_ARG_06,
9134 class t_ARG_07,
9135 class t_ARG_08,
9136 class t_ARG_09,
9137 class t_ARG_10>
9138typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9140 const t_ARG_02& arg_02,
9141 const t_ARG_03& arg_03,
9142 const t_ARG_04& arg_04,
9143 const t_ARG_05& arg_05,
9144 const t_ARG_06& arg_06,
9145 const t_ARG_07& arg_07,
9146 const t_ARG_08& arg_08,
9147 const t_ARG_09& arg_09,
9148 const t_ARG_10& arg_10)
9149{
9150 Variant_Base::template baseEmplace<t_INDEX>(arg_01,
9151 arg_02,
9152 arg_03,
9153 arg_04,
9154 arg_05,
9155 arg_06,
9156 arg_07,
9157 arg_08,
9158 arg_09,
9159 arg_10);
9160
9161 return bsl::get<t_INDEX>(*this);
9162}
9163
9164template <class t_HEAD, class... t_TAIL>
9165inline
9167 const variant& rhs)
9168{
9169 Variant_Base::operator=(static_cast<const Variant_Base&>(rhs));
9170 return *this;
9171}
9172
9173template <class t_HEAD, class... t_TAIL>
9174inline
9176 BloombergLP::bslmf::MovableRef<variant> rhs)
9177{
9178 variant<t_HEAD, t_TAIL...>& lvalue = rhs;
9179 Variant_Base::operator=(
9180 MoveUtil::move(static_cast<Variant_Base&>(lvalue)));
9181 return *this;
9182}
9183template <class t_HEAD, class... t_TAIL>
9184template <class t_TYPE>
9185inline
9186typename bsl::enable_if<
9187 BloombergLP::bslstl::Variant_AssignsFromType<variant<t_HEAD, t_TAIL...>,
9188 t_TYPE>::value,
9189 variant<t_HEAD, t_TAIL...>&>::type
9191{
9192 const size_t altIndex = BSLSTL_VARIANT_CONVERT_INDEX_OF(t_TYPE, variant);
9193
9194 if (index() == altIndex) {
9195 bsl::get<altIndex>(*this) = rhs;
9196 }
9197 else {
9198 // 'altIndex' can not be @ref variant_npos if 'Variant_AssignsFromType' is
9199 // satisfied
9200 emplace<altIndex>(rhs);
9201 }
9202
9203 return *this;
9204}
9205#endif
9206#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9207
9208#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
9209template <class t_HEAD, class... t_TAIL>
9210inline
9212{
9213 if (!valueless_by_exception()) {
9214 if (index() == other.index()) {
9215 BloombergLP::bslstl::Variant_SwapVisitor<variant> swapper(this);
9216 BSLSTL_VARIANT_VISITID(void, swapper, other);
9217 }
9218 else {
9219 variant tmpThis(MoveUtil::move(*this));
9220 this->reset();
9221 if (!other.valueless_by_exception()) {
9222 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
9223 moveConstructor(this);
9224 BSLSTL_VARIANT_VISITID(void, moveConstructor, other);
9225 }
9226#ifndef BSL_VARIANT_FULL_IMPLEMENTATION
9227 // In C++03, if there are nonunique alternatives,
9228 // 'BSLSTL_VARIANT_VISITID' will always use the first nonunique
9229 // alternative, which may result in the wrong 'd_type' being set.
9230 this->d_type = other.index();
9231#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9232 other.reset();
9233 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
9234 moveConstructor(BSLS_UTIL_ADDRESSOF(other));
9235 BSLSTL_VARIANT_VISITID(void, moveConstructor, tmpThis);
9236#ifndef BSL_VARIANT_FULL_IMPLEMENTATION
9237 other.d_type = tmpThis.index();
9238#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9239 }
9240 }
9241 else {
9242 if (!other.valueless_by_exception()) {
9243 BloombergLP::bslstl::Variant_MoveConstructVisitor<Variant_Base>
9244 moveConstructor(this);
9245 BSLSTL_VARIANT_VISITID(void, moveConstructor, other);
9246#ifndef BSL_VARIANT_FULL_IMPLEMENTATION
9247 this->d_type = other.index();
9248#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9249 other.reset();
9250 }
9251 }
9252}
9253
9254// ACCESSORS
9255template <class t_HEAD, class... t_TAIL>
9256inline
9258{
9259 return this->d_type;
9260}
9261
9262template <class t_HEAD, class... t_TAIL>
9263inline
9269
9270#endif
9271
9272// FREE FUNCTIONS
9273#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
9274template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9275typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type& get(
9277{
9279
9280 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9281 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9283
9284 return ImpUtil::get<Ret, t_INDEX>(obj);
9285}
9286
9287template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9288const typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&
9289get(const variant<t_HEAD, t_TAIL...>& obj)
9290{
9291 BSLMF_ASSERT((t_INDEX < variant_size<variant<t_HEAD, t_TAIL...> >::value));
9292
9293 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9294 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9296
9297 return ImpUtil::get<const Ret, t_INDEX>(obj);
9298}
9299
9300template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9301typename variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...> >::type&& get(
9302 variant<t_HEAD, t_TAIL...>&& obj)
9303{
9304 BSLMF_ASSERT((t_INDEX < variant_size<variant<t_HEAD, t_TAIL...> >::value));
9305
9306 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9307 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9309
9310 return std::move(ImpUtil::get<Ret, t_INDEX>(obj));
9311}
9312
9313template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9314const typename variant_alternative<t_INDEX,
9315 variant<t_HEAD, t_TAIL...> >::type&&
9316get(const variant<t_HEAD, t_TAIL...>&& obj)
9317{
9318 BSLMF_ASSERT((t_INDEX < variant_size<variant<t_HEAD, t_TAIL...> >::value));
9319
9320 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9321 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9323
9324 return std::move(ImpUtil::get<const Ret, t_INDEX>(obj));
9325}
9326#else // BSL_VARIANT_FULL_IMPLEMENTATION
9327#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
9328template <size_t t_INDEX, class t_VARIANT>
9329typename Variant_GetIndexReturnType<t_INDEX, t_VARIANT>::type
9330get(t_VARIANT& obj)
9331{
9333
9334 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9336
9337 return ImpUtil::get<Ret, t_INDEX>(obj);
9338}
9339
9340template <size_t t_INDEX, class t_VARIANT>
9341typename Variant_GetIndexReturnType<
9342 t_INDEX,
9343 BloombergLP::bslmf::MovableRef<t_VARIANT> >::type
9344get(BloombergLP::bslmf::MovableRef<t_VARIANT> obj)
9345{
9346 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
9347 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9349
9350 t_VARIANT& lvalue = obj;
9351
9352 return MoveUtil::move(ImpUtil::get<Ret, t_INDEX>(lvalue));
9353}
9354#endif
9355#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9356
9357#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
9358template <class t_TYPE, class t_HEAD, class... t_TAIL>
9359t_TYPE& get(variant<t_HEAD, t_TAIL...>& obj)
9360{
9361 BSLMF_ASSERT((BloombergLP::bslstl::Variant_HasUniqueType<
9362 t_TYPE,
9363 variant<t_HEAD, t_TAIL...> >::value));
9364
9365 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9366 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9367
9368 return ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(obj);
9369}
9370
9371template <class t_TYPE, class t_HEAD, class... t_TAIL>
9372const t_TYPE& get(const variant<t_HEAD, t_TAIL...>& obj)
9373{
9374 BSLMF_ASSERT((BloombergLP::bslstl::Variant_HasUniqueType<
9375 t_TYPE,
9376 variant<t_HEAD, t_TAIL...> >::value));
9377
9378 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9379 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9380
9381 return ImpUtil::get<const t_TYPE,
9382 BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(obj);
9383}
9384
9385template <class t_TYPE, class t_HEAD, class... t_TAIL>
9386t_TYPE&& get(variant<t_HEAD, t_TAIL...>&& obj)
9387{
9388 static_assert(
9389 BloombergLP::bslstl::
9390 Variant_HasUniqueType<t_TYPE, variant<t_HEAD, t_TAIL...> >::value,
9391 "Type is not unique in variant");
9392
9393 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9394 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9395
9396 return std::move(
9397 ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(obj));
9398}
9399
9400template <class t_TYPE, class t_HEAD, class... t_TAIL>
9401const t_TYPE&& get(const variant<t_HEAD, t_TAIL...>&& obj)
9402{
9403 static_assert(
9404 BloombergLP::bslstl::
9405 Variant_HasUniqueType<t_TYPE, variant<t_HEAD, t_TAIL...> >::value,
9406 "Type is not unique in variant");
9407
9408 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9409 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9410
9411 return std::move(
9412 ImpUtil::get<const t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(
9413 obj));
9414}
9415#else // BSL_VARIANT_FULL_IMPLEMENTATION
9416#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
9417template <class t_TYPE, class t_VARIANT>
9418typename Variant_GetTypeReturnType<t_TYPE&, t_VARIANT>::type
9419get(t_VARIANT& obj)
9420{
9421 BSLMF_ASSERT((
9422 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, t_VARIANT>::value));
9423
9424 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9425
9426 return ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
9427 obj);
9428}
9429
9430template <class t_TYPE, class t_VARIANT>
9431typename Variant_GetTypeReturnType<const t_TYPE&, t_VARIANT>::type
9432get(const t_VARIANT& obj)
9433{
9434 BSLMF_ASSERT((
9435 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, t_VARIANT>::value));
9436
9437 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9438
9439 return ImpUtil::get<const t_TYPE,
9440 BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(obj);
9441}
9442
9443template <class t_TYPE, class t_VARIANT>
9444typename Variant_GetTypeReturnType<BloombergLP::bslmf::MovableRef<t_TYPE>,
9445 t_VARIANT>::type
9446get(BloombergLP::bslmf::MovableRef<t_VARIANT> obj)
9447{
9448 BSLMF_ASSERT((
9449 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, t_VARIANT>::value));
9450
9451 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
9452 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9453
9454 t_VARIANT& lvalue = obj;
9455 return MoveUtil::move(
9456 ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
9457 lvalue));
9458}
9459#endif
9460#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9461
9462#ifdef BSL_VARIANT_FULL_IMPLEMENTATION
9463template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9464typename add_pointer<
9465 typename variant_alternative<t_INDEX,
9466 variant<t_HEAD, t_TAIL...> >::type>::type
9467get_if(variant<t_HEAD, t_TAIL...> *ptr) BSLS_KEYWORD_NOEXCEPT
9468{
9469 BSLMF_ASSERT((t_INDEX < variant_size<variant<t_HEAD, t_TAIL...> >::value));
9470
9471 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9472 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9474
9475 if (ptr == 0 || ptr->index() != t_INDEX) {
9476 return NULL; // RETURN
9477 }
9478
9479 return BSLS_UTIL_ADDRESSOF((ImpUtil::get<Ret, t_INDEX>(*ptr)));
9480}
9481
9482template <size_t t_INDEX, class t_HEAD, class... t_TAIL>
9483typename add_pointer<const typename variant_alternative<
9484 t_INDEX,
9485 variant<t_HEAD, t_TAIL...> >::type>::type
9486get_if(const variant<t_HEAD, t_TAIL...> *ptr) BSLS_KEYWORD_NOEXCEPT
9487{
9488 BSLMF_ASSERT((t_INDEX < variant_size<variant<t_HEAD, t_TAIL...> >::value));
9489
9490 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9491 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9493
9494 if (ptr == 0 || ptr->index() != t_INDEX) {
9495 return NULL; // RETURN
9496 }
9497 return BSLS_UTIL_ADDRESSOF((ImpUtil::get<const Ret, t_INDEX>(*ptr)));
9498}
9499
9500template <class t_TYPE, class t_HEAD, class... t_TAIL>
9502 variant<t_HEAD, t_TAIL...> *ptr) BSLS_KEYWORD_NOEXCEPT
9503{
9504 BSLMF_ASSERT((BloombergLP::bslstl::Variant_HasUniqueType<
9505 t_TYPE,
9506 variant<t_HEAD, t_TAIL...> >::value));
9507
9508 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9509 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9510
9511 if (ptr == 0 || ptr->index() != BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)) {
9512 return NULL; // RETURN
9513 }
9514 return BSLS_UTIL_ADDRESSOF((
9515 ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(*ptr)));
9516}
9517
9518template <class t_TYPE, class t_HEAD, class... t_TAIL>
9520 const variant<t_HEAD, t_TAIL...> *ptr) BSLS_KEYWORD_NOEXCEPT
9521{
9522 BSLMF_ASSERT((BloombergLP::bslstl::Variant_HasUniqueType<
9523 t_TYPE,
9524 variant<t_HEAD, t_TAIL...> >::value));
9525
9526 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9527 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9528
9529 if (ptr == 0 || ptr->index() != BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)) {
9530 return NULL; // RETURN
9531 }
9532 return BSLS_UTIL_ADDRESSOF(
9533 (ImpUtil::get<const t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant)>(
9534 *ptr)));
9535}
9536#else
9537#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
9538template <size_t t_INDEX, class t_VARIANT>
9539typename Variant_GetIndexReturnType<t_INDEX, t_VARIANT>::pointer
9541{
9543
9544 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9546
9547 if (ptr == 0 || ptr->index() != t_INDEX) {
9548 return NULL; // RETURN
9549 }
9550
9551 return BSLS_UTIL_ADDRESSOF((ImpUtil::get<Ret, t_INDEX>(*ptr)));
9552}
9553
9554template <class t_TYPE, class t_VARIANT>
9555typename Variant_GetTypeReturnType<t_TYPE, t_VARIANT>::pointer
9557{
9558 BSLMF_ASSERT((
9559 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, t_VARIANT>::value));
9560
9561 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9562
9563 if (ptr == 0 ||
9564 ptr->index() != BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)) {
9565 return NULL; // RETURN
9566 }
9567 return BSLS_UTIL_ADDRESSOF(
9568 (ImpUtil::get<t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
9569 *ptr)));
9570}
9571
9572template <class t_TYPE, class t_VARIANT>
9573typename Variant_GetTypeReturnType<const t_TYPE, t_VARIANT>::pointer
9574get_if(const t_VARIANT *ptr) BSLS_KEYWORD_NOEXCEPT
9575{
9576 BSLMF_ASSERT((
9577 BloombergLP::bslstl::Variant_HasUniqueType<t_TYPE, t_VARIANT>::value));
9578
9579 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9580
9581 if (ptr == 0 ||
9582 ptr->index() != BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)) {
9583 return NULL; // RETURN
9584 }
9585 return BSLS_UTIL_ADDRESSOF((
9586 ImpUtil::get<const t_TYPE, BSLSTL_VARIANT_INDEX_OF(t_TYPE, t_VARIANT)>(
9587 *ptr)));
9588}
9589#endif
9590#endif // BSL_VARIANT_FULL_IMPLEMENTATION
9591
9592#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
9593// HASH SPECIALIZATIONS
9594template <class t_HASHALG, class t_HEAD, class... t_TAIL>
9595void hashAppend(t_HASHALG& hashAlg, const variant<t_HEAD, t_TAIL...>& input)
9596{
9597 if (!input.valueless_by_exception()) {
9598 hashAppend(hashAlg, input.index());
9599 BloombergLP::bslstl::Variant_HashVisitor<t_HASHALG> hashVisitor(
9600 hashAlg);
9601 visit(hashVisitor, input);
9602 }
9603 else {
9604 hashAppend(hashAlg, false);
9605 }
9606}
9607
9608template <class t_TYPE, class t_HEAD, class... t_TAIL>
9611{
9612 BSLMF_ASSERT((BloombergLP::bslstl::Variant_HasUniqueType<
9613 t_TYPE,
9614 variant<t_HEAD, t_TAIL...> >::value));
9615 typedef typename bsl::variant<t_HEAD, t_TAIL...> Variant;
9616 return obj.index() == BSLSTL_VARIANT_INDEX_OF(t_TYPE, Variant);
9617}
9618
9619template <class t_HEAD, class... t_TAIL>
9622{
9623 BloombergLP::bslstl::variant_swapImpl(
9625 bool,
9626 BloombergLP::bslstl::
9627 Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value>(),
9628 lhs,
9629 rhs);
9630}
9631
9632// FREE OPERATORS
9633template <class t_HEAD, class... t_TAIL>
9634bool operator==(const variant<t_HEAD, t_TAIL...>& lhs,
9636{
9637 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9638
9639 if (lhs.index() != rhs.index()) {
9640 return false; // RETURN
9641 }
9642 else if (lhs.valueless_by_exception()) {
9643 return true; // RETURN
9644 }
9645 return ImpUtil::Equal(lhs, rhs);
9646}
9647
9648template <class t_HEAD, class... t_TAIL>
9649bool operator!=(const variant<t_HEAD, t_TAIL...>& lhs,
9651{
9652 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9653
9654 if (lhs.index() != rhs.index()) {
9655 return true; // RETURN
9656 }
9657 else if (lhs.valueless_by_exception()) {
9658 return false; // RETURN
9659 }
9660 return ImpUtil::NotEqual(lhs, rhs);
9661}
9662
9663template <class t_HEAD, class... t_TAIL>
9664bool operator<(const variant<t_HEAD, t_TAIL...>& lhs,
9666{
9667 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9668
9669 if (rhs.valueless_by_exception()) {
9670 return false; // RETURN
9671 }
9672 else if (lhs.valueless_by_exception()) {
9673 return true; // RETURN
9674 }
9675 else if (lhs.index() != rhs.index()) {
9676 return lhs.index() < rhs.index(); // RETURN
9677 }
9678 return ImpUtil::LessThan(lhs, rhs);
9679}
9680
9681template <class t_HEAD, class... t_TAIL>
9682bool operator>(const variant<t_HEAD, t_TAIL...>& lhs,
9684{
9685 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9686
9687 if (lhs.valueless_by_exception()) {
9688 return false; // RETURN
9689 }
9690 else if (rhs.valueless_by_exception()) {
9691 return true; // RETURN
9692 }
9693 else if (lhs.index() != rhs.index()) {
9694 return lhs.index() > rhs.index(); // RETURN
9695 }
9696 return ImpUtil::GreaterThan(lhs, rhs);
9697}
9698
9699template <class t_HEAD, class... t_TAIL>
9700bool operator<=(const variant<t_HEAD, t_TAIL...>& lhs,
9702{
9703 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9704
9705 if (lhs.valueless_by_exception()) {
9706 return true; // RETURN
9707 }
9708 else if (rhs.valueless_by_exception()) {
9709 return false; // RETURN
9710 }
9711 else if (lhs.index() != rhs.index()) {
9712 return lhs.index() < rhs.index(); // RETURN
9713 }
9714 return ImpUtil::LessOrEqual(lhs, rhs);
9715}
9716
9717template <class t_HEAD, class... t_TAIL>
9718bool operator>=(const variant<t_HEAD, t_TAIL...>& lhs,
9720{
9721 typedef BloombergLP::bslstl::Variant_ImpUtil ImpUtil;
9722
9723 if (rhs.valueless_by_exception()) {
9724 return true; // RETURN
9725 }
9726 else if (lhs.valueless_by_exception()) {
9727 return false; // RETURN
9728 }
9729 else if (lhs.index() != rhs.index()) {
9730 return lhs.index() > rhs.index(); // RETURN
9731 }
9732
9733 return ImpUtil::GreaterOrEqual(lhs, rhs);
9734}
9735
9736#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON && \
9737 defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
9738
9739template <class... t_ALTS>
9740 requires(std::three_way_comparable<t_ALTS> && ...)
9741constexpr std::common_comparison_category_t<
9742 std::compare_three_way_result_t<t_ALTS>...>
9743operator<=>(const variant<t_ALTS...>& lhs, const variant<t_ALTS...>& rhs)
9744{
9745 using RET = std::common_comparison_category_t<
9746 std::compare_three_way_result_t<t_ALTS>...>;
9747
9748 const size_t lhs_index = lhs.index();
9749 const size_t rhs_index = rhs.index();
9750 if ((lhs_index != variant_npos) && (rhs_index != variant_npos)) {
9751 if (lhs_index == rhs_index) {
9752 return BloombergLP::bslstl::Variant_ImpUtil::visitId<RET>(
9753 [&lhs]<size_t t_INDEX>(bsl::in_place_index_t<t_INDEX>,
9754 auto&& rhs_value) {
9755 return bsl::get<t_INDEX>(lhs) <=> rhs_value; // RETURN
9756 },
9757 rhs);
9758 }
9759 else {
9760 return lhs_index <=> rhs_index; // RETURN
9761 }
9762 }
9763 else {
9764 if (lhs_index == variant_npos) {
9765 if (rhs_index == variant_npos)
9766 return std::strong_ordering::equal; // RETURN
9767 else
9768 return std::strong_ordering::less; // RETURN
9769 }
9770 else
9771 return std::strong_ordering::greater; // RETURN
9772 }
9773}
9774#endif
9775
9776#endif
9777} // close namespace bsl
9778
9779#endif // End C++11 code
9780
9781#undef BSL_VARIANT_FULL_IMPLEMENTATION
9782#undef BSLSTL_VARIANT_NOT_A_TYPE
9783#undef BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM
9784#undef BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM
9785#undef BSLSTL_VARIANT_DEFINE_IF_HAS_UNIQUE_TYPE
9786#undef BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE
9787#undef BSLSTL_VARIANT_HAS_UNIQUE_TYPE
9788#undef BSLSTL_VARIANT_TYPE_AT_INDEX
9789#undef BSLSTL_VARIANT_INDEX_OF
9790#undef BSLSTL_VARIANT_CONVERT_INDEX_OF
9791#undef BSLSTL_VARIANT_CONVERT_TYPE_OF
9792#undef BSLSTL_VARIANT_VISITID
9793#undef BSLSTL_VARIANT_RELOP_VISITOR_DEFINITON
9794
9795#endif // End C++11 code
9796
9797// ----------------------------------------------------------------------------
9798// Copyright 2023 Bloomberg Finance L.P.
9799//
9800// Licensed under the Apache License, Version 2.0 (the "License");
9801// you may not use this file except in compliance with the License.
9802// You may obtain a copy of the License at
9803//
9804// http://www.apache.org/licenses/LICENSE-2.0
9805//
9806// Unless required by applicable law or agreed to in writing, software
9807// distributed under the License is distributed on an "AS IS" BASIS,
9808// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9809// See the License for the specific language governing permissions and
9810// limitations under the License.
9811// ----------------------------- END-OF-FILE ----------------------------------
9812
9813/** @} */
9814/** @} */
9815/** @} */
#define BSLSTL_VARIANT_DEFINE_IF_HAS_UNIQUE_TYPE(TYPE)
Definition bslstl_variant.h:903
#define BSLSTL_VARIANT_DEFINE_IF_CONSTRUCTS_FROM(VARIANT, TYPE)
Definition bslstl_variant.h:870
#define BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM_STD(STD_VARIANT)
Definition bslstl_variant.h:893
#define BSLSTL_VARIANT_HAS_UNIQUE_TYPE(TYPE)
Definition bslstl_variant.h:919
#define BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM(VARIANT, TYPE)
Definition bslstl_variant.h:879
#define BSLSTL_VARIANT_INDEX_OF(TYPE, VARIANT)
Definition bslstl_variant.h:933
#define BSLSTL_VARIANT_TYPE_AT_INDEX(INDEX)
Definition bslstl_variant.h:926
#define BSLSTL_VARIANT_RELOP_VISITOR_DEFINITON(NAME, OP)
Definition bslstl_variant.h:2866
#define BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(TYPE)
Definition bslstl_variant.h:911
#define BSLSTL_VARIANT_VISITID(RET, VISITOR, VAROBJ)
Definition bslstl_variant.h:956
#define BSLSTL_VARIANT_CONVERT_INDEX_OF(TYPE, VARIANT)
Definition bslstl_variant.h:940
Definition bslma_bslallocator.h:588
BloombergLP::bslma::Allocator * mechanism() const
Definition bslma_bslallocator.h:1146
Definition bslmf_invokeresult.h:362
Definition bslstl_variant.h:3806
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09)
Definition bslstl_variant.h:8589
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04)
Definition bslstl_variant.h:8988
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace()
Definition bslstl_variant.h:8941
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10)
Definition bslstl_variant.h:7974
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10)
Definition bslstl_variant.h:8629
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03)
Definition bslstl_variant.h:8710
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06)
Definition bslstl_variant.h:8780
variant(const variant &original)
Definition bslstl_variant.h:7452
size_t index() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_variant.h:9257
variant & operator=(BloombergLP::bslmf::MovableRef< variant > rhs)
Definition bslstl_variant.h:9175
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03)
Definition bslstl_variant.h:7788
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06)
Definition bslstl_variant.h:9028
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02)
Definition bslstl_variant.h:8396
void swap(variant &other)
Definition bslstl_variant.h:9211
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02)
Definition bslstl_variant.h:8694
variant(bsl::allocator_arg_t, allocator_type allocator, const variant &original)
Definition bslstl_variant.h:8009
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05)
Definition bslstl_variant.h:9007
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04)
Definition bslstl_variant.h:8731
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05)
Definition bslstl_variant.h:8754
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03)
Definition bslstl_variant.h:8972
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06)
Definition bslstl_variant.h:8487
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07)
Definition bslstl_variant.h:9051
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
BSLMF_NESTED_TRAIT_DECLARATION_IF(variant, BloombergLP::bslma::UsesBslmaAllocator,(BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value))
bool valueless_by_exception() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_variant.h:9264
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(BloombergLP::bslmf::MovableRef< variant > original)
Definition bslstl_variant.h:7459
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01)
Definition bslstl_variant.h:8679
~variant()=default
variant(bsl::in_place_index_t< t_INDEX >)
Definition bslstl_variant.h:7761
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator)
Definition bslstl_variant.h:8001
BSLMF_NESTED_TRAIT_DECLARATION_IF(variant, BloombergLP::bslmf::UsesAllocatorArgT,(BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08)
Definition bslstl_variant.h:8838
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09)
Definition bslstl_variant.h:9103
BSLMF_NESTED_TRAIT_DECLARATION_IF(variant, BloombergLP::bslmf::IsBitwiseMoveable,(BloombergLP::bslstl::Variant_IsBitwiseMoveableAll< t_HEAD, t_TAIL... >::value))
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10)
Definition bslstl_variant.h:8911
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08)
Definition bslstl_variant.h:8552
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05)
Definition bslstl_variant.h:7824
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04)
Definition bslstl_variant.h:8434
variant(bsl::allocator_arg_t, allocator_type allocator, const t_TYPE &value, BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM(variant, t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_AssignsFromType< variant, t_TYPE >::value, variant & >::type operator=(const t_TYPE &value)
Definition bslstl_variant.h:9190
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >)
Definition bslstl_variant.h:8370
variant(const t_TYPE &value, BSLSTL_VARIANT_DECLARE_IF_CONSTRUCTS_FROM(variant, t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
Variant_Base::allocator_type allocator_type
Type alias to the allocator type used by variant.
Definition bslstl_variant.h:3846
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01)
Definition bslstl_variant.h:8382
variant(bsl::allocator_arg_t, allocator_type allocator, BloombergLP::bslmf::MovableRef< variant > original)
Definition bslstl_variant.h:8018
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant()
Definition bslstl_variant.h:7445
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09)
Definition bslstl_variant.h:7938
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05)
Definition bslstl_variant.h:8459
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01)
Definition bslstl_variant.h:8951
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03)
Definition bslstl_variant.h:8412
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07)
Definition bslstl_variant.h:8518
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, const t_ARG_10 &arg_10)
Definition bslstl_variant.h:9139
variant & operator=(const variant &rhs)
Definition bslstl_variant.h:9166
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07)
Definition bslstl_variant.h:7875
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06)
Definition bslstl_variant.h:7848
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04)
Definition bslstl_variant.h:7803
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace()
Definition bslstl_variant.h:8664
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08)
Definition bslstl_variant.h:9076
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07)
Definition bslstl_variant.h:8808
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01)
Definition bslstl_variant.h:7769
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant(bsl::in_place_type_t< t_TYPE >, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
variant_alternative< t_INDEX, variant< t_HEAD, t_TAIL... > >::type & emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02)
Definition bslstl_variant.h:8961
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08)
Definition bslstl_variant.h:7905
variant(bsl::in_place_index_t< t_INDEX >, const t_ARG_01 &arg_01, const t_ARG_02 &arg_02)
Definition bslstl_variant.h:7778
variant(bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
bsl::enable_if< BloombergLP::bslstl::Variant_HasUniqueType< t_TYPE, variant >::value, t_TYPE & >::type emplace(const t_ARG_01 &arg_01, const t_ARG_02 &arg_02, const t_ARG_03 &arg_03, const t_ARG_04 &arg_04, const t_ARG_05 &arg_05, const t_ARG_06 &arg_06, const t_ARG_07 &arg_07, const t_ARG_08 &arg_08, const t_ARG_09 &arg_09)
Definition bslstl_variant.h:8870
variant(bsl::in_place_type_t< t_TYPE >, const t_ARG_01 &arg_01, BSLSTL_VARIANT_DECLARE_IF_HAS_UNIQUE_TYPE(t_TYPE))
Definition bslmf_movableref.h:752
Definition bslstl_variant.h:2706
void operator()(bsl::in_place_index_t< t_INDEX >, const t_TYPE &value) const
Definition bslstl_variant.h:2735
Variant_CopyAssignVisitor(t_VARIANT *variant)
Definition bslstl_variant.h:2717
Definition bslstl_variant.h:2623
Variant_CopyConstructVisitor(t_VARIANT_BASE *variant)
Definition bslstl_variant.h:2634
void operator()(bsl::in_place_index_t< t_INDEX >, const t_TYPE &other) const
Definition bslstl_variant.h:2648
Definition bslstl_variant.h:2547
t_TYPE & value()
Definition bslstl_variant.h:5973
Variant_DataImp()=default
Create a Variant_DataImp object that holds an empty buffer.
const t_TYPE & value() const
Definition bslstl_variant.h:5999
Definition bslstl_variant.h:2982
void operator()(t_TYPE &value) const
Definition bslstl_variant.h:3003
Variant_HashVisitor(t_HASHALG &hashAlg)
Definition bslstl_variant.h:2993
Definition bslstl_variant.h:2763
void operator()(bsl::in_place_index_t< t_INDEX >, t_TYPE &value) const
Definition bslstl_variant.h:2794
Variant_MoveAssignVisitor(t_VARIANT *variant)
Definition bslstl_variant.h:2777
Definition bslstl_variant.h:2663
void operator()(bsl::in_place_index_t< t_INDEX >, t_TYPE &other) const
Definition bslstl_variant.h:2691
Variant_MoveConstructVisitor(t_VARIANT_BASE *variant)
Definition bslstl_variant.h:2677
Definition bslstl_variant.h:2926
Variant_SwapVisitor(t_VARIANT *variant)
Definition bslstl_variant.h:2938
void operator()(bsl::in_place_index_t< t_INDEX >, t_TYPE &value) const
Definition bslstl_variant.h:2954
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_THROW(X)
Definition bsls_exceptionutil.h:374
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_CONSTEXPR_CPP14
Definition bsls_keyword.h:631
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:624
#define BSLS_KEYWORD_INLINE_CONSTEXPR
Definition bsls_keyword.h:659
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_INLINE_VARIABLE
Definition bsls_keyword.h:665
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:296
void BSLSTL_VARIANT_NOT_A_TYPE
Definition bslstl_variant.h:330
Definition bdlat_valuetypefunctions.h:939
bool holds_alternative(const variant< t_HEAD, t_TAIL... > &obj) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_variant.h:9609
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition bslstl_array.h:959
Variant_GetIndexReturnType< t_INDEX, t_VARIANT >::pointer get_if(t_VARIANT *obj) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_variant.h:9540
BSLS_KEYWORD_CONSTEXPR_CPP14 TYPE & get(array< TYPE, SIZE > &a) BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_INLINE_CONSTEXPR size_t variant_npos
Definition bslstl_variant.h:381
bsl::invoke_result< t_VISITOR &, typenamebsl::variant_alternative< 0, t_VARIANT >::type & >::type visit(t_VISITOR &visitor, t_VARIANT &variant)
Definition bslstl_variant.h:2359
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
t_RET visitR(t_VISITOR &visitor, t_VARIANT &variant)
Definition bslstl_variant.h:2313
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition bslstl_algorithm.h:84
void variant_swapImpl(bsl::true_type, t_VARIANT &lhs, t_VARIANT &rhs)
Definition bslstl_variant.h:6009
Definition bdldfp_decimal.h:5549
BloombergLP::bslmf::MovableRef< typename bsl::variant_alternative< t_INDEX, t_VARIANT >::type > type
Definition bslstl_variant.h:592
bsl::variant_alternative< t_INDEX, constt_VARIANT >::type * pointer
Definition bslstl_variant.h:581
bsl::variant_alternative< t_INDEX, constt_VARIANT >::type & type
Definition bslstl_variant.h:578
bsl::variant_alternative< t_INDEX, t_VARIANT >::type & type
Definition bslstl_variant.h:566
bsl::variant_alternative< t_INDEX, t_VARIANT >::type * pointer
Definition bslstl_variant.h:569
Definition bslstl_variant.h:561
Definition bslstl_variant.h:605
Definition bslstl_variant.h:420
Definition bslmf_addpointer.h:175
BloombergLP::bslmf::AddPointer_Impl< t_TYPE >::type type
Definition bslmf_addpointer.h:181
Definition bslmf_allocatorargt.h:433
Definition bslmf_conditional.h:123
Definition bslmf_enableif.h:530
Definition bslstl_inplace.h:183
Definition bslstl_inplace.h:143
Definition bslmf_integralconstant.h:261
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removeconst.h:164
Definition bslmf_removecv.h:120
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:128
variant_alternative< t_INDEX, t_TYPE >::type const type
Definition bslstl_variant.h:396
variant_alternative< t_INDEX, t_TYPE >::type const volatile type
Definition bslstl_variant.h:407
BSLMF_ASSERT((t_INDEX< bsl::variant_size< variant< t_HEAD, t_TAIL... > >::value))
variant_alternative< t_INDEX, t_TYPE >::type volatile type
Definition bslstl_variant.h:401
Definition bslstl_variant.h:392
Definition bslstl_variant.h:349
BloombergLP::bslmf::MovableRefUtil MoveUtil
Definition bslstl_variant.h:3040
BloombergLP::bslma::Allocator * mechanism() const
Return the mechanism of the stored allocator.
Definition bslstl_variant.h:3069
bsl::allocator< char > allocator_type
Definition bslstl_variant.h:3041
Variant_AllocatorBase()
Definition bslstl_variant.h:3050
allocator_type d_allocator
Definition bslstl_variant.h:3044
Variant_AllocatorBase(allocator_type allocator)
Definition bslstl_variant.h:3061
Variant_AllocatorBase(const Variant_AllocatorBase &original)
Definition bslstl_variant.h:3054
Definition bslstl_variant.h:3016
BloombergLP::bslma::Allocator * mechanism() const
Definition bslstl_variant.h:3029
Definition bslstl_variant.h:3106
Definition bslstl_variant.h:3090
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant_Base, BloombergLP::bslma::UsesBslmaAllocator,(BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value))
Variant_Base()
Definition bslstl_variant.h:6167
bsl::conditional< BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value, bsl::allocator< char >, NoAlloc >::type allocator_type
Type alias to the allocator type used by variant.
Definition bslstl_variant.h:3114
size_t d_type
Definition bslstl_variant.h:3120
void baseEmplace()
Definition bslstl_variant.h:7007
bsl::variant< t_HEAD, t_TAIL... > Variant
Definition bslstl_variant.h:3100
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant_Base, BloombergLP::bslmf::IsBitwiseMoveable,(BloombergLP::bslstl::Variant_IsBitwiseMoveableAll< t_HEAD, t_TAIL... >::value))
Variant_Union d_union
Union holding the alternative object.
Definition bslstl_variant.h:3123
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant_Base, BloombergLP::bslmf::UsesAllocatorArgT,(BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value))
~Variant_Base()
Destroy this object. The contained value, if any, is destroyed.
Definition bslstl_variant.h:6971
BloombergLP::bslmf::MovableRefUtil MoveUtil
Definition bslstl_variant.h:3093
void reset() BSLS_KEYWORD_NOEXCEPT
Destroy the contained value, if any.
Definition bslstl_variant.h:7392
BloombergLP::bslstl::Variant_Union< t_HEAD, t_TAIL... > Variant_Union
Definition bslstl_variant.h:3099
Variant_Base & operator=(const Variant_Base &rhs)
Definition bslstl_variant.h:7335
BloombergLP::bslstl::Variant_AllocatorBase< BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny< t_HEAD, t_TAIL... >::value > AllocBase
Definition bslstl_variant.h:3097
Definition bslstl_variant.h:775
Definition bslstl_variant.h:2813
void operator()(t_TYPE &object) const
Definition bslstl_variant.h:2821
Definition bslstl_variant.h:2434
BSLS_KEYWORD_CONSTEXPR Variant_NoSuchType(int) BSLS_KEYWORD_NOEXCEPT
Create a Variant_NoSuchType object.
Definition bslstl_variant.h:5934
Definition bslstl_variant.h:795
Definition bslstl_variant.h:2117
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335
TYPE & object()
Definition bsls_objectbuffer.h:352
Variant_Union< t_TAIL0, t_TAIL... > d_tail
Definition bslstl_variant.h:2609
Variant_DataImp< t_HEAD > d_head
Definition bslstl_variant.h:2608
Definition bslstl_variant.h:2589