BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlb_variant.h
Go to the documentation of this file.
1/// @file bdlb_variant.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlb_variant.h -*-C++-*-
8#ifndef INCLUDED_BDLB_VARIANT
9#define INCLUDED_BDLB_VARIANT
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlb_variant bdlb_variant
15/// @brief Provide a variant (discriminated `union`-like) type.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlb
19/// @{
20/// @addtogroup bdlb_variant
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlb_variant-purpose"> Purpose</a>
25/// * <a href="#bdlb_variant-classes"> Classes </a>
26/// * <a href="#bdlb_variant-description"> Description </a>
27/// * <a href="#bdlb_variant-default-construction"> Default Construction </a>
28/// * <a href="#bdlb_variant-visitors"> Visitors </a>
29/// * <a href="#bdlb_variant-bdex-streamability"> BDEX Streamability </a>
30/// * <a href="#bdlb_variant-class-synopsis"> Class Synopsis </a>
31/// * <a href="#bdlb_variant-creators"> Creators </a>
32/// * <a href="#bdlb_variant-manipulators"> Manipulators </a>
33/// * <a href="#bdlb_variant-accessors"> Accessors </a>
34/// * <a href="#bdlb_variant-usage"> Usage </a>
35/// * <a href="#bdlb_variant-example-1-variant-construction"> Example 1: Variant Construction </a>
36/// * <a href="#bdlb_variant-example-2-variant-assignment"> Example 2: Variant Assignment </a>
37/// * <a href="#bdlb_variant-operator"> operator= </a>
38/// * <a href="#bdlb_variant-assignto-type"> assignTo<TYPE> </a>
39/// * <a href="#bdlb_variant-assign"> assign </a>
40/// * <a href="#bdlb_variant-example-3-visiting-a-variant-via-apply"> Example 3: Visiting a Variant via apply </a>
41/// * <a href="#bdlb_variant-bslmf-nil-passed-to-visitor"> bslmf::Nil Passed to Visitor </a>
42/// * <a href="#bdlb_variant-user-specified-default-value-passed-to-visitor"> User-Specified Default Value Passed to Visitor </a>
43/// * <a href="#bdlb_variant-applyraw-undefined-if-variant-is-unset"> applyRaw Undefined If Variant Is Unset </a>
44/// * <a href="#bdlb_variant-return-value-specified-in-visitor"> Return Value Specified in Visitor </a>
45/// * <a href="#bdlb_variant-return-value-specified-with-function-call"> Return Value Specified with Function Call </a>
46///
47/// # Purpose {#bdlb_variant-purpose}
48/// Provide a variant (discriminated `union`-like) type.
49///
50/// # Classes {#bdlb_variant-classes}
51///
52/// - bdlb::Variant: variant of up to 20 types
53/// - bdlb::Variant2: variant of exactly 2 types
54/// - bdlb::Variant3: variant of exactly 3 types
55/// - bdlb::Variant4: variant of exactly 4 types
56/// - bdlb::Variant5: variant of exactly 5 types
57/// - bdlb::Variant6: variant of exactly 6 types
58/// - bdlb::Variant7: variant of exactly 7 types
59/// - bdlb::Variant8: variant of exactly 8 types
60/// - bdlb::Variant9: variant of exactly 9 types
61/// - bdlb::Variant10: variant of exactly 10 types
62/// - bdlb::Variant11: variant of exactly 11 types
63/// - bdlb::Variant12: variant of exactly 12 types
64/// - bdlb::Variant13: variant of exactly 13 types
65/// - bdlb::Variant14: variant of exactly 14 types
66/// - bdlb::Variant15: variant of exactly 15 types
67/// - bdlb::Variant16: variant of exactly 16 types
68/// - bdlb::Variant17: variant of exactly 17 types
69/// - bdlb::Variant18: variant of exactly 18 types
70/// - bdlb::Variant19: variant of exactly 19 types
71/// - bdlb::VariantImp: variant from a type list
72///
73/// @see
74///
75/// # Description {#bdlb_variant-description}
76/// This component provides: (1) a variant class template,
77/// `bdlb::Variant`, that can store an instance of one of up to some
78/// (implementation-defined) number of parameter types (currently 20), (2)
79/// several variant class templates that accommodate a *fixed* number (from 2
80/// to 19) of types, `bdlb::Variant2`, `bdlb::Variant3`, `bdlb::Variant4`,
81/// `bdlb::Variant5`, `bdlb::Variant6`, `bdlb::Variant7`, `bdlb::Variant8`,
82/// `bdlb::Variant9`, `bdlb::Variant10`, `bdlb::Variant11`, `bdlb::Variant12`,
83/// `bdlb::Variant13`, `bdlb::Variant14`, `bdlb::Variant15`, `bdlb::Variant16`,
84/// `bdlb::Variant17`, `bdlb::Variant18`, and `bdlb::Variant19`, and (3) a final
85/// variant class template, `bdlb::VariantImp`, whose supported types are
86/// specified via a `bslmf::TypeList`. A variant (of any of the aforementioned
87/// classes) can hold any one of the types defined in its signature at any point
88/// in time. Clients can retrieve the value and type that a variant currently
89/// holds, assign a new value to the variant, or apply a visitor to the variant.
90/// A visitor's action is based on the value and type the variant currently
91/// holds. Assigning a value of a new type destroys the object of the old type
92/// and constructs the new value by copy constructing the supplied value.
93///
94/// When the number (`N`) of types that needs to be supported is known, it is
95/// better to use the `bdlb::VariantN` templates that use an identical
96/// implementation, but generate shorter symbols and debugging information due
97/// to the lack of defaulted template argument types. Note that
98/// `bdlb::VariantN<T1, ..., TN>` and `bdlb::Variant<T1, ..., TN>` are,
99/// nevertheless, distinct types.
100///
101/// When the variant types are (directly) supplied as a type list (of type
102/// `bslmf::TypeList`), the type `bdlb::VariantImp<TYPELIST>` can be used in
103/// place of:
104/// @code
105/// bdlb::Variant<typename TYPELIST::Type1, typename TYPELIST::Type2, ...>
106/// @endcode
107///
108/// Lastly, move constructors (taking an optional allocator) and move-assignment
109/// operators are also provided. Note that move semantics are emulated with
110/// C++03 compilers.
111///
112/// ## Default Construction {#bdlb_variant-default-construction}
113///
114///
115/// The `bdlb::Variant` class, when default constructed, does not hold a value
116/// and `isUnset` returns `true`. This state is the same as that of a
117/// `bdlb::Variant` that is reset by the `reset` method.
118///
119/// ## Visitors {#bdlb_variant-visitors}
120///
121///
122/// `bdlb::Variant` provides an `apply` method that implements the visitor
123/// design pattern. `apply` accepts a visitor (functor) that provides an
124/// `operator()` that is invoked with the value that the variant currently
125/// holds.
126///
127/// Note, that visitor must satisfy the following requirements:
128/// * The visitor's `operator()` must be callable with any of the types that
129/// might be contained in the variant.
130/// * For the `apply` methods (but not `applyRaw`) the visitor's `operator()`
131/// must be callable with an argument of type `bslmf::Nil`.
132/// * For the `apply` and `applyRaw` methods returning non-void type the return
133/// value of all callable overloads of `operator()` must be convertible to
134/// this type.
135///
136/// The `apply` method should be preferred over a `switch` statement based on
137/// the type index of a variant. If the order or types contained by the variant
138/// is changed in the future, every place where the type index is hard-coded
139/// needs to be updated. Whereas if `apply` were used, no change would be
140/// needed because function overloading will automatically resolve to the proper
141/// `operator()` to invoke.
142///
143/// There are several variations of the `apply` method, varying based on the
144/// return type and the handling of unset variants. Firstly,
145/// the method varies based on whether `apply` returns a value or not.
146/// There can either be:
147/// * No return value.
148/// * A return type specified in the visitor interface.
149/// * A return type specified explicitly when invoking `apply`.
150///
151/// The default is no return value. Even if visitor's `operator()` returns any
152/// non-void value, it will not be passed to the user. If users would like to
153/// return a value from the visitor's `operator()`, they can specify a public
154/// alias `ResultType` to the desired return type in the functor class. For
155/// example, if `operator()` were to return an `int`, the functor class should
156/// specify:
157/// @code
158/// typedef int ResultType;
159/// @endcode
160/// If `ResultType` cannot be determined, users also have the option of
161/// explicitly specifying the return type when invoking apply:
162/// @code
163/// apply<int>(visitor);
164/// @endcode
165/// Secondly, the `apply` method varies based on how the method handles an unset
166/// variant. A user can choose to:
167/// * Pass a default-constructed `bslmf::Nil` to the visitor.
168/// * Pass a user-specified "default" value to the visitor.
169///
170/// Furthermore, if the user is sure that the variant cannot be unset, the user
171/// can invoke `applyRaw`, which is slightly more efficient. However, if the
172/// variant is, in fact, unset, the behavior of `applyRaw` is undefined.
173///
174/// ## BDEX Streamability {#bdlb_variant-bdex-streamability}
175///
176///
177/// BDEX streaming is not implemented for any of the variant classes.
178///
179/// ## Class Synopsis {#bdlb_variant-class-synopsis}
180///
181///
182/// Due to the complexity of the implementation, the following synopsis is
183/// provided to aid users in locating documentation for functions. Note that
184/// this is not a complete summary of all available methods; only the key
185/// methods are shown. For more information, refer to the function-level
186/// documentation.
187///
188/// ### Creators {#bdlb_variant-creators}
189///
190///
191/// @code
192/// bdlb::Variant()
193/// bdlb::Variant(const TYPE_OR_ALLOCATOR& valueOrAllocator);
194/// bdlb::Variant(const TYPE& value, bslma::Allocator *basicAllocator);
195/// @endcode
196/// Create a variant. Users can choose to initialize a variant with a specified
197/// value, or leave the variant in the unset state (via default construction).
198/// Users can also supply a `bslma::Allocator *` for memory allocation.
199///
200/// ### Manipulators {#bdlb_variant-manipulators}
201///
202///
203/// @code
204/// bdlb::Variant& operator=(const TYPE& value);
205/// @endcode
206/// Assign a different value of template parameter `TYPE` to the variant.
207/// @code
208/// bdlb::Variant& operator=(const bdlb::Variant& rhs);
209/// @endcode
210/// Assign another variant to a variant.
211/// @code
212/// void apply(VISITOR& visitor);
213/// VISITOR::ResultType apply(VISITOR& visitor);
214/// RET_TYPE apply(VISITOR& visitor);
215/// @endcode
216/// Access a variant's value using a specified visitor functor whereby
217/// `bslmf::Nil` is passed to the visitor's `operator()` if the variant is
218/// unset.
219/// @code
220/// void apply(VISITOR& visitor, const TYPE& defaultValue);
221/// VISITOR::ResultType apply(VISITOR& visitor, const TYPE& defaultValue);
222/// RET_TYPE apply(VISITOR& visitor, const TYPE& defaultValue);
223/// @endcode
224/// Access a variant's value using a specified visitor functor whereby a
225/// user-specified default value is passed to the visitor's `operator()` if the
226/// variant is unset.
227/// @code
228/// void applyRaw(VISITOR& visitor);
229/// VISITOR::ResultType applyRaw(VISITOR& visitor);
230/// RET_TYPE applyRaw(VISITOR& visitor);
231/// @endcode
232/// Access a variant's value using a specified visitor functor whereby the
233/// behavior is undefined if the variant is unset.
234/// @code
235/// template <class TYPE>
236/// TYPE& createInPlace();
237/// TYPE& createInPlace(const A1& a1);
238/// // ...
239/// TYPE& createInPlace(const A1& a1, const A2& a2, ..., const A14& a14);
240/// @endcode
241/// Create a new value of template parameter `TYPE` in-place, with up to 14
242/// constructor arguments.
243/// @code
244/// void reset();
245/// @endcode
246/// Reset a variant to the unset state.
247/// @code
248/// template <class TYPE>
249/// TYPE& the();
250/// @endcode
251/// Access the value of template parameter `TYPE` currently held by a variant.
252/// This method should be invoked using the syntax `the<TYPE>()`, e.g.,
253/// `the<int>()`.
254///
255/// ### Accessors {#bdlb_variant-accessors}
256///
257///
258/// @code
259/// template <class TYPE>
260/// bool is() const;
261/// @endcode
262/// Check whether a variant is currently holding a particular type. This
263/// method should be invoked using the syntax `is<TYPE>()`, e.g., `is<int>()`.
264/// @code
265/// bool isUnset() const;
266/// @endcode
267/// Return `true` if a variant is currently unset, and `false` otherwise.
268/// @code
269/// bsl::ostream& print(bsl::ostream& stream,
270/// int level = 0,
271/// int spacesPerLevel = 4) const;
272/// @endcode
273/// Write a description of a variant to a specified `stream`.
274///
275/// ## Usage {#bdlb_variant-usage}
276///
277///
278/// This section illustrates intended use of this component.
279///
280/// ### Example 1: Variant Construction {#bdlb_variant-example-1-variant-construction}
281///
282///
283/// The following example illustrates the different ways of constructing a
284/// `bdlb::Variant`:
285/// @code
286/// typedef bdlb::Variant <int, double, bsl::string> List;
287/// typedef bdlb::Variant3<int, double, bsl::string> List3; // equivalent
288/// @endcode
289/// The contained types can be retrieved as a `bslmf::TypeList` (using the
290/// `TypeList` nested type), or individually (using `TypeN`, for `N` varying
291/// from 1 to the length of the `TypeList`). In the example below, we use the
292/// `List` variant, but this could be substituted with `List3` with no change
293/// to the code:
294/// @code
295/// assert(3 == List::TypeList::LENGTH);
296/// assert(3 == List3::TypeList::LENGTH);
297/// @endcode
298/// We can check that the variant defaults to the unset state by using the
299/// `is<TYPE>` and `typeIndex` methods:
300/// @code
301/// List x;
302///
303/// assert(!x.is<int>());
304/// assert(!x.is<double>());
305/// assert(!x.is<bsl::string>());
306/// assert(0 == x.typeIndex());
307/// @endcode
308/// Single-argument construction from a type in the `TypeList` of a variant is
309/// also supported. This is more efficient than creating an unset variant and
310/// assigning a value to it:
311/// @code
312/// List3 y(bsl::string("Hello"));
313///
314/// assert(!y.is<int>());
315/// assert(!y.is<double>());
316/// assert( y.is<bsl::string>());
317///
318/// assert("Hello" == y.the<bsl::string>());
319/// @endcode
320/// Furthermore, `createInPlace` is provided to support direct in-place
321/// construction. This method allows users to directly construct the target
322/// type inside the variant, instead of first creating a temporary object, then
323/// copy constructing the object to initialize the variant:
324/// @code
325/// List z;
326/// z.createInPlace<bsl::string>("Hello", 5);
327///
328/// assert(!z.is<int>());
329/// assert(!z.is<double>());
330/// assert( z.is<bsl::string>());
331///
332/// assert("Hello" == z.the<bsl::string>());
333/// @endcode
334/// Up to 14 constructor arguments are supported for in-place construction of
335/// an object. Users can also safely create another object of the same or
336/// different type in a variant that already holds a value using the
337/// `createInPlace` method. No memory is leaked in all cases and the destructor
338/// for the currently held object is invoked:
339/// @code
340/// z.createInPlace<bsl::string>("Hello", 5);
341/// assert(z.is<bsl::string>());
342/// assert("Hello" == z.the<bsl::string>());
343///
344/// z.createInPlace<double>(10.0);
345/// assert(z.is<double>());
346/// assert(10.0 == z.the<double>());
347///
348/// z.createInPlace<int>(10);
349/// assert(z.is<int>());
350/// assert(10 == z.the<int>());
351/// @endcode
352/// `createInPlace` returns a reference providing modifiable access to the
353/// created object:
354/// @code
355/// bsl::string& ref = z.createInPlace<bsl::string>("Goodbye");
356/// assert("Goodbye" == z.the<bsl::string>());
357/// assert("Goodbye" == ref);
358/// assert(&ref == &z.the<bsl::string>());
359///
360/// ref = "Hello again!";
361/// assert("Hello again!" == z.the<bsl::string>());
362/// @endcode
363///
364/// ### Example 2: Variant Assignment {#bdlb_variant-example-2-variant-assignment}
365///
366///
367/// A value of a given type can be stored in a variant in three different ways:
368///
369/// * `operator=`
370/// * `assignTo<TYPE>`
371/// * `assign`
372///
373/// `operator=` automatically deduces the type that the user is trying to assign
374/// to the variant. This should be used most of the time. The `assignTo<TYPE>`
375/// method should be used when conversion to the type that the user is assigning
376/// to is necessary (see the first two examples below for more details).
377/// Finally, `assign` is equivalent to `operator=` and exists simply for
378/// backwards compatibility.
379///
380/// #### operator= {#bdlb_variant-operator}
381///
382///
383/// The following example illustrates how to use `operator=`:
384/// @code
385/// typedef bdlb::Variant<int, double, bsl::string> List;
386///
387/// List x;
388///
389/// List::Type1 v1 = 1; // 'int'
390/// List::Type2 v2 = 2.0; // 'double'
391/// List::Type3 v3("hello"); // 'bsl::string'
392///
393/// x = v1;
394/// assert( x.is<int>());
395/// assert(!x.is<double>());
396/// assert(!x.is<bsl::string>());
397/// assert(v1 == x.the<int>());
398///
399/// x = v2;
400/// assert(!x.is<int>());
401/// assert( x.is<double>());
402/// assert(!x.is<bsl::string>());
403/// assert(v2 == x.the<double>());
404///
405/// x = v3;
406/// assert(!x.is<int>());
407/// assert(!x.is<double>());
408/// assert( x.is<bsl::string>());
409/// assert(v3 == x.the<bsl::string>());
410/// @endcode
411/// Note that the type of the object is deduced automatically during assignment,
412/// as in:
413/// @code
414/// x = v1;
415/// @endcode
416/// This automatic deduction, however, cannot be extended to conversion
417/// constructors, such as:
418/// @code
419/// x = static_cast<const char *>("Bye"); // ERROR
420/// @endcode
421/// The compiler will diagnose that `const char *` is not a variant type
422/// specified in the list of parameter types used in the definition of `List`,
423/// and will trigger a compile-time assertion. To overcome this problem, see
424/// the next usage example of `assignTo<TYPE>`.
425///
426/// #### assignTo<TYPE> {#bdlb_variant-assignto-type}
427///
428///
429/// In the previous example, `const char *` was not part of the variant's type
430/// list, which resulted in a compilation diagnostic. The use of
431/// `assignTo<TYPE>` explicitly informs the compiler of the intended type to
432/// assign to the variant:
433/// @code
434/// x.assignTo<bsl::string>(static_cast<const char *>("Bye"));
435///
436/// assert(!x.is<int>());
437/// assert(!x.is<double>());
438/// assert( x.is<bsl::string>());
439///
440/// assert("Bye" == x.the<bsl::string>());
441/// @endcode
442///
443/// #### assign {#bdlb_variant-assign}
444///
445///
446/// Finally, for backwards compatibility, `assign` can also be used in place of
447/// `operator=` (but not `assignTo`):
448/// @code
449/// x.assign<int>(v1);
450/// assert( x.is<int>());
451/// assert(!x.is<double>());
452/// assert(!x.is<bsl::string>());
453/// assert(v1 == x.the<int>());
454///
455/// x.assign<double>(v2);
456/// assert(!x.is<int>());
457/// assert( x.is<double>());
458/// assert(!x.is<bsl::string>());
459/// assert(v2 == x.the<double>());
460///
461/// x.assign<bsl::string>(v3);
462/// assert(!x.is<int>());
463/// assert(!x.is<double>());
464/// assert( x.is<bsl::string>());
465/// assert(v3 == x.the<bsl::string>());
466/// @endcode
467///
468/// ### Example 3: Visiting a Variant via apply {#bdlb_variant-example-3-visiting-a-variant-via-apply}
469///
470///
471/// As described in {Visitors} (above), there are different ways to invoke the
472/// `apply` method. The first two examples below illustrate the different ways
473/// to invoke `apply` (with no return value) to control the behavior of visiting
474/// an unset variant:
475/// * `bslmf::Nil` is passed to the visitor.
476/// * A user-specified default value is passed to the visitor.
477///
478/// A third example illustrates use of `applyRaw`, the behavior of which is
479/// undefined if the variant is unset. Two final examples illustrate different
480/// ways to specify the return value from `apply`:
481/// * The return value is specified in the visitor.
482/// * The return value is specified with the function call.
483///
484/// #### bslmf::Nil Passed to Visitor {#bdlb_variant-bslmf-nil-passed-to-visitor}
485///
486///
487/// A simple visitor that does not require any return value might be one that
488/// prints the value of the variant to `stdout`:
489/// @code
490/// class my_PrintVisitor {
491/// public:
492/// template <class TYPE>
493/// void operator()(const TYPE& value) const
494/// {
495/// bsl::cout << value << bsl::endl;
496/// }
497///
498/// void operator()(bslmf::Nil value) const
499/// {
500/// bsl::cout << "null" << bsl::endl;
501/// }
502/// };
503///
504/// typedef bdlb::Variant<int, double, bsl::string> List;
505///
506/// List x[4];
507///
508/// // Note that 'x[3]' is uninitialized.
509///
510/// x[0].assign(1);
511/// x[1].assign(1.1);
512/// x[2].assignTo<bsl::string>(static_cast<const char *>("Hello"));
513///
514/// my_PrintVisitor printVisitor;
515///
516/// for (int i = 0; i < 4; ++i) {
517/// x[i].apply(printVisitor);
518/// }
519/// @endcode
520/// The above prints the following on `stdout`:
521/// @code
522/// 1
523/// 1.1
524/// Hello
525/// null
526/// @endcode
527/// Note that `operator()` is overloaded with `bslmf::Nil`. A direct match has
528/// higher precedence than a template parameter match. When the variant is
529/// unset (such as `x[3]`), a `bslmf::Nil` is passed to the visitor.
530///
531/// #### User-Specified Default Value Passed to Visitor {#bdlb_variant-user-specified-default-value-passed-to-visitor}
532///
533///
534/// Instead of using `bslmf::Nil`, users can also specify a default value to
535/// pass to the visitor when the variant is currently unset. Using the same
536/// `my_PrintVisitor` class from the previous example:
537/// @code
538/// for (int i = 0; i < 4; ++i) {
539/// x[i].apply(printVisitor, "Print this when unset");
540/// }
541/// @endcode
542/// Now, the above code prints the following on `stdout`:
543/// @code
544/// 1
545/// 1.1
546/// Hello
547/// Print this when unset
548/// @endcode
549/// This variation of `apply` is useful since the user can provide a default
550/// value to the visitor without incurring the cost of initializing the variant
551/// itself.
552///
553/// #### applyRaw Undefined If Variant Is Unset {#bdlb_variant-applyraw-undefined-if-variant-is-unset}
554///
555///
556/// If it is certain that a variant is not unset, then the `applyRaw` method can
557/// be used instead of `apply`. `applyRaw` is slightly more efficient than
558/// `apply`, but the behavior of `applyRaw` is undefined if the variant is
559/// unset. In the following application of `applyRaw`, we purposely circumvent
560/// `x[3]` from being visited because we know that it is unset:
561/// @code
562/// for (int i = 0; i < 3; ++i) { // NOT 'i < 4' as above.
563/// assert(!x[i].isUnset());
564/// x[i].applyRaw(printVisitor); // undefined behavior for 'x[3]'
565/// }
566/// assert(x[3].isUnset());
567/// @endcode
568///
569/// #### Return Value Specified in Visitor {#bdlb_variant-return-value-specified-in-visitor}
570///
571///
572/// Users can also specify a return type that `operator()` will return by
573/// specifying a `typedef` with the name `ResultType` in their functor class.
574/// This is necessary in order for the `apply` method to know what type to
575/// return at compile time:
576/// @code
577/// class my_AddVisitor {
578/// public:
579/// typedef bool ResultType;
580///
581/// // Note that the return type of 'operator()' is 'ResultType'.
582///
583/// template <class TYPE>
584/// ResultType operator()(TYPE& value) const
585/// // Return 'true' when addition is performed successfully, and
586/// // 'false' otherwise.
587/// {
588/// if (bsl::is_convertible<TYPE, double>::value) {
589///
590/// // Add certain values to the variant. The details are elided
591/// // as it is the return value that is the focus of this example.
592///
593/// return true; // RETURN
594/// }
595/// return false;
596/// }
597/// };
598///
599/// typedef bdlb::Variant<int, double, bsl::string> List;
600///
601/// List x[3];
602///
603/// x[0].assign(1);
604/// x[1].assign(1.1);
605/// x[2].assignTo<bsl::string>(static_cast<const char *>("Hello"));
606///
607/// my_AddVisitor addVisitor;
608///
609/// bool ret[3];
610///
611/// for (int i = 0; i < 3; ++i) {
612/// ret[i] = x[i].apply(addVisitor);
613/// if (!ret[i]) {
614/// bsl::cout << "Cannot add to types not convertible to 'double'."
615/// << bsl::endl;
616/// }
617/// }
618/// assert(true == ret[0]);
619/// assert(true == ret[1]);
620/// assert(false == ret[2]);
621/// @endcode
622/// The above prints the following on `stdout`:
623/// @code
624/// Cannot add to types not convertible to 'double'.
625/// @endcode
626/// Note that if no `typedef` is provided (as in the `my_PrintVisitor` class),
627/// then the default return value is `void`.
628///
629/// #### Return Value Specified with Function Call {#bdlb_variant-return-value-specified-with-function-call}
630///
631///
632/// There may be some cases when a visitor interface is not owned by a client
633/// (hence the client cannot add a `typedef` to the visitor), or the visitor
634/// could not determine the return type at design time. In these scenarios,
635/// users can explicitly specify the return type when invoking `apply`:
636/// @code
637/// class ThirdPartyVisitor {
638/// public:
639/// template <class TYPE>
640/// bsl::string operator()(const TYPE& value) const;
641/// // Return the name of the specified 'value' as a 'bsl::string'.
642/// // Note that the implementation of this class is deliberately not
643/// // shown since this class belongs to a third-party library.
644/// };
645///
646/// typedef bdlb::Variant<int, double, bsl::string> List;
647///
648/// List x[3];
649///
650/// x[0].assign(1);
651/// x[1].assign(1.1);
652/// x[2].assignTo<bsl::string>(static_cast<const char *>("Hello"));
653///
654/// ThirdPartyVisitor visitor;
655///
656/// for (int i = 0; i < 3; ++i) {
657///
658/// // Note that the return type is explicitly specified.
659///
660/// bsl::string ret = x[i].apply<bsl::string>(visitor);
661/// bsl::cout << ret << bsl::endl;
662/// }
663/// @endcode
664/// @}
665/** @} */
666/** @} */
667
668/** @addtogroup bdl
669 * @{
670 */
671/** @addtogroup bdlb
672 * @{
673 */
674/** @addtogroup bdlb_variant
675 * @{
676 */
677
678#include <bdlscm_version.h>
679
680#include <bdlb_printmethods.h>
681
682#include <bslalg_swaputil.h>
683
684#include <bslma_allocator.h>
686#include <bslma_default.h>
689
690#include <bslmf_assert.h>
691#include <bslmf_conditional.h>
692#include <bslmf_enableif.h>
696#include <bslmf_isconvertible.h>
697#include <bslmf_issame.h>
698#include <bslmf_movableref.h>
700#include <bslmf_nil.h>
701#include <bslmf_removeconst.h>
702#include <bslmf_removecvref.h>
704#include <bslmf_typelist.h>
705#include <bslmf_util.h> // 'forward(V)'
706
710
711#include <bsls_assert.h>
713#include <bsls_objectbuffer.h>
714#include <bsls_util.h> // 'forward<T>(V)'
715
716#include <bsl_algorithm.h>
717#include <bsl_iosfwd.h>
718
719#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
720#include <bslmf_if.h>
721#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
722
723#ifndef BDE_OMIT_INTERNAL_DEPRECATED
726
727#include <bsl_typeinfo.h>
728#endif // BDE_OMIT_INTERNAL_DEPRECATED
729
730#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
731// clang-format off
732// Include version that can be compiled with C++03
733// Generated on Mon Jan 13 08:32:07 2025
734// Command line: sim_cpp11_features.pl bdlb_variant.h
735
736# define COMPILING_BDLB_VARIANT_H
737# include <bdlb_variant_cpp03.h>
738# undef COMPILING_BDLB_VARIANT_H
739
740// clang-format on
741#else
742
743#if defined(BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES) \
744 && defined(BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES)
745///
746/// \note Note that this macro definition parallels that of a similar macro
747/// defined in `bslmf_typelist.h`.
748#define BDLB_VARIANT_USING_VARIADIC_TEMPLATES
749#endif
750
751
752namespace bdlb {
753
754struct Variant_CopyAssignVisitor;
755struct Variant_CopyConstructVisitor;
756struct Variant_DefaultConstructVisitor;
757struct Variant_DestructorVisitor;
758struct Variant_EqualityTestVisitor;
759struct Variant_MoveAssignVisitor;
760struct Variant_MoveConstructVisitor;
761struct Variant_PrintVisitor;
762
763template <class TYPES>
764class VariantImp;
765
766template <class TYPES, class TYPE>
767struct Variant_TypeIndex;
768
769 // ================================
770 // struct Variant_ReturnValueHelper
771 // ================================
772
773// These definitions are provided outside of 'Variant_ReturnValueHelper'
774// because of a bug in the IBM xlC compiler.
776typedef struct { char a[2]; } Variant_ReturnValueHelper_NoType;
777
780
781/// This struct is a component-private struct. Do *not* use. This provides
782/// functions, the matching of which are used by Variant_ReturnValueHelper
783/// to determine whether the template parameter type `VISITOR` has the
784/// member `ResultType` defined.
785///
786/// See @ref bdlb_variant
788
789 /// Return `YesType` if `T::ResultType` exists, and `NoType` otherwise.
790 ///
791 /// \note Note that if `T::ResultType` exists, then the first function is a
792 /// better match than the ellipsis version.
793 template <class T>
796 template <class T>
798};
799
800/// This struct is a component-private meta-function. Do *not* use. This
801/// meta-function checks whether the template parameter type `VISITOR` has
802/// the member `ResultType` defined using "SFINAE" (Substitution Failure Is
803/// Not An Error). A `value` of `true` indicates `VISITOR::ResultType`
804/// exists, and `false` otherwise.
805template <class VISITOR>
808 bool,
809 sizeof(Variant_ReturnValueHelper_Matcher::match<VISITOR>(0)) ==
810 sizeof(Variant_ReturnValueHelper_YesType)> {
811};
812
813 // =====================================
814 // class VariantImp_AllocatorBase<TYPES>
815 // =====================================
816
817/// This class is component-private. Do not use. This class contains the
818/// `typedef`s and data members of the `Variant` class, and serves as the
819/// base class for the variant when any one of the types held by the variant
820/// has the `bslma::UsesBslmaAllocator` type trait.
821///
822/// See @ref bdlb_variant
823template <class TYPES>
825
826 public:
827 // TYPES
828
829 /// `TypeList` is an alias for the `bslmf::TypeList` type serving as the
830 /// template parameter to this variant implementation.
831 typedef TYPES TypeList;
832
852
853 /// `TypeN` is an alias for the `N`th type in the `TypeList` of this
854 /// variant implementation. If less than `N` template arguments were
855 /// given to the `Variant` type, then `TypeN` is `bslmf::Nil`.
857
858 private:
859 union Value {
880 };
881 // 'Value' is a union of 'bsls::ObjectBuffer' of all types contained by
882 // the variant. 'bsls::ObjectBuffer' is used to: 1) wrap non-POD types
883 // within the union, and 2) ensure proper alignment of the types.
884
885 // DATA
886 Value d_value; // value of the object, initialized by
887 // derived class
888
889 int d_type; // current type the variant is holding (0
890 // if unset)
891
892 bslma::Allocator *d_allocator_p; // pointer to allocator (held, not owned)
893
894 // FRIENDS
895 template <class VARIANT_TYPES>
896 friend class VariantImp;
897
898 template <class VARIANT_TYPES>
901
902 public:
903 // TRAITS
906
907 // CREATORS
908 VariantImp_AllocatorBase(int type, bslma::Allocator *basicAllocator);
909
910 /// Create a `VariantImp_AllocatorBase` with the specified `type`
911 /// indicating the type of the object that the variant will initially
912 /// hold, and the specified `basicAllocator` to supply memory.
914 bslma::Allocator *basicAllocator,
916
917 template <class TYPE>
918 VariantImp_AllocatorBase(int type, const TYPE&, bsl::false_type);
919
920 // ACCESSORS
921
922 /// Return the allocator used by this object to supply memory.
924};
925
926 // =======================================
927 // class VariantImp_NoAllocatorBase<TYPES>
928 // =======================================
929
930/// This class is component-private. Do not use. This class contains the
931/// `typedef`s and data members of the `Variant` class, and serves as the
932/// base class for the variant when none of the types held by the variant
933/// has the `bslma::UsesBslmaAllocator` type trait. The goal is to optimize
934/// the size of the variant to avoid holding an unnecessary allocator
935/// pointer.
936///
937/// See @ref bdlb_variant
938template <class TYPES>
940
941 public:
942 // TYPES
943
944 /// `TypeList` is an alias for the `bslmf::TypeList` type serving as the
945 /// template parameter to this variant implementation.
946 typedef TYPES TypeList;
947
967
968 /// `TypeN` is an alias for the `N`th type in the `TypeList` of this
969 /// variant implementation. If less than `N` template arguments were
970 /// given to the `Variant` type, then `TypeN` is `bslmf::Nil`.
972
973 private:
974 union Value {
995 };
996 // 'Value' is a union of 'bsls::ObjectBuffer' of all types contained by
997 // the variant. 'bsls::ObjectBuffer' is used to: 1) wrap non-POD types
998 // within the union, and 2) ensure proper alignment of the types.
999
1000 // DATA
1001 Value d_value; // value of the object, initialized by derived class
1002 int d_type; // current type the variant is holding (0 if unset)
1003
1004 // FRIENDS
1005 template <class VARIANT_TYPES>
1006 friend class VariantImp;
1007
1008 template <class VARIANT_TYPES>
1011
1012 public:
1013 // CREATORS
1015
1016 /// Create a `VariantImp_NoAllocatorBase` with the specified `type`
1017 /// indicating the type of the object that the variant will initially
1018 /// hold.
1020
1021 template <class TYPE>
1022 VariantImp_NoAllocatorBase(int type, const TYPE&, bsl::false_type);
1023
1024 // ACCESSORS
1025
1026 /// Return 0.
1027 /// \note Note that this object does not hold an allocator pointer.
1029};
1030
1031 // ========================
1032 // struct VariantImp_Traits
1033 // ========================
1034
1035/// This struct is component-private. Do not use. This meta-function
1036/// selects `VariantImp_AllocatorBase` as a base class type if any one of
1037/// the types held by a variant has the `bslma::UsesBslmaAllocator` trait,
1038/// and `VariantImp_NoAllocatorBase` otherwise.
1039///
1040/// See @ref bdlb_variant
1041template <class TYPES>
1043
1044 // TYPES
1065
1066 enum {
1088
1110
1132#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1136#endif // BDE_OMIT_INTERNAL_DEPRECATED
1138
1139 /// Determines what the base type is.
1144};
1145
1146 // ==============================
1147 // class Variant_RawVisitorHelper
1148 // ==============================
1149
1150/// This `struct` provides a helper for implementing `Variant::applyRaw`
1151/// that enables `applyRaw` to support visitor functors that do not provide
1152/// an overload for `operator()(bslmf::Nil)`. Objects of this type are
1153/// constructed using a functor of (template parameter) type `VISITOR`,
1154/// whose `operator()` returns the (template parameter) type `RESULT_TYPE`.
1155/// A `Variant_RawVisitorHelper` wraps a functor of type `VISITOR` and
1156/// provides an implementation of `operator()(bslmf::Nil)` that performs a `BSLS_ASSERT_OPT(false)`.
1157///
1158/// \note Note that this overload is needed to enable
1159/// compilation (specifically, to instantiate `doApply` and `doApplyR`), but
1160/// is never invoked by any code path at runtime.
1161///
1162/// See @ref bdlb_variant
1163template <class RESULT_TYPE, class VISITOR>
1165
1166 // DATA
1167 VISITOR *d_visitor; // visitor to which this helper delegates
1168
1169 public:
1170 // CREATORS
1171
1172 /// Create a `RawVisitorHelper` functor that delegates to the specified
1173 /// `visitor`.
1174 explicit
1175 Variant_RawVisitorHelper(VISITOR *visitor);
1176
1177 // MANIPULATORS
1178
1179 /// Invoke the functor supplied at construction with the specified
1180 /// `argument`, and return the result.
1181 template <class ARGUMENT_TYPE>
1182 RESULT_TYPE operator()(ARGUMENT_TYPE& argument);
1183 template <class ARGUMENT_TYPE>
1184 RESULT_TYPE operator()(const ARGUMENT_TYPE& argument);
1185
1186 // ACCESSORS
1187
1188 /// Invoke the functor supplied at construction with the specified
1189 /// `argument`, and return the result.
1190 template <class ARGUMENT_TYPE>
1191 RESULT_TYPE operator()(ARGUMENT_TYPE& argument) const;
1192 template <class ARGUMENT_TYPE>
1193 RESULT_TYPE operator()(const ARGUMENT_TYPE& argument) const;
1194
1195 /// Do not call. The behavior of this method is undefined.
1196 RESULT_TYPE operator()(bslmf::Nil) const;
1197};
1198
1199 // =======================
1200 // class VariantImp<TYPES>
1201 // =======================
1202
1203/// This class provides the implementation of `Variant` (except for the
1204/// creators) given a list of template parameter `TYPES`.
1205///
1206/// More generally, if each of the types in the list of `TYPES` is
1207/// value semantic, then this class also supports a complete set of *value*
1208/// *semantic* operations, including copy construction, assignment, equality
1209/// comparison, and `ostream` printing. A precise operational definition of
1210/// when two instances have the same value can be found in the description
1211/// of `operator==` for the class. This class is *exception* *neutral* with
1212/// no guarantee of rollback: if an exception is thrown during the
1213/// invocation of a method on a pre-existing instance, the object is left in
1214/// a valid state, but its value is undefined. In no event is memory
1215/// leaked. Finally, *aliasing* (e.g., using all or part of an object as
1216/// both source and destination) is supported in all cases.
1217///
1218/// If any of the types in the list of `TYPES` does not support
1219/// `operator==`, or any of the value-semantic operations mentioned above,
1220/// then this variant also does not support that operation and attempts to
1221/// invoke it will trigger a compilation diagnostic.
1222///
1223/// See @ref bdlb_variant
1224template <class TYPES>
1225class VariantImp : public VariantImp_Traits<TYPES>::BaseType {
1226
1227 // PRIVATE TYPES
1228 typedef VariantImp_Traits<TYPES> Traits;
1229 typedef typename Traits::BaseType Base;
1231
1232 /// `SelfType` is an alias to this class.
1233 typedef VariantImp<TYPES> SelfType;
1234
1235 private:
1236 // PRIVATE MANIPULATORS
1237
1238 /// Invoke `operator()` of the specified `visitor` on the current value
1239 /// (of template parameter `TYPE`) held by this variant. `TYPE` must be
1240 /// the same as one of the types that this variant can hold.
1241 ///
1242 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
1243 ///
1244 /// \note Note that the second argument is for resolving
1245 /// overloading ambiguity and is not used.
1246 template <class TYPE, class VISITOR_REF>
1247 void applyImp(VISITOR_REF visitor, bsl::false_type);
1248 template <class TYPE, class VISITOR_REF>
1249 void applyImp(VISITOR_REF visitor, bsl::true_type);
1250 template <class TYPE, class VISITOR_REF>
1251 void applyImp(VISITOR_REF visitor);
1252
1253 /// Invoke `operator()` of the specified `visitor` on the current value
1254 /// (of template parameter `TYPE`) held by this variant, and return the
1255 /// value (of template parameter `RET_TYPE`) returned by the `visitor`.
1256 /// `TYPE` must be the same as one of the types that this variant can hold.
1257 ///
1258 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
1259 ///
1260 /// \note Note that the second argument is for
1261 /// resolving overloading ambiguity and is not used.
1262 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1263 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::false_type);
1264 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1265 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::true_type);
1266 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1267 RET_TYPE applyImpR(VISITOR_REF visitor);
1268
1269 /// Assign to this variant the specified `value` of template parameter
1270 /// `SOURCE_TYPE` converted to template parameter `TYPE`. `TYPE` must
1271 /// be the same as one of the types that this variant can hold and
1272 /// `SOURCE_TYPE` must be convertible to `TYPE`.
1273 template <class TYPE, class SOURCE_TYPE>
1274 void assignImp(const SOURCE_TYPE& value);
1275
1276 template <class TYPE>
1277#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1278 void assignImp(TYPE&& value);
1279#else
1280 void assignImp(bslmf::MovableRef<TYPE> value);
1281#endif
1282 // Assign to this variant the specified 'value' of template parameter
1283 // 'TYPE'. The contents of 'value' are moved to this object with
1284 // 'value' left in a valid but unspecified state. 'TYPE' must be the
1285 // same as one of the types that this variant can hold.
1286
1287 /// Construct this variant object to initially hold the specified
1288 /// `value` of template parameter `TYPE`. `TYPE` must be the same as one of the types that this variant can hold.
1289 ///
1290 /// \note Note that the second
1291 /// parameter is for resolving overloading ambiguity and is not used.
1292 template <class TYPE>
1293 void create(const TYPE& value, bsl::false_type);
1294
1295 /// Construct this variant object to be initially in the unset state.
1296 void create(bslma::Allocator *, bsl::true_type);
1297
1298 /// Apply the specified `visitor` on the current value held by this
1299 /// variant by invoking `applyImp` with the appropriate template
1300 /// arguments, determined by the specified `type`.
1301 ///
1302 /// \pre The behavior is undefined unless `type != 0`.
1303 template <class VISITOR_REF>
1304 void doApply(VISITOR_REF visitor, int type);
1305
1306 /// Apply the specified `visitor` on the current value held by this
1307 /// variant by invoking `applyImpR` with the appropriate template
1308 /// arguments, determined by the specified `type`, and return the value
1309 /// (of template parameter `RET_TYPE`) returned by the `visitor`.
1310 ///
1311 /// \pre The behavior is undefined unless `type != 0`.
1312 template <class VISITOR_REF, class RET_TYPE>
1313 RET_TYPE doApplyR(VISITOR_REF visitor, int type);
1314
1315 // PRIVATE ACCESSORS
1316
1317 /// Invoke `operator()` of the specified `visitor` on the current value
1318 /// (of template parameter `TYPE`) held by this variant. `TYPE` must be
1319 /// the same as one of the types that this variant can hold.
1320 ///
1321 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
1322 ///
1323 /// \note Note that the second argument is for resolving
1324 /// overloading ambiguity and is not used.
1325 template <class TYPE, class VISITOR_REF>
1326 void applyImp(VISITOR_REF visitor, bsl::false_type) const;
1327 template <class TYPE, class VISITOR_REF>
1328 void applyImp(VISITOR_REF visitor, bsl::true_type) const;
1329 template <class TYPE, class VISITOR_REF>
1330 void applyImp(VISITOR_REF visitor) const;
1331
1332 /// Invoke `operator()` of the specified `visitor` on the current value
1333 /// (of template parameter `TYPE`) held by this variant, and return the
1334 /// value (of template parameter `RET_TYPE`) returned by the `visitor`.
1335 /// `TYPE` must be the same as one of the types that this variant can hold.
1336 ///
1337 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
1338 ///
1339 /// \note Note that the second argument is for
1340 /// resolving overloading ambiguity and is not used.
1341 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1342 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::false_type) const;
1343 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1344 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::true_type) const;
1345 template <class TYPE, class VISITOR_REF, class RET_TYPE>
1346 RET_TYPE applyImpR(VISITOR_REF visitor) const;
1347
1348 /// Apply the specified `visitor` on the current value held by this
1349 /// variant by invoking `applyImp` with the appropriate template
1350 /// arguments, determined by the specified `type`.
1351 ///
1352 /// \pre The behavior is undefined unless `type != 0`.
1353 template <class VISITOR_REF>
1354 void doApply(VISITOR_REF visitor, int type) const;
1355
1356 /// Apply the specified `visitor` on the current value held by this
1357 /// variant by invoking `applyImpR` with the appropriate template
1358 /// arguments, determined by the specified `type`, and return the value
1359 /// (of template parameter `RET_TYPE`) returned by the `visitor`.
1360 ///
1361 /// \pre The behavior is undefined unless `type != 0`.
1362 template <class VISITOR_REF, class RET_TYPE>
1363 RET_TYPE doApplyR(VISITOR_REF visitor, int type) const;
1364
1365 public:
1366 // TRAITS
1369 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
1372 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
1375 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
1377
1378 // CREATORS
1379
1380 /// Create a variant object in the unset state that uses the currently
1381 /// installed default allocator to supply memory.
1383
1384 /// Create a variant object with the specified `valueOrAllocator` that
1385 /// can be either a value of a type that the variant can hold or an
1386 /// allocator to supply memory. If `valueOrAllocator` is not a
1387 /// `bslma::Allocator *`, then the variant will hold the value and type
1388 /// of `valueOrAllocator`, and use the currently installed default
1389 /// allocator to supply memory. Otherwise, the variant will be unset
1390 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
1391 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
1392 ///
1393 /// \note Note that this
1394 /// parameterized constructor is defined instead of two constructors
1395 /// (one taking a `bslma::Allocator *` and the other not) because
1396 /// template parameter arguments are always a better match than
1397 /// derived-to-base conversion (a concrete allocator pointer converted
1398 /// to `bslma::Allocator *`).
1399 template <class TYPE_OR_ALLOCATOR>
1400 explicit
1401 VariantImp(const TYPE_OR_ALLOCATOR& valueOrAllocator);
1402
1403 /// Create a variant object having the specified `value` of template
1404 /// parameter `TYPE` and that uses the specified `basicAllocator` to
1405 /// supply memory. If `basicAllocator` is 0, the currently installed
1406 /// default allocator is used. `TYPE` must be the same as one of the
1407 /// types that this variant can hold.
1408 template <class TYPE>
1409 VariantImp(const TYPE& value, bslma::Allocator *basicAllocator);
1410
1411 template <class TYPE>
1412 explicit
1413#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1414 VariantImp(TYPE&& value,
1415 typename bsl::enable_if<
1416 !bsl::is_same<
1417 SelfType,
1418 typename bsl::remove_const<
1419 typename bsl::remove_reference<TYPE>::type>::type>::value
1420 &&
1422 void>::type * = 0);
1423#else
1425#endif
1426 // Create a variant object having the specified 'value' of template
1427 // parameter 'TYPE' by moving the contents of 'value' to the
1428 // newly-created object. Use the currently installed default allocator
1429 // to supply memory. 'value' is left in a valid but unspecified state.
1430 // 'TYPE' must be the same as one of the types that this variant can
1431 // hold. Note that in C++11 mode, this method does not participate in
1432 // overload resolution if it would lead to ambiguity with the move
1433 // constructor that does not take an allocator (below) or with the
1434 // constructor taking a 'valueOrAllocator' (above).
1435
1436 template <class TYPE>
1437#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1438 VariantImp(TYPE&& value,
1439 typename bsl::enable_if<
1440 !bsl::is_same<
1441 SelfType,
1442 typename bsl::remove_const<
1443 typename bsl::remove_reference<TYPE>::type>::type>::value,
1444 bslma::Allocator>::type *basicAllocator);
1445#else
1447 bslma::Allocator *basicAllocator);
1448#endif
1449 // Create a variant object having the specified 'value' of template
1450 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
1451 // memory. If 'basicAllocator' is 0, the currently installed default
1452 // allocator is used. The contents of 'value' are moved to the
1453 // newly-created object with 'value' left in a valid but unspecified
1454 // state. 'TYPE' must be the same as one of the types that this
1455 // variant can hold. Note that in C++11 mode, this method does not
1456 // participate in overload resolution if it would lead to ambiguity
1457 // with the move constructor that takes an allocator (below).
1458
1459 /// Create a variant object having the type and value of the specified
1460 /// `original` variant. Optionally specify a `basicAllocator` used to
1461 /// supply memory. If `basicAllocator` is 0, the currently installed
1462 /// default allocator is used.
1463 VariantImp(const VariantImp& original,
1464 bslma::Allocator *basicAllocator = 0);
1465
1466 /// Create a variant object having the type and value of the specified
1467 /// `original` object by moving the contents of `original` to the
1468 /// newly-created object. The allocator associated with `original` (if
1469 /// any) is propagated for use in the newly-created object. `original`
1470 /// is left in a valid but unspecified state.
1472
1473 /// Create a variant object having the type and value of the specified
1474 /// `original` object that uses the specified `basicAllocator` to supply
1475 /// memory. If `basicAllocator` is 0, the currently installed default
1476 /// allocator is used. The contents of `original` are moved to the
1477 /// newly-created object with `original` left in a valid but unspecified
1478 /// state.
1480 bslma::Allocator *basicAllocator);
1481
1482 /// Destroy this variant object, invoking the destructor of the type of
1483 /// object contained (if any) on the value of that type.
1485
1486 // MANIPULATORS
1487
1488 /// Assign to this object the specified `value` of template parameter
1489 /// `TYPE`, and return a reference providing modifiable access to this
1490 /// object. The value currently held by this variant (if any) is
1491 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
1492 /// must be the same as one of the types that this variant can hold.
1493 template <class TYPE>
1494 VariantImp& operator=(const TYPE& value);
1495
1496 template <class TYPE>
1497#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1498 typename bsl::enable_if<
1499 !bsl::is_same<SelfType,
1500 typename bsl::remove_cvref<TYPE>::type>::value,
1501 SelfType>::type&
1502 operator=(TYPE&& value);
1503#else
1504 VariantImp&
1506#endif
1507 // Assign to this object the specified 'value' of template parameter
1508 // 'TYPE', and return a reference providing modifiable access to this
1509 // object. The contents of 'value' are moved to this object with
1510 // 'value' left in a valid but unspecified state. The value currently
1511 // held by this variant (if any) is destroyed if that value's type is
1512 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
1513 // that this variant can hold. Note that in C++11 mode, this method
1514 // does not participate in overload resolution if it would lead to
1515 // ambiguity with the move-assignment operator (below).
1516
1517 /// Assign to this object the type and value currently held by the
1518 /// specified `rhs` object, and return a reference providing modifiable
1519 /// access to this object. The value currently held by this variant
1520 /// (if any) is destroyed if that value's type is not the same as the
1521 /// type held by the `rhs` object.
1523
1524 /// Assign to this object the type and value currently held by the
1525 /// specified `rhs` object, and return a reference providing modifiable
1526 /// access to this object. The contents of `rhs` are either
1527 /// move-inserted into or move-assigned to this object with `rhs` left
1528 /// in a valid but unspecified state.
1530
1531 /// Apply the specified `visitor` to this modifiable variant by passing
1532 /// the value this variant currently holds to the `visitor` object's
1533 /// `operator()`, and return the value returned by the `visitor`. If
1534 /// this variant is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1535 ///
1536 /// \note Note that this method is selected only if the
1537 /// template parameter type `VISITOR` defines a `typedef` of
1538 /// `ResultType` in its public interface. Also note that this method is
1539 /// defined inline to work around a Windows compiler bug with SFINAE
1540 /// functions.
1541 template <class VISITOR>
1543 typename VISITOR::ResultType>::type
1544 apply(VISITOR& visitor) {
1545
1546 if (this->d_type) {
1547 return doApplyR<VISITOR&,
1548 typename VISITOR::ResultType>(visitor, this->d_type);
1549 // RETURN
1550 }
1551
1552 bslmf::Nil nil = bslmf::Nil();
1553 return visitor(nil);
1554 }
1555
1556 /// Apply the specified `visitor` to this modifiable variant by passing
1557 /// the value this variant currently holds to the `visitor` object's
1558 /// `operator()`, and return the value returned by the `visitor`. If
1559 /// If this variant is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1560 ///
1561 /// \note Note that this method is selected only if
1562 /// the template parameter type `VISITOR` defines a `typedef` of
1563 /// `ResultType` in its public interface. Also note that this method is
1564 /// defined inline to work around a Windows compiler bug with SFINAE
1565 /// functions.
1566 template <class VISITOR>
1568 typename VISITOR::ResultType>::type
1569 apply(const VISITOR& visitor) {
1570
1571 if (this->d_type) {
1572 return doApplyR<const VISITOR&,
1573 typename VISITOR::ResultType>(visitor, this->d_type);
1574 // RETURN
1575 }
1576
1577 bslmf::Nil nil = bslmf::Nil();
1578 return visitor(nil);
1579 }
1580
1581 /// Apply the specified `visitor` to this modifiable variant by passing
1582 /// the value (of template parameter `TYPE`) this variant currently
1583 /// holds to the `visitor` object's `operator()`, and return the value
1584 /// returned by the `visitor`. If this variant is unset, the specified
1585 /// `defaultValue` of template parameter `TYPE` is passed to the
1586 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1587 ///
1588 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1589 ///
1590 /// \note Note that this
1591 /// method is selected only if the template parameter type `VISITOR`
1592 /// defines a `typedef` of `ResultType` in its public interface. Also
1593 /// note that this method is defined inline to work around a Windows
1594 /// compiler bug with SFINAE functions.
1595 template <class VISITOR, class TYPE>
1597 typename VISITOR::ResultType>::type
1598 apply(VISITOR& visitor, const TYPE& defaultValue) {
1599
1600 if (this->d_type) {
1601 return doApplyR<VISITOR&,
1602 typename VISITOR::ResultType>(visitor, this->d_type);
1603 // RETURN
1604 }
1605
1606 return visitor(defaultValue);
1607 }
1608
1609 /// Apply the specified `visitor` to this modifiable variant by passing
1610 /// the value (of template parameter `TYPE`) this variant currently
1611 /// holds to the `visitor` object's `operator()`, and return the value
1612 /// returned by the `visitor`. If this variant is unset, the specified
1613 /// `defaultValue` of template parameter `TYPE` is passed to the
1614 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1615 ///
1616 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1617 ///
1618 /// \note Note that this
1619 /// method is selected only if the template parameter type `VISITOR`
1620 /// defines a `typedef` of `ResultType` in its public interface. Also
1621 /// note that this method is defined inline to work around a Windows
1622 /// compiler bug with SFINAE functions.
1623 template <class VISITOR, class TYPE>
1625 typename VISITOR::ResultType>::type
1626 apply(const VISITOR& visitor, const TYPE& defaultValue) {
1627
1628 if (this->d_type) {
1629 return doApplyR<const VISITOR&,
1630 typename VISITOR::ResultType>(visitor, this->d_type);
1631 // RETURN
1632 }
1633
1634 return visitor(defaultValue);
1635 }
1636
1637 /// Apply the specified `visitor` to this modifiable variant by passing
1638 /// the value this variant currently holds to the `visitor` object's
1639 /// `operator()`. This method does not return a value. If this variant
1640 /// is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1641 ///
1642 /// \note Note that this method is selected only if the template
1643 /// parameter type `VISITOR` does not define a `typedef` of `ResultType`
1644 /// in its public interface. Also note that this method is defined
1645 /// inline to work around a Windows compiler bug with SFINAE functions.
1646 template <class VISITOR>
1648 void>::type
1649 apply(VISITOR& visitor) {
1650
1651 if (this->d_type) {
1652 doApply<VISITOR&>(visitor, this->d_type);
1653 return; // RETURN
1654 }
1655
1656 bslmf::Nil nil = bslmf::Nil();
1657 visitor(nil);
1658 }
1659
1660 /// Apply the specified `visitor` to this modifiable variant by passing
1661 /// the value this variant currently holds to the `visitor` object's
1662 /// `operator()`. This method does not return a value. If this variant
1663 /// is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1664 ///
1665 /// \note Note that this method is selected only if the template
1666 /// parameter type `VISITOR` does not define a `typedef` of `ResultType`
1667 /// in its public interface. Also note that this method is defined
1668 /// inline to work around a Windows compiler bug with SFINAE functions.
1669 template <class VISITOR>
1671 void>::type
1672 apply(const VISITOR& visitor) {
1673
1674 if (this->d_type) {
1675 doApply<const VISITOR&>(visitor, this->d_type);
1676 return; // RETURN
1677 }
1678
1679 bslmf::Nil nil = bslmf::Nil();
1680 visitor(nil);
1681 }
1682
1683 /// Apply the specified `visitor` to this modifiable variant by passing
1684 /// the value (of template parameter `TYPE`) this variant currently
1685 /// holds to the `visitor` object's `operator()`. This method does not
1686 /// return a value. If this variant is unset, the specified
1687 /// `defaultValue` of template parameter `TYPE` is passed to the
1688 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1689 ///
1690 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1691 ///
1692 /// \note Note that this
1693 /// method is selected only if the template parameter type `VISITOR`
1694 /// does not define a `typedef` of `ResultType` in its public interface.
1695 /// Also note that this method is defined inline to work around a
1696 /// Windows compiler bug with SFINAE functions.
1697 template <class VISITOR, class TYPE>
1699 void>::type
1700 apply(VISITOR& visitor, const TYPE& defaultValue) {
1701
1702 if (this->d_type) {
1703 doApply<VISITOR&>(visitor, this->d_type);
1704 return; // RETURN
1705 }
1706
1707 visitor(defaultValue);
1708 }
1709
1710 /// Apply the specified `visitor` to this modifiable variant by passing
1711 /// the value (of template parameter `TYPE`) this variant currently
1712 /// holds to the `visitor` object's `operator()`. This method does not
1713 /// return a value. If this variant is unset, the specified
1714 /// `defaultValue` of template parameter `TYPE` is passed to the
1715 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1716 ///
1717 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1718 ///
1719 /// \note Note that this
1720 /// method is selected only if the template parameter type `VISITOR`
1721 /// does not define a `typedef` of `ResultType` in its public interface.
1722 /// Also note that this method is defined inline to work around a
1723 /// Windows compiler bug with SFINAE functions.
1724 template <class VISITOR, class TYPE>
1726 void>::type
1727 apply(const VISITOR& visitor, const TYPE& defaultValue) {
1728
1729 if (this->d_type) {
1730 doApply<const VISITOR&>(visitor, this->d_type);
1731 return; // RETURN
1732 }
1733
1734 visitor(defaultValue);
1735 }
1736
1737 /// Apply the specified `visitor` to this modifiable variant by passing
1738 /// the value (of template parameter `TYPE`) this variant currently
1739 /// holds to the `visitor` object's `operator()`, and return the value
1740 /// (of template parameter `RET_TYPE`) returned by the `visitor`. If
1741 /// this variant is unset, a default constructed `bslmf::Nil` is passed
1742 /// to the `visitor`.
1743 template <class RET_TYPE, class VISITOR>
1744 RET_TYPE apply(VISITOR& visitor);
1745 template <class RET_TYPE, class VISITOR>
1746 RET_TYPE apply(const VISITOR& visitor);
1747
1748 /// Apply the specified `visitor` to this modifiable variant by passing
1749 /// the value (of template parameter `TYPE`) this variant currently
1750 /// holds to the `visitor` object's `operator()`, and return the value
1751 /// (of template parameter `RET_TYPE`) returned by the `visitor`. If
1752 /// this variant is unset, the specified `defaultValue` of template
1753 /// parameter `TYPE` is passed to the `visitor`. `TYPE` must be the
1754 /// same as one of the types that this variant can hold.
1755 ///
1756 /// \pre The behavior is undefined unless this variant is unset or holds a value of
1757 /// template parameter `TYPE`.
1758 template <class RET_TYPE, class VISITOR, class TYPE>
1759 RET_TYPE apply(VISITOR& visitor, const TYPE& defaultValue);
1760 template <class RET_TYPE, class VISITOR, class TYPE>
1761 RET_TYPE apply(const VISITOR& visitor, const TYPE& defaultValue);
1762
1763 /// Apply the specified `visitor` to this modifiable variant by passing
1764 /// the value (of template parameter `TYPE`) this variant currently
1765 /// holds to the `visitor` object's `operator()`, and return the value returned by the `visitor`.
1766 ///
1767 /// \pre The behavior is undefined if this variant is unset.
1768 ///
1769 /// \note Note that this method is selected only if the
1770 /// template parameter type `VISITOR` defines a `typedef` of
1771 /// `ResultType` in its public interface. Also note that this method is
1772 /// defined inline to work around a Windows compiler bug with SFINAE
1773 /// functions.
1774 template <class VISITOR>
1776 typename VISITOR::ResultType>::type
1777 applyRaw(VISITOR& visitor) {
1778
1779 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1780 VISITOR> Helper;
1781
1782 return doApplyR<const Helper&,
1783 typename VISITOR::ResultType>(Helper(&visitor),
1784 this->d_type);
1785 }
1786
1787 /// Apply the specified `visitor` to this modifiable variant by passing
1788 /// the value (of template parameter `TYPE`) this variant currently
1789 /// holds to the `visitor` object's `operator()`, and return the value returned by the `visitor`.
1790 ///
1791 /// \pre The behavior is undefined if this variant is unset.
1792 ///
1793 /// \note Note that this method is selected only if the
1794 /// template parameter type `VISITOR` defines a `typedef` of
1795 /// `ResultType` in its public interface. Also note that this method is
1796 /// defined inline to work around a Windows compiler bug with SFINAE
1797 /// functions.
1798 template <class VISITOR>
1800 typename VISITOR::ResultType>::type
1801 applyRaw(const VISITOR& visitor) {
1802
1803 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1804 const VISITOR> Helper;
1805
1806 return doApplyR<const Helper&,
1807 typename VISITOR::ResultType>(Helper(&visitor),
1808 this->d_type);
1809 }
1810
1811 /// Apply the specified `visitor` to this modifiable variant by passing
1812 /// the value (of template parameter `TYPE`) this variant currently
1813 /// holds to the `visitor` object's `operator()`. This method does not return a value.
1814 ///
1815 /// \pre The behavior is undefined if this variant is unset.
1816 ///
1817 /// \note Note that this method is selected only if the template parameter
1818 /// type `VISITOR` does not define a `typedef` of `ResultType` in its
1819 /// public interface. Also note that this method is defined inline to
1820 /// work around a Windows compiler bug with SFINAE functions.
1821 template <class VISITOR>
1823 void>::type
1824 applyRaw(VISITOR& visitor) {
1825
1827
1828 doApply<const Helper&>(Helper(&visitor), this->d_type);
1829 }
1830
1831 /// Apply the specified `visitor` to this modifiable variant by passing
1832 /// the value (of template parameter `TYPE`) this variant currently
1833 /// holds to the `visitor` object's `operator()`. This method does not return a value.
1834 ///
1835 /// \pre The behavior is undefined if this variant is unset.
1836 ///
1837 /// \note Note that this method is selected only if the template parameter
1838 /// type `VISITOR` does not define a `typedef` of `ResultType` in its
1839 /// public interface. Also note that this method is defined inline to
1840 /// work around a Windows compiler bug with SFINAE functions.
1841 template <class VISITOR>
1843 void>::type
1844 applyRaw(const VISITOR& visitor) {
1845
1847
1848 doApply<const Helper&>(Helper(&visitor), this->d_type);
1849 }
1850
1851 /// Apply the specified `visitor` to this modifiable variant by passing
1852 /// the value this variant currently holds to the `visitor` object's
1853 /// `operator()`, and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
1854 ///
1855 /// \pre The behavior is undefined if
1856 /// this variant is unset.
1857 template <class RET_TYPE, class VISITOR>
1858 RET_TYPE applyRaw(VISITOR& visitor);
1859 template <class RET_TYPE, class VISITOR>
1860 RET_TYPE applyRaw(const VISITOR& visitor);
1861
1862 /// Assign to this object the specified `value` of template parameter
1863 /// `TYPE`, and return a reference providing modifiable access to this
1864 /// object. The value currently held by this variant (if any) is
1865 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
1866 /// must be the same as one of the types that this variant can hold.
1867 template <class TYPE>
1868 VariantImp& assign(const TYPE& value);
1869
1870 template <class TYPE>
1871#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1872 VariantImp& assign(TYPE&& value);
1873#else
1875#endif
1876 // Assign to this object the specified 'value' of template parameter
1877 // 'TYPE', and return a reference providing modifiable access to this
1878 // object. The contents of 'value' are moved to this object with
1879 // 'value' left in a valid but unspecified state. The value currently
1880 // held by this variant (if any) is destroyed if that value's type is
1881 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
1882 // that this variant can hold.
1883
1884 /// Assign to this object the specified `value` of template parameter
1885 /// `SOURCE_TYPE` converted to template parameter `TYPE`, and return a
1886 /// reference providing modifiable access to this object. The value
1887 /// currently held by this variant (if any) is destroyed if that value's
1888 /// type is not the same as `TYPE`. `TYPE` must be the same as one of
1889 /// the types that this variant can hold and `SOURCE_TYPE` must be
1890 /// convertible to `TYPE`.
1891 template <class TYPE, class SOURCE_TYPE>
1892 VariantImp& assignTo(const SOURCE_TYPE& value);
1893
1894#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=14
1895
1896 /// Create an instance of template parameter `TYPE` in this variant
1897 /// object with up to 14 parameters using the allocator currently held
1898 /// by this variant to supply memory, and return a reference providing
1899 /// modifiable access to the created instance. This method first
1900 /// destroys the current value held by this variant (even if `TYPE` is
1901 /// the same as the type currently held). `TYPE` must be the same as
1902 /// one of the types that this variant can hold. Note the order of the
1903 /// template arguments was chosen so that `TYPE` must always be
1904 /// specified.
1905 template <class TYPE, class... ARGS>
1906 TYPE& createInPlace(ARGS&&... arguments);
1907#endif
1908
1909 /// Destroy the current value held by this variant (if any), and reset
1910 /// this variant to the unset state.
1911 void reset();
1912
1913 /// Swap the value of this object with the value of the specified
1914 /// `other` object. This method provides the no-throw guarantee if the
1915 /// `TYPE` template parameter has a no-throw `swap` and the two variant
1916 /// objects being swapped have the same type; otherwise this method
1917 /// provides the basic guarantee.
1918 void swap(VariantImp& other);
1919
1920 /// Return a reference providing modifiable access to the value of
1921 /// template parameter `TYPE` held by this variant object. `TYPE` must
1922 /// be the same as one of the types that this variant can hold.
1923 ///
1924 /// \pre The behavior is undefined unless `is<TYPE>()` returns `true` and `TYPE` is not `void`.
1925 ///
1926 /// \note Note that `TYPE` must be specified explicitly, e.g.,
1927 /// `myValue.the<int>()`.
1928 template <class TYPE>
1929 TYPE& the();
1930
1931 // ACCESSORS
1932
1933 /// Apply the specified `visitor` to this variant by passing the value
1934 /// this variant currently holds to the `visitor` object's `operator()`,
1935 /// and return the value returned by the `visitor`. If this variant is
1936 /// unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1937 ///
1938 /// \note Note that this method is selected only if the template
1939 /// parameter type `VISITOR` defines a `typedef` of `ResultType` in its
1940 /// public interface. Also note that this method is defined inline to
1941 /// work around a Windows compiler bug with SFINAE functions.
1942 template <class VISITOR>
1944 typename VISITOR::ResultType>::type
1945 apply(VISITOR& visitor) const {
1946
1947 if (this->d_type) {
1948 return doApplyR<VISITOR&,
1949 typename VISITOR::ResultType>(visitor, this->d_type);
1950 // RETURN
1951 }
1952
1953 bslmf::Nil nil = bslmf::Nil();
1954 return visitor(nil);
1955 }
1956
1957 /// Apply the specified `visitor` to this variant by passing the value
1958 /// this variant currently holds to the `visitor` object's `operator()`,
1959 /// and return the value returned by the 'visitor. If this variant is
1960 /// unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1961 ///
1962 /// \note Note that this method is selected only if the template
1963 /// parameter type `VISITOR` defines a `typedef` of `ResultType` in its
1964 /// public interface. Also note that this method is defined inline to
1965 /// work around a Windows compiler bug with SFINAE functions.
1966 template <class VISITOR>
1968 typename VISITOR::ResultType>::type
1969 apply(const VISITOR& visitor) const {
1970
1971 if (this->d_type) {
1972 return doApplyR<const VISITOR&,
1973 typename VISITOR::ResultType>(visitor, this->d_type);
1974 // RETURN
1975 }
1976
1977 bslmf::Nil nil = bslmf::Nil();
1978 return visitor(nil);
1979 }
1980
1981 /// Apply the specified `visitor` to this variant by passing the value
1982 /// (of template parameter `TYPE`) this variant currently holds to the
1983 /// `visitor` object's `operator()`, and return the value returned by
1984 /// the `visitor`. If this variant is unset, the specified
1985 /// `defaultValue` of template parameter `TYPE` is passed to the
1986 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1987 ///
1988 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1989 ///
1990 /// \note Note that this
1991 /// method is selected only if the template parameter type `VISITOR`
1992 /// defines a `typedef` of `ResultType` in its public interface. Also
1993 /// note that this method is defined inline to work around a Windows
1994 /// compiler bug with SFINAE functions.
1995 template <class VISITOR, class TYPE>
1997 typename VISITOR::ResultType>::type
1998 apply(VISITOR& visitor, const TYPE& defaultValue) const {
1999
2000 if (this->d_type) {
2001 return doApplyR<VISITOR&,
2002 typename VISITOR::ResultType>(visitor, this->d_type);
2003 // RETURN
2004 }
2005
2006 return visitor(defaultValue);
2007 }
2008
2009 /// Apply the specified `visitor` to this variant by passing the value
2010 /// (of template parameter `TYPE`) this variant currently holds to the
2011 /// `visitor` object's `operator()`, and return the value returned by
2012 /// the `visitor`. If this variant is unset, the specified
2013 /// `defaultValue` of template parameter `TYPE` is passed to the
2014 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
2015 ///
2016 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
2017 ///
2018 /// \note Note that this
2019 /// method is selected only if the template parameter type `VISITOR`
2020 /// defines a `typedef` of `ResultType` in its public interface. Also
2021 /// note that this method is defined inline to work around a Windows
2022 /// compiler bug with SFINAE functions.
2023 template <class VISITOR, class TYPE>
2025 typename VISITOR::ResultType>::type
2026 apply(const VISITOR& visitor, const TYPE& defaultValue) const {
2027
2028 if (this->d_type) {
2029 return doApplyR<const VISITOR&,
2030 typename VISITOR::ResultType>(visitor, this->d_type);
2031 // RETURN
2032 }
2033
2034 return visitor(defaultValue);
2035 }
2036
2037 /// Apply the specified `visitor` to this variant by passing the value
2038 /// this variant currently holds to the `visitor` object's `operator()`.
2039 /// This method does not return a value. If this variant is unset, a
2040 /// default constructed `bslmf::Nil` is passed to the `visitor`.
2041 ///
2042 /// \note Note that this method is selected only if the template parameter type
2043 /// `VISITOR` does not define a `typedef` of `ResultType` in its public
2044 /// interface. Also note that this method is defined inline to work
2045 /// around a Windows compiler bug with SFINAE functions.
2046 template <class VISITOR>
2048 void>::type
2049 apply(VISITOR& visitor) const {
2050
2051 if (this->d_type) {
2052 doApply<VISITOR&>(visitor, this->d_type);
2053 return; // RETURN
2054 }
2055
2056 bslmf::Nil nil = bslmf::Nil();
2057 visitor(nil);
2058 }
2059
2060 /// Apply the specified `visitor` to this variant by passing the value
2061 /// this variant currently holds to the `visitor` object's `operator()`.
2062 /// This method does not return a value. If this variant is unset, a
2063 /// default constructed `bslmf::Nil` is passed to the `visitor`.
2064 ///
2065 /// \note Note that this method is selected only if the template parameter type
2066 /// `VISITOR` does not define a `typedef` of `ResultType` in its public
2067 /// interface. Also note that this method is defined inline to work
2068 /// around a Windows compiler bug with SFINAE functions.
2069 template <class VISITOR>
2071 void>::type
2072 apply(const VISITOR& visitor) const {
2073
2074 if (this->d_type) {
2075 doApply<const VISITOR&>(visitor, this->d_type);
2076 return; // RETURN
2077 }
2078
2079 bslmf::Nil nil = bslmf::Nil();
2080 visitor(nil);
2081 }
2082
2083 /// Apply the specified `visitor` to this variant by passing the value
2084 /// (of template parameter `TYPE`) this variant currently holds to the
2085 /// `visitor` object's `operator()`. This method does not return a
2086 /// value. If this variant is unset, the specified `defaultValue` of
2087 /// template parameter `TYPE` is passed to the `visitor`. `TYPE` must
2088 /// be the same as one of the types that this variant can hold.
2089 ///
2090 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
2091 ///
2092 /// \note Note that this method is selected
2093 /// only if the template parameter type `VISITOR` does not define a
2094 /// `typedef` of `ResultType` in its public interface. Also note that
2095 /// this method is defined inline to work around a Windows compiler bug
2096 /// with SFINAE functions.
2097 template <class VISITOR, class TYPE>
2099 void>::type
2100 apply(VISITOR& visitor, const TYPE& defaultValue) const {
2101
2102 if (this->d_type) {
2103 doApply<VISITOR&>(visitor, this->d_type);
2104 return; // RETURN
2105 }
2106
2107 visitor(defaultValue);
2108 }
2109
2110 /// Apply the specified `visitor` to this variant by passing the value
2111 /// (of template parameter `TYPE`) this variant currently holds to the
2112 /// `visitor` object's `operator()`. This method does not return a
2113 /// value. If this variant is unset, the specified `defaultValue` of
2114 /// template parameter `TYPE` is passed to the `visitor`. `TYPE` must
2115 /// be the same as one of the types that this variant can hold.
2116 ///
2117 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
2118 ///
2119 /// \note Note that this method is selected
2120 /// only if the template parameter type `VISITOR` does not define a
2121 /// `typedef` of `ResultType` in its public interface. Also note that
2122 /// this method is defined inline to work around a Windows compiler bug
2123 /// with SFINAE functions.
2124 template <class VISITOR, class TYPE>
2126 void>::type
2127 apply(const VISITOR& visitor, const TYPE& defaultValue) const {
2128
2129 if (this->d_type) {
2130 doApply<const VISITOR&>(visitor, this->d_type);
2131 return; // RETURN
2132 }
2133
2134 visitor(defaultValue);
2135 }
2136
2137 /// Apply the specified `visitor` to this variant by passing the value
2138 /// this variant currently holds to the `visitor` object's `operator()`,
2139 /// and return the value (of template parameter `RET_TYPE`) returned by
2140 /// the `visitor`. If this variant is unset, a default constructed
2141 /// `bslmf::Nil` is passed to the `visitor`.
2142 template <class RET_TYPE, class VISITOR>
2143 RET_TYPE apply(VISITOR& visitor) const;
2144 template <class RET_TYPE, class VISITOR>
2145 RET_TYPE apply(const VISITOR& visitor) const;
2146
2147 /// Apply the specified `visitor` to this variant by passing the value
2148 /// (of template parameter `TYPE`) this variant currently holds to the
2149 /// `visitor` object's `operator()`, and return the value (of template
2150 /// parameter `RET_TYPE`) returned by the `visitor`. If this variant is
2151 /// unset, the specified `defaultValue` of template parameter `TYPE` is
2152 /// passed to the `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
2153 ///
2154 /// \pre The behavior is undefined unless
2155 /// this variant is unset or holds a value of template parameter `TYPE`.
2156 template <class RET_TYPE, class VISITOR, class TYPE>
2157 RET_TYPE apply(VISITOR& visitor, const TYPE& defaultValue) const;
2158 template <class RET_TYPE, class VISITOR, class TYPE>
2159 RET_TYPE apply(const VISITOR& visitor, const TYPE& defaultValue) const;
2160
2161 /// Apply the specified `visitor` to this variant by passing the value
2162 /// this variant currently holds to the `visitor` object's `operator()`,
2163 /// and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
2164 ///
2165 /// \pre The behavior is undefined if this variant is unset.
2166 ///
2167 /// \note Note that this method is selected only if the template parameter
2168 /// type `VISITOR` defines a `typedef` of `ResultType` in its public
2169 /// interface. Also note that this method is defined inline to work
2170 /// around a Windows compiler bug with SFINAE functions.
2171 template <class VISITOR>
2173 typename VISITOR::ResultType>::type
2174 applyRaw(VISITOR& visitor) const {
2175
2176 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
2177 VISITOR> Helper;
2178
2179 return doApplyR<const Helper&,
2180 typename VISITOR::ResultType>(Helper(&visitor),
2181 this->d_type);
2182 }
2183
2184 /// Apply the specified `visitor` to this variant by passing the value
2185 /// this variant currently holds to the `visitor` object's `operator()`,
2186 /// and return the value returned by the `visitor`.
2187 ///
2188 /// \pre The behavior is undefined if this variant is unset.
2189 /// \note Note that this method is
2190 /// selected only if the template parameter type `VISITOR` defines a
2191 /// `typedef` of `ResultType` in its public interface. Also note that
2192 /// this method is defined inline to work around a Windows compiler bug
2193 /// with SFINAE functions.
2194 template <class VISITOR>
2196 typename VISITOR::ResultType>::type
2197 applyRaw(const VISITOR& visitor) const {
2198
2199 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
2200 const VISITOR> Helper;
2201
2202 return doApplyR<const Helper&,
2203 typename VISITOR::ResultType>(Helper(&visitor),
2204 this->d_type);
2205 }
2206
2207 /// Apply the specified `visitor` to this variant by passing the value
2208 /// this variant currently holds to the `visitor` object's `operator()`. This method does not return a value.
2209 ///
2210 /// \pre The behavior is undefined if this variant is unset.
2211 ///
2212 /// \note Note that this method is selected only if
2213 /// the template parameter type `VISITOR` does not define a `typedef` of
2214 /// `ResultType` in its public interface. Also note that this method is
2215 /// defined inline to work around a Windows compiler bug with SFINAE
2216 /// functions.
2217 template <class VISITOR>
2219 void>::type
2220 applyRaw(VISITOR& visitor) const {
2221
2223
2224 return doApply<const Helper&>(Helper(&visitor), this->d_type);
2225 }
2226
2227 /// Apply the specified `visitor` to this variant by passing the value
2228 /// this variant currently holds to the `visitor` object's `operator()`. This method does not return a value.
2229 ///
2230 /// \pre The behavior is undefined if this variant is unset.
2231 ///
2232 /// \note Note that this method is selected only if
2233 /// the template parameter type `VISITOR` does not define a `typedef` of
2234 /// `ResultType` in its public interface. Also note that this method is
2235 /// defined inline to work around a Windows compiler bug with SFINAE
2236 /// functions.
2237 template <class VISITOR>
2239 void>::type
2240 applyRaw(const VISITOR& visitor) const {
2241
2243
2244 return doApply<const Helper&>(Helper(&visitor), this->d_type);
2245 }
2246
2247 /// Apply the specified `visitor` to this variant by passing the value
2248 /// this variant currently holds to the `visitor` object's `operator()`,
2249 /// and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
2250 ///
2251 /// \pre The behavior is undefined if this variant is unset.
2252 template <class RET_TYPE, class VISITOR>
2253 RET_TYPE applyRaw(VISITOR& visitor) const;
2254 template <class RET_TYPE, class VISITOR>
2255 RET_TYPE applyRaw(const VISITOR& visitor) const;
2256
2257 /// Return `true` if the value held by this variant object is of
2258 /// template parameter `TYPE`, and `false` otherwise. `TYPE` must be
2259 /// the same as one of the types that this variant can hold.
2260 ///
2261 /// \note Note that `TYPE` must be specified explicitly, e.g., `myValue.is<int>()`.
2262 template <class TYPE>
2263 bool is() const;
2264
2265 /// Return `true` if this variant is currently unset, and `false`
2266 /// otherwise. An unset variant does not hold a value or type.
2267 ///
2268 /// \note Note that this method should be preferred over checking the type index of
2269 /// the variant.
2270 bool isUnset() const;
2271
2272 /// Format this object to the specified output `stream` at the (absolute
2273 /// value of) the optionally specified indentation `level`, and return a
2274 /// reference to `stream`. If `level` is specified, optionally specify
2275 /// `spacesPerLevel`, the number of spaces per indentation level for
2276 /// this and all of its nested objects. If `level` is negative,
2277 /// suppress indentation of the first line. If `spacesPerLevel` is
2278 /// negative, format the entire output on one line, suppressing all but
2279 /// the initial indentation (as governed by `level`). If `stream` is
2280 /// not valid on entry, this operation has no effect. Nothing is
2281 /// printed if this variant is unset. Each type that may be contained
2282 /// by this variant shall be printable with `bdlb::PrintMethods`
2283 /// (typically meaning that they either declare the
2284 /// `bdlb::HasPrintMethod` trait or provide the `<<` output streaming
2285 /// operator). See @ref bdlb_printmethods . The compiler will emit an
2286 /// error if `bdlb::PrintMethods::print` cannot be instantiated for each
2287 /// type that may be contained by this variant.
2288 bsl::ostream& print(bsl::ostream& stream,
2289 int level = 0,
2290 int spacesPerLevel = 4) const;
2291
2292 /// Return a reference providing non-modifiable access to the value of
2293 /// template parameter `TYPE` held by this variant object. `TYPE` must
2294 /// be the same as one of the types that this variant can hold.
2295 ///
2296 /// \pre The behavior is undefined unless `is<TYPE>()` returns `true` and `TYPE` is not `void`.
2297 ///
2298 /// \note Note that `TYPE` must be specified explicitly, e.g.,
2299 /// `myValue.the<int>()`.
2300 template <class TYPE>
2301 const TYPE& the() const;
2302
2303 /// Return the index in the list of `TYPES` corresponding to the type of
2304 /// the value currently held by this variant object (starting at 1), or 0 if this object is unset.
2305 ///
2306 /// \note Note that instead of switching code on
2307 /// the type index, calling `apply` is the preferred method of
2308 /// manipulating different types stored inside a variant.
2309 int typeIndex() const;
2310
2311#ifndef BDE_OMIT_INTERNAL_DEPRECATED
2312 /// Return `typeid(void)`.
2313 ///
2314 /// DEPRECATED: Do not use.
2315 const bsl::type_info& typeInfo() const;
2316
2317 /// DEPRECATED: Do not use.
2318 template <class STREAM>
2319 STREAM& bdexStreamIn(STREAM& stream, int version);
2320
2321 /// DEPRECATED: Do not use.
2323
2324 /// DEPRECATED: Do not use.
2325 template <class STREAM>
2326 STREAM& bdexStreamOut(STREAM& stream, int version) const;
2327
2328#endif // BDE_OMIT_INTERNAL_DEPRECATED
2329};
2330
2331// FREE OPERATORS
2332
2333/// Return `true` if the specified `lhs` variant object has the same value
2334/// as the specified `rhs` variant object, and `false` otherwise. Two
2335/// variant objects have the same value if they are both set and hold
2336/// objects of the same type and same value, or are both unset.
2337template <class TYPES>
2338bool operator==(const VariantImp<TYPES>& lhs,
2339 const VariantImp<TYPES>& rhs);
2340
2341/// Return `true` if the specified `lhs` variant object does not have the
2342/// same value as the specified `rhs` variant object, and `false` otherwise.
2343/// Two variant objects do not have the same value if one is set and the
2344/// other is unset, or if they are both set but hold objects that differ in
2345/// type or value.
2346template <class TYPES>
2347bool operator!=(const VariantImp<TYPES>& lhs,
2348 const VariantImp<TYPES>& rhs);
2349
2350/// Write the specified variant `object` to the specified output `stream` in
2351/// a single-line (human-readable) format, and return a reference to
2352/// `stream`.
2353template <class TYPES>
2354bsl::ostream& operator<<(bsl::ostream& stream,
2355 const VariantImp<TYPES>& object);
2356
2357// FREE FUNCTIONS
2358
2359/// Swap the values of the specified `a` and `b` objects. This method
2360/// provides the no-throw guarantee if the `TYPE` template parameter has a
2361/// no-throw `swap` and the two variant objects being swapped has the same
2362/// type; otherwise this method provides the basic guarantee.
2363template <class TYPES>
2365
2366 // ==================
2367 // class Variant<...>
2368 // ==================
2369
2370#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
2371template <class ...TYPES>
2372class Variant : public VariantImp<typename bslmf::TypeList<TYPES...>::ListType>
2373 {
2374#else
2375template <class A1 = bslmf::Nil, class A2 = bslmf::Nil,
2376 class A3 = bslmf::Nil, class A4 = bslmf::Nil,
2377 class A5 = bslmf::Nil, class A6 = bslmf::Nil,
2378 class A7 = bslmf::Nil, class A8 = bslmf::Nil,
2379 class A9 = bslmf::Nil, class A10 = bslmf::Nil,
2380 class A11 = bslmf::Nil, class A12 = bslmf::Nil,
2381 class A13 = bslmf::Nil, class A14 = bslmf::Nil,
2382 class A15 = bslmf::Nil, class A16 = bslmf::Nil,
2383 class A17 = bslmf::Nil, class A18 = bslmf::Nil,
2384 class A19 = bslmf::Nil, class A20 = bslmf::Nil>
2385class Variant : public VariantImp<typename bslmf::TypeList<
2386 A1, A2, A3, A4, A5,
2387 A6, A7, A8, A9, A10,
2388 A11, A12, A13, A14, A15,
2389 A16, A17, A18, A19, A20>::ListType> {
2390#endif
2391 // This class provides a "variant" type, i.e., a type capable of storing
2392 // values from a list of template parameter types 'A1' to 'A20'. Note that
2393 // if the number 'N' of types is smaller than 20, 'AN+1' up to 'A20'
2394 // default to 'bslmf::Nil', but it is more economical to use 'VariantN',
2395 // which accepts exactly 'N' template arguments, as this leads to shorter
2396 // symbols and debug string information.
2397
2398 // PRIVATE TYPES
2399#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
2400 typedef VariantImp<typename bslmf::TypeList<TYPES...>::ListType> Imp;
2401
2402 /// `SelfType` is an alias to this class.
2403 typedef Variant<TYPES...> SelfType;
2404#else
2405 typedef VariantImp<typename bslmf::TypeList<A1, A2, A3, A4, A5, A6,
2406 A7, A8, A9, A10, A11, A12,
2407 A13, A14, A15, A16, A17, A18,
2408 A19, A20>::ListType> Imp;
2409
2410 typedef Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
2411 A11, A12, A13, A14, A15, A16, A17, A18, A19, A20> SelfType;
2412 // 'SelfType' is an alias to this class.
2413#endif
2414
2417
2418 public:
2419 // TRAITS
2422 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2425 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2428 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2430
2431 // CREATORS
2432
2433 /// Create a variant object in the unset state that uses the currently
2434 /// installed default allocator to supply memory.
2436
2437 /// Create a variant object with the specified `valueOrAllocator` that
2438 /// can be either a value of a type that the variant can hold or an
2439 /// allocator to supply memory. If `valueOrAllocator` is not a
2440 /// `bslma::Allocator *`, then the variant will hold the value and type
2441 /// of `valueOrAllocator`, and use the currently installed default
2442 /// allocator to supply memory. Otherwise, the variant will be unset
2443 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2444 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2445 ///
2446 /// \note Note that this
2447 /// parameterized constructor is defined instead of two constructors
2448 /// (one taking a `bslma::Allocator *` and the other not) because
2449 /// template parameter arguments are always a better match than
2450 /// derived-to-base conversion (a concrete allocator pointer converted
2451 /// to `bslma::Allocator *`).
2452 template <class TYPE_OR_ALLOCATOR>
2453 explicit
2454 Variant(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2455
2456 /// Create a variant object having the specified `value` of template
2457 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2458 /// supply memory. If `basicAllocator` is 0, the currently installed
2459 /// default allocator is used. `TYPE` must be the same as one of the
2460 /// types that this variant can hold.
2461 template <class TYPE>
2462 Variant(const TYPE& value, bslma::Allocator *basicAllocator);
2463
2464 template <class TYPE>
2465 explicit
2466#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2467 Variant(TYPE&& value,
2468 typename bsl::enable_if<
2469 !bsl::is_same<
2470 SelfType,
2471 typename bsl::remove_const<
2472 typename bsl::remove_reference<TYPE>::type>::type>::value
2473 &&
2475 void>::type * = 0);
2476#else
2478#endif
2479 // Create a variant object having the specified 'value' of template
2480 // parameter 'TYPE' by moving the contents of 'value' to the
2481 // newly-created object. Use the currently installed default allocator
2482 // to supply memory. 'value' is left in a valid but unspecified state.
2483 // 'TYPE' must be the same as one of the types that this variant can
2484 // hold. Note that in C++11 mode, this method does not participate in
2485 // overload resolution if it would lead to ambiguity with the move
2486 // constructor that does not take an allocator (below) or with the
2487 // constructor taking a 'valueOrAllocator' (above).
2488
2489 template <class TYPE>
2490#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2491 Variant(TYPE&& value,
2492 typename bsl::enable_if<
2493 !bsl::is_same<
2494 SelfType,
2495 typename bsl::remove_const<
2496 typename bsl::remove_reference<TYPE>::type>::type>::value,
2497 bslma::Allocator>::type *basicAllocator);
2498#else
2500 bslma::Allocator *basicAllocator);
2501#endif
2502 // Create a variant object having the specified 'value' of template
2503 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2504 // memory. If 'basicAllocator' is 0, the currently installed default
2505 // allocator is used. The contents of 'value' are moved to the
2506 // newly-created object with 'value' left in a valid but unspecified
2507 // state. 'TYPE' must be the same as one of the types that this
2508 // variant can hold. Note that in C++11 mode, this method does not
2509 // participate in overload resolution if it would lead to ambiguity
2510 // with the move constructor that takes an allocator (below).
2511
2512 /// Create a variant object having the type and value of the specified
2513 /// `original` variant. Optionally specify a `basicAllocator` used to
2514 /// supply memory. If `basicAllocator` is 0, the currently installed
2515 /// default allocator is used.
2516 Variant(const Variant& original, bslma::Allocator *basicAllocator = 0);
2517
2518 /// Create a variant object having the type and value of the specified
2519 /// `original` object by moving the contents of `original` to the
2520 /// newly-created object. The allocator associated with `original` (if
2521 /// any) is propagated for use in the newly-created object. `original`
2522 /// is left in a valid but unspecified state.
2524
2525 /// Create a variant object having the type and value of the specified
2526 /// `original` object that uses the specified `basicAllocator` to supply
2527 /// memory. If `basicAllocator` is 0, the currently installed default
2528 /// allocator is used. The contents of `original` are moved to the
2529 /// newly-created object with `original` left in a valid but unspecified
2530 /// state.
2532 bslma::Allocator *basicAllocator);
2533
2534 // MANIPULATORS
2535
2536 /// Assign to this object the specified `value` of template parameter
2537 /// `TYPE`, and return a reference providing modifiable access to this
2538 /// object. The value currently held by this variant (if any) is
2539 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2540 /// must be the same as one of the types that this variant can hold.
2541 template <class TYPE>
2542 Variant& operator=(const TYPE& value);
2543
2544 template <class TYPE>
2545#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2546 typename bsl::enable_if<
2547 !bsl::is_same<SelfType,
2548 typename bsl::remove_cvref<TYPE>::type>::value,
2549 SelfType>::type&
2550 operator=(TYPE&& value);
2551#else
2552 Variant&
2554#endif
2555 // Assign to this object the specified 'value' of template parameter
2556 // 'TYPE', and return a reference providing modifiable access to this
2557 // object. The contents of 'value' are moved to this object with
2558 // 'value' left in a valid but unspecified state. The value currently
2559 // held by this variant (if any) is destroyed if that value's type is
2560 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2561 // that this variant can hold. Note that in C++11 mode, this method
2562 // does not participate in overload resolution if it would lead to
2563 // ambiguity with the move-assignment operator (below).
2564
2565 /// Assign to this object the type and value currently held by the
2566 /// specified `rhs` object, and return a reference providing modifiable
2567 /// access to this object. The value currently held by this variant
2568 /// (if any) is destroyed if that value's type is not the same as the
2569 /// type held by the `rhs` object.
2571
2572 /// Assign to this object the type and value currently held by the
2573 /// specified `rhs` object, and return a reference providing modifiable
2574 /// access to this object. The value currently held by this variant
2575 /// (if any) is destroyed if that value's type is not the same as the
2576 /// type held by the `rhs` object. The contents of `rhs` are either
2577 /// move-inserted into or move-assigned to this object with `rhs` left
2578 /// in a valid but unspecified state.
2580};
2581
2582 // ===================
2583 // class Variant2<...>
2584 // ===================
2585
2586/// This class is a "specialization" of `Variant` for a fixed number (2) of
2587/// types. Its 2 template arguments *must* all be specified (none are
2588/// defaulted to `bslmf::Nil`). It provides the same functionality as
2589/// `Variant<A1, A2>`.
2590template <class A1, class A2>
2591class Variant2 : public VariantImp<typename bslmf::TypeList2<
2592 A1, A2>::ListType> {
2593
2594 // PRIVATE TYPES
2596
2597 /// `SelfType` is an alias to this class.
2598 typedef Variant2<A1, A2> SelfType;
2599
2602
2603 public:
2604 // TRAITS
2607 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2610 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2613 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2615
2616 // CREATORS
2617
2618 /// Create a variant object in the unset state that uses the currently
2619 /// installed default allocator to supply memory.
2620 Variant2();
2621
2622 /// Create a variant object with the specified `valueOrAllocator` that
2623 /// can be either a value of a type that the variant can hold or an
2624 /// allocator to supply memory. If `valueOrAllocator` is not a
2625 /// `bslma::Allocator *`, then the variant will hold the value and type
2626 /// of `valueOrAllocator`, and use the currently installed default
2627 /// allocator to supply memory. Otherwise, the variant will be unset
2628 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2629 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2630 ///
2631 /// \note Note that this
2632 /// parameterized constructor is defined instead of two constructors
2633 /// (one taking a `bslma::Allocator *` and the other not) because
2634 /// template parameter arguments are always a better match than
2635 /// derived-to-base conversion (a concrete allocator pointer converted
2636 /// to `bslma::Allocator *`).
2637 template <class TYPE_OR_ALLOCATOR>
2638 explicit
2639 Variant2(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2640
2641 /// Create a variant object having the specified `value` of template
2642 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2643 /// supply memory. If `basicAllocator` is 0, the currently installed
2644 /// default allocator is used. `TYPE` must be the same as one of the
2645 /// types that this variant can hold.
2646 template <class TYPE>
2647 Variant2(const TYPE& value, bslma::Allocator *basicAllocator);
2648
2649 template <class TYPE>
2650 explicit
2651#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2652 Variant2(TYPE&& value,
2653 typename bsl::enable_if<
2654 !bsl::is_same<
2655 SelfType,
2656 typename bsl::remove_const<
2657 typename bsl::remove_reference<TYPE>::type>::type>::value
2658 &&
2660 void>::type * = 0);
2661#else
2663#endif
2664 // Create a variant object having the specified 'value' of template
2665 // parameter 'TYPE' by moving the contents of 'value' to the
2666 // newly-created object. Use the currently installed default allocator
2667 // to supply memory. 'value' is left in a valid but unspecified state.
2668 // 'TYPE' must be the same as one of the types that this variant can
2669 // hold. Note that in C++11 mode, this method does not participate in
2670 // overload resolution if it would lead to ambiguity with the move
2671 // constructor that does not take an allocator (below) or with the
2672 // constructor taking a 'valueOrAllocator' (above).
2673
2674 template <class TYPE>
2675#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2676 Variant2(TYPE&& value,
2677 typename bsl::enable_if<
2678 !bsl::is_same<
2679 SelfType,
2680 typename bsl::remove_const<
2681 typename bsl::remove_reference<TYPE>::type>::type>::value,
2682 bslma::Allocator>::type *basicAllocator);
2683#else
2685 bslma::Allocator *basicAllocator);
2686#endif
2687 // Create a variant object having the specified 'value' of template
2688 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2689 // memory. If 'basicAllocator' is 0, the currently installed default
2690 // allocator is used. The contents of 'value' are moved to the
2691 // newly-created object with 'value' left in a valid but unspecified
2692 // state. 'TYPE' must be the same as one of the types that this
2693 // variant can hold. Note that in C++11 mode, this method does not
2694 // participate in overload resolution if it would lead to ambiguity
2695 // with the move constructor that takes an allocator (below).
2696
2697 /// Create a variant object having the type and value of the specified
2698 /// `original` variant. Optionally specify a `basicAllocator` used to
2699 /// supply memory. If `basicAllocator` is 0, the currently installed
2700 /// default allocator is used.
2701 Variant2(const Variant2& original, bslma::Allocator *basicAllocator = 0);
2702
2703 /// Create a variant object having the type and value of the specified
2704 /// `original` object by moving the contents of `original` to the
2705 /// newly-created object. The allocator associated with `original` (if
2706 /// any) is propagated for use in the newly-created object. `original`
2707 /// is left in a valid but unspecified state.
2709
2710 /// Create a variant object having the type and value of the specified
2711 /// `original` object that uses the specified `basicAllocator` to supply
2712 /// memory. If `basicAllocator` is 0, the currently installed default
2713 /// allocator is used. The contents of `original` are moved to the
2714 /// newly-created object with `original` left in a valid but unspecified
2715 /// state.
2717 bslma::Allocator *basicAllocator);
2718
2719 // MANIPULATORS
2720
2721 /// Assign to this object the specified `value` of template parameter
2722 /// `TYPE`, and return a reference providing modifiable access to this
2723 /// object. The value currently held by this variant (if any) is
2724 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2725 /// must be the same as one of the types that this variant can hold.
2726 template <class TYPE>
2727 Variant2& operator=(const TYPE& value);
2728
2729 template <class TYPE>
2730#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2731 typename bsl::enable_if<
2732 !bsl::is_same<SelfType,
2733 typename bsl::remove_cvref<TYPE>::type>::value,
2734 SelfType>::type&
2735 operator=(TYPE&& value);
2736#else
2737 Variant2&
2739#endif
2740 // Assign to this object the specified 'value' of template parameter
2741 // 'TYPE', and return a reference providing modifiable access to this
2742 // object. The contents of 'value' are moved to this object with
2743 // 'value' left in a valid but unspecified state. The value currently
2744 // held by this variant (if any) is destroyed if that value's type is
2745 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2746 // that this variant can hold. Note that in C++11 mode, this method
2747 // does not participate in overload resolution if it would lead to
2748 // ambiguity with the move-assignment operator (below).
2749
2750 /// Assign to this object the type and value currently held by the
2751 /// specified `rhs` object, and return a reference providing modifiable
2752 /// access to this object. The value currently held by this variant
2753 /// (if any) is destroyed if that value's type is not the same as the
2754 /// type held by the `rhs` object.
2755 Variant2& operator=(const Variant2& rhs);
2756
2757 /// Assign to this object the type and value currently held by the
2758 /// specified `rhs` object, and return a reference providing modifiable
2759 /// access to this object. The value currently held by this variant
2760 /// (if any) is destroyed if that value's type is not the same as the
2761 /// type held by the `rhs` object. The contents of `rhs` are either
2762 /// move-inserted into or move-assigned to this object with `rhs` left
2763 /// in a valid but unspecified state.
2764 Variant2& operator=(bslmf::MovableRef<Variant2> rhs);
2765};
2766
2767 // ===================
2768 // class Variant3<...>
2769 // ===================
2770
2771/// This class is a "specialization" of `Variant` for a fixed number (3) of
2772/// types. Its 3 template arguments *must* all be specified (none are
2773/// defaulted to `bslmf::Nil`). It provides the same functionality as
2774/// `Variant<A1, A2, A3>`.
2775template <class A1, class A2, class A3>
2776class Variant3 : public VariantImp<typename bslmf::TypeList3<
2777 A1, A2, A3>::ListType> {
2778
2779 // PRIVATE TYPES
2780 typedef VariantImp<typename bslmf::TypeList3<A1, A2,
2781 A3>::ListType> Imp;
2782
2783 /// `SelfType` is an alias to this class.
2784 typedef Variant3<A1, A2, A3> SelfType;
2785
2788
2789 public:
2790 // TRAITS
2793 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2796 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2799 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2801
2802 // CREATORS
2803
2804 /// Create a variant object in the unset state that uses the currently
2805 /// installed default allocator to supply memory.
2806 Variant3();
2807
2808 /// Create a variant object with the specified `valueOrAllocator` that
2809 /// can be either a value of a type that the variant can hold or an
2810 /// allocator to supply memory. If `valueOrAllocator` is not a
2811 /// `bslma::Allocator *`, then the variant will hold the value and type
2812 /// of `valueOrAllocator`, and use the currently installed default
2813 /// allocator to supply memory. Otherwise, the variant will be unset
2814 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2815 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2816 ///
2817 /// \note Note that this
2818 /// parameterized constructor is defined instead of two constructors
2819 /// (one taking a `bslma::Allocator *` and the other not) because
2820 /// template parameter arguments are always a better match than
2821 /// derived-to-base conversion (a concrete allocator pointer converted
2822 /// to `bslma::Allocator *`).
2823 template <class TYPE_OR_ALLOCATOR>
2824 explicit
2825 Variant3(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2826
2827 /// Create a variant object having the specified `value` of template
2828 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2829 /// supply memory. If `basicAllocator` is 0, the currently installed
2830 /// default allocator is used. `TYPE` must be the same as one of the
2831 /// types that this variant can hold.
2832 template <class TYPE>
2833 Variant3(const TYPE& value, bslma::Allocator *basicAllocator);
2834
2835 template <class TYPE>
2836 explicit
2837#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2838 Variant3(TYPE&& value,
2839 typename bsl::enable_if<
2840 !bsl::is_same<
2841 SelfType,
2842 typename bsl::remove_const<
2843 typename bsl::remove_reference<TYPE>::type>::type>::value
2844 &&
2846 void>::type * = 0);
2847#else
2849#endif
2850 // Create a variant object having the specified 'value' of template
2851 // parameter 'TYPE' by moving the contents of 'value' to the
2852 // newly-created object. Use the currently installed default allocator
2853 // to supply memory. 'value' is left in a valid but unspecified state.
2854 // 'TYPE' must be the same as one of the types that this variant can
2855 // hold. Note that in C++11 mode, this method does not participate in
2856 // overload resolution if it would lead to ambiguity with the move
2857 // constructor that does not take an allocator (below) or with the
2858 // constructor taking a 'valueOrAllocator' (above).
2859
2860 template <class TYPE>
2861#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2862 Variant3(TYPE&& value,
2863 typename bsl::enable_if<
2864 !bsl::is_same<
2865 SelfType,
2866 typename bsl::remove_const<
2867 typename bsl::remove_reference<TYPE>::type>::type>::value,
2868 bslma::Allocator>::type *basicAllocator);
2869#else
2871 bslma::Allocator *basicAllocator);
2872#endif
2873 // Create a variant object having the specified 'value' of template
2874 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2875 // memory. If 'basicAllocator' is 0, the currently installed default
2876 // allocator is used. The contents of 'value' are moved to the
2877 // newly-created object with 'value' left in a valid but unspecified
2878 // state. 'TYPE' must be the same as one of the types that this
2879 // variant can hold. Note that in C++11 mode, this method does not
2880 // participate in overload resolution if it would lead to ambiguity
2881 // with the move constructor that takes an allocator (below).
2882
2883 /// Create a variant object having the type and value of the specified
2884 /// `original` variant. Optionally specify a `basicAllocator` used to
2885 /// supply memory. If `basicAllocator` is 0, the currently installed
2886 /// default allocator is used.
2887 Variant3(const Variant3& original, bslma::Allocator *basicAllocator = 0);
2888
2889 /// Create a variant object having the type and value of the specified
2890 /// `original` object by moving the contents of `original` to the
2891 /// newly-created object. The allocator associated with `original` (if
2892 /// any) is propagated for use in the newly-created object. `original`
2893 /// is left in a valid but unspecified state.
2895
2896 /// Create a variant object having the type and value of the specified
2897 /// `original` object that uses the specified `basicAllocator` to supply
2898 /// memory. If `basicAllocator` is 0, the currently installed default
2899 /// allocator is used. The contents of `original` are moved to the
2900 /// newly-created object with `original` left in a valid but unspecified
2901 /// state.
2903 bslma::Allocator *basicAllocator);
2904
2905 // MANIPULATORS
2906
2907 /// Assign to this object the specified `value` of template parameter
2908 /// `TYPE`, and return a reference providing modifiable access to this
2909 /// object. The value currently held by this variant (if any) is
2910 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2911 /// must be the same as one of the types that this variant can hold.
2912 template <class TYPE>
2913 Variant3& operator=(const TYPE& value);
2914
2915 template <class TYPE>
2916#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2917 typename bsl::enable_if<
2918 !bsl::is_same<SelfType,
2919 typename bsl::remove_cvref<TYPE>::type>::value,
2920 SelfType>::type&
2921 operator=(TYPE&& value);
2922#else
2923 Variant3&
2925#endif
2926 // Assign to this object the specified 'value' of template parameter
2927 // 'TYPE', and return a reference providing modifiable access to this
2928 // object. The contents of 'value' are moved to this object with
2929 // 'value' left in a valid but unspecified state. The value currently
2930 // held by this variant (if any) is destroyed if that value's type is
2931 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2932 // that this variant can hold. Note that in C++11 mode, this method
2933 // does not participate in overload resolution if it would lead to
2934 // ambiguity with the move-assignment operator (below).
2935
2936 /// Assign to this object the type and value currently held by the
2937 /// specified `rhs` object, and return a reference providing modifiable
2938 /// access to this object. The value currently held by this variant
2939 /// (if any) is destroyed if that value's type is not the same as the
2940 /// type held by the `rhs` object.
2941 Variant3& operator=(const Variant3& rhs);
2942
2943 /// Assign to this object the type and value currently held by the
2944 /// specified `rhs` object, and return a reference providing modifiable
2945 /// access to this object. The value currently held by this variant
2946 /// (if any) is destroyed if that value's type is not the same as the
2947 /// type held by the `rhs` object. The contents of `rhs` are either
2948 /// move-inserted into or move-assigned to this object with `rhs` left
2949 /// in a valid but unspecified state.
2950 Variant3& operator=(bslmf::MovableRef<Variant3> rhs);
2951};
2952
2953 // ===================
2954 // class Variant4<...>
2955 // ===================
2956
2957/// This class is a "specialization" of `Variant` for a fixed number (4) of
2958/// types. Its 4 template arguments *must* all be specified (none are
2959/// defaulted to `bslmf::Nil`). It provides the same functionality as
2960/// `Variant<A1, A2, ..., A4>`.
2961template <class A1, class A2, class A3, class A4>
2962class Variant4 : public VariantImp<typename bslmf::TypeList4<
2963 A1, A2, A3, A4>::ListType> {
2964
2965 // PRIVATE TYPES
2966 typedef VariantImp<typename bslmf::TypeList4<A1, A2, A3,
2967 A4>::ListType> Imp;
2968
2969 /// `SelfType` is an alias to this class.
2970 typedef Variant4<A1, A2, A3, A4> SelfType;
2971
2974
2975 public:
2976 // TRAITS
2979 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2982 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2985 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2987
2988 // CREATORS
2989
2990 /// Create a variant object in the unset state that uses the currently
2991 /// installed default allocator to supply memory.
2992 Variant4();
2993
2994 /// Create a variant object with the specified `valueOrAllocator` that
2995 /// can be either a value of a type that the variant can hold or an
2996 /// allocator to supply memory. If `valueOrAllocator` is not a
2997 /// `bslma::Allocator *`, then the variant will hold the value and type
2998 /// of `valueOrAllocator`, and use the currently installed default
2999 /// allocator to supply memory. Otherwise, the variant will be unset
3000 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3001 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3002 ///
3003 /// \note Note that this
3004 /// parameterized constructor is defined instead of two constructors
3005 /// (one taking a `bslma::Allocator *` and the other not) because
3006 /// template parameter arguments are always a better match than
3007 /// derived-to-base conversion (a concrete allocator pointer converted
3008 /// to `bslma::Allocator *`).
3009 template <class TYPE_OR_ALLOCATOR>
3010 explicit
3011 Variant4(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3012
3013 /// Create a variant object having the specified `value` of template
3014 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3015 /// supply memory. If `basicAllocator` is 0, the currently installed
3016 /// default allocator is used. `TYPE` must be the same as one of the
3017 /// types that this variant can hold.
3018 template <class TYPE>
3019 Variant4(const TYPE& value, bslma::Allocator *basicAllocator);
3020
3021 template <class TYPE>
3022 explicit
3023#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3024 Variant4(TYPE&& value,
3025 typename bsl::enable_if<
3026 !bsl::is_same<
3027 SelfType,
3028 typename bsl::remove_const<
3029 typename bsl::remove_reference<TYPE>::type>::type>::value
3030 &&
3032 void>::type * = 0);
3033#else
3035#endif
3036 // Create a variant object having the specified 'value' of template
3037 // parameter 'TYPE' by moving the contents of 'value' to the
3038 // newly-created object. Use the currently installed default allocator
3039 // to supply memory. 'value' is left in a valid but unspecified state.
3040 // 'TYPE' must be the same as one of the types that this variant can
3041 // hold. Note that in C++11 mode, this method does not participate in
3042 // overload resolution if it would lead to ambiguity with the move
3043 // constructor that does not take an allocator (below) or with the
3044 // constructor taking a 'valueOrAllocator' (above).
3045
3046 template <class TYPE>
3047#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3048 Variant4(TYPE&& value,
3049 typename bsl::enable_if<
3050 !bsl::is_same<
3051 SelfType,
3052 typename bsl::remove_const<
3053 typename bsl::remove_reference<TYPE>::type>::type>::value,
3054 bslma::Allocator>::type *basicAllocator);
3055#else
3057 bslma::Allocator *basicAllocator);
3058#endif
3059 // Create a variant object having the specified 'value' of template
3060 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3061 // memory. If 'basicAllocator' is 0, the currently installed default
3062 // allocator is used. The contents of 'value' are moved to the
3063 // newly-created object with 'value' left in a valid but unspecified
3064 // state. 'TYPE' must be the same as one of the types that this
3065 // variant can hold. Note that in C++11 mode, this method does not
3066 // participate in overload resolution if it would lead to ambiguity
3067 // with the move constructor that takes an allocator (below).
3068
3069 /// Create a variant object having the type and value of the specified
3070 /// `original` variant. Optionally specify a `basicAllocator` used to
3071 /// supply memory. If `basicAllocator` is 0, the currently installed
3072 /// default allocator is used.
3073 Variant4(const Variant4& original, bslma::Allocator *basicAllocator = 0);
3074
3075 /// Create a variant object having the type and value of the specified
3076 /// `original` object by moving the contents of `original` to the
3077 /// newly-created object. The allocator associated with `original` (if
3078 /// any) is propagated for use in the newly-created object. `original`
3079 /// is left in a valid but unspecified state.
3081
3082 /// Create a variant object having the type and value of the specified
3083 /// `original` object that uses the specified `basicAllocator` to supply
3084 /// memory. If `basicAllocator` is 0, the currently installed default
3085 /// allocator is used. The contents of `original` are moved to the
3086 /// newly-created object with `original` left in a valid but unspecified
3087 /// state.
3089 bslma::Allocator *basicAllocator);
3090
3091 // MANIPULATORS
3092
3093 /// Assign to this object the specified `value` of template parameter
3094 /// `TYPE`, and return a reference providing modifiable access to this
3095 /// object. The value currently held by this variant (if any) is
3096 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3097 /// must be the same as one of the types that this variant can hold.
3098 template <class TYPE>
3099 Variant4& operator=(const TYPE& value);
3100
3101 template <class TYPE>
3102#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3103 typename bsl::enable_if<
3104 !bsl::is_same<SelfType,
3105 typename bsl::remove_cvref<TYPE>::type>::value,
3106 SelfType>::type&
3107 operator=(TYPE&& value);
3108#else
3109 Variant4&
3111#endif
3112 // Assign to this object the specified 'value' of template parameter
3113 // 'TYPE', and return a reference providing modifiable access to this
3114 // object. The contents of 'value' are moved to this object with
3115 // 'value' left in a valid but unspecified state. The value currently
3116 // held by this variant (if any) is destroyed if that value's type is
3117 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3118 // that this variant can hold. Note that in C++11 mode, this method
3119 // does not participate in overload resolution if it would lead to
3120 // ambiguity with the move-assignment operator (below).
3121
3122 /// Assign to this object the type and value currently held by the
3123 /// specified `rhs` object, and return a reference providing modifiable
3124 /// access to this object. The value currently held by this variant
3125 /// (if any) is destroyed if that value's type is not the same as the
3126 /// type held by the `rhs` object.
3127 Variant4& operator=(const Variant4& rhs);
3128
3129 /// Assign to this object the type and value currently held by the
3130 /// specified `rhs` object, and return a reference providing modifiable
3131 /// access to this object. The value currently held by this variant
3132 /// (if any) is destroyed if that value's type is not the same as the
3133 /// type held by the `rhs` object. The contents of `rhs` are either
3134 /// move-inserted into or move-assigned to this object with `rhs` left
3135 /// in a valid but unspecified state.
3136 Variant4& operator=(bslmf::MovableRef<Variant4> rhs);
3137};
3138
3139 // ===================
3140 // class Variant5<...>
3141 // ===================
3142
3143/// This class is a "specialization" of `Variant` for a fixed number (5) of
3144/// types. Its 5 template arguments *must* all be specified (none are
3145/// defaulted to `bslmf::Nil`). It provides the same functionality as
3146/// `Variant<A1, A2, ..., A5>`.
3147template <class A1, class A2, class A3, class A4, class A5>
3148class Variant5 : public VariantImp<typename bslmf::TypeList5<
3149 A1, A2, A3, A4, A5>::ListType> {
3150
3151 // PRIVATE TYPES
3152 typedef VariantImp<typename bslmf::TypeList5<A1, A2, A3, A4,
3153 A5>::ListType> Imp;
3154
3155 /// `SelfType` is an alias to this class.
3156 typedef Variant5<A1, A2, A3, A4, A5> SelfType;
3157
3160
3161 public:
3162 // TRAITS
3165 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3168 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3171 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3173
3174 // CREATORS
3175
3176 /// Create a variant object in the unset state that uses the currently
3177 /// installed default allocator to supply memory.
3178 Variant5();
3179
3180 /// Create a variant object with the specified `valueOrAllocator` that
3181 /// can be either a value of a type that the variant can hold or an
3182 /// allocator to supply memory. If `valueOrAllocator` is not a
3183 /// `bslma::Allocator *`, then the variant will hold the value and type
3184 /// of `valueOrAllocator`, and use the currently installed default
3185 /// allocator to supply memory. Otherwise, the variant will be unset
3186 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3187 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3188 ///
3189 /// \note Note that this
3190 /// parameterized constructor is defined instead of two constructors
3191 /// (one taking a `bslma::Allocator *` and the other not) because
3192 /// template parameter arguments are always a better match than
3193 /// derived-to-base conversion (a concrete allocator pointer converted
3194 /// to `bslma::Allocator *`).
3195 template <class TYPE_OR_ALLOCATOR>
3196 explicit
3197 Variant5(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3198
3199 /// Create a variant object having the specified `value` of template
3200 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3201 /// supply memory. If `basicAllocator` is 0, the currently installed
3202 /// default allocator is used. `TYPE` must be the same as one of the
3203 /// types that this variant can hold.
3204 template <class TYPE>
3205 Variant5(const TYPE& value, bslma::Allocator *basicAllocator);
3206
3207 template <class TYPE>
3208 explicit
3209#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3210 Variant5(TYPE&& value,
3211 typename bsl::enable_if<
3212 !bsl::is_same<
3213 SelfType,
3214 typename bsl::remove_const<
3215 typename bsl::remove_reference<TYPE>::type>::type>::value
3216 &&
3218 void>::type * = 0);
3219#else
3221#endif
3222 // Create a variant object having the specified 'value' of template
3223 // parameter 'TYPE' by moving the contents of 'value' to the
3224 // newly-created object. Use the currently installed default allocator
3225 // to supply memory. 'value' is left in a valid but unspecified state.
3226 // 'TYPE' must be the same as one of the types that this variant can
3227 // hold. Note that in C++11 mode, this method does not participate in
3228 // overload resolution if it would lead to ambiguity with the move
3229 // constructor that does not take an allocator (below) or with the
3230 // constructor taking a 'valueOrAllocator' (above).
3231
3232 template <class TYPE>
3233#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3234 Variant5(TYPE&& value,
3235 typename bsl::enable_if<
3236 !bsl::is_same<
3237 SelfType,
3238 typename bsl::remove_const<
3239 typename bsl::remove_reference<TYPE>::type>::type>::value,
3240 bslma::Allocator>::type *basicAllocator);
3241#else
3243 bslma::Allocator *basicAllocator);
3244#endif
3245 // Create a variant object having the specified 'value' of template
3246 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3247 // memory. If 'basicAllocator' is 0, the currently installed default
3248 // allocator is used. The contents of 'value' are moved to the
3249 // newly-created object with 'value' left in a valid but unspecified
3250 // state. 'TYPE' must be the same as one of the types that this
3251 // variant can hold. Note that in C++11 mode, this method does not
3252 // participate in overload resolution if it would lead to ambiguity
3253 // with the move constructor that takes an allocator (below).
3254
3255 /// Create a variant object having the type and value of the specified
3256 /// `original` variant. Optionally specify a `basicAllocator` used to
3257 /// supply memory. If `basicAllocator` is 0, the currently installed
3258 /// default allocator is used.
3259 Variant5(const Variant5& original, bslma::Allocator *basicAllocator = 0);
3260
3261 /// Create a variant object having the type and value of the specified
3262 /// `original` object by moving the contents of `original` to the
3263 /// newly-created object. The allocator associated with `original` (if
3264 /// any) is propagated for use in the newly-created object. `original`
3265 /// is left in a valid but unspecified state.
3267
3268 /// Create a variant object having the type and value of the specified
3269 /// `original` object that uses the specified `basicAllocator` to supply
3270 /// memory. If `basicAllocator` is 0, the currently installed default
3271 /// allocator is used. The contents of `original` are moved to the
3272 /// newly-created object with `original` left in a valid but unspecified
3273 /// state.
3275 bslma::Allocator *basicAllocator);
3276
3277 // MANIPULATORS
3278
3279 /// Assign to this object the specified `value` of template parameter
3280 /// `TYPE`, and return a reference providing modifiable access to this
3281 /// object. The value currently held by this variant (if any) is
3282 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3283 /// must be the same as one of the types that this variant can hold.
3284 template <class TYPE>
3285 Variant5& operator=(const TYPE& value);
3286
3287 template <class TYPE>
3288#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3289 typename bsl::enable_if<
3290 !bsl::is_same<SelfType,
3291 typename bsl::remove_cvref<TYPE>::type>::value,
3292 SelfType>::type&
3293 operator=(TYPE&& value);
3294#else
3295 Variant5&
3297#endif
3298 // Assign to this object the specified 'value' of template parameter
3299 // 'TYPE', and return a reference providing modifiable access to this
3300 // object. The contents of 'value' are moved to this object with
3301 // 'value' left in a valid but unspecified state. The value currently
3302 // held by this variant (if any) is destroyed if that value's type is
3303 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3304 // that this variant can hold. Note that in C++11 mode, this method
3305 // does not participate in overload resolution if it would lead to
3306 // ambiguity with the move-assignment operator (below).
3307
3308 /// Assign to this object the type and value currently held by the
3309 /// specified `rhs` object, and return a reference providing modifiable
3310 /// access to this object. The value currently held by this variant
3311 /// (if any) is destroyed if that value's type is not the same as the
3312 /// type held by the `rhs` object.
3313 Variant5& operator=(const Variant5& rhs);
3314
3315 /// Assign to this object the type and value currently held by the
3316 /// specified `rhs` object, and return a reference providing modifiable
3317 /// access to this object. The value currently held by this variant
3318 /// (if any) is destroyed if that value's type is not the same as the
3319 /// type held by the `rhs` object. The contents of `rhs` are either
3320 /// move-inserted into or move-assigned to this object with `rhs` left
3321 /// in a valid but unspecified state.
3322 Variant5& operator=(bslmf::MovableRef<Variant5> rhs);
3323};
3324
3325 // ===================
3326 // class Variant6<...>
3327 // ===================
3328
3329/// This class is a "specialization" of `Variant` for a fixed number (6) of
3330/// types. Its 6 template arguments *must* all be specified (none are
3331/// defaulted to `bslmf::Nil`). It provides the same functionality as
3332/// `Variant<A1, A2, ..., A6>`.
3333template <class A1, class A2, class A3, class A4, class A5, class A6>
3334class Variant6 : public VariantImp<typename bslmf::TypeList6<
3335 A1, A2, A3, A4, A5, A6>::ListType> {
3336
3337 // PRIVATE TYPES
3338 typedef VariantImp<typename bslmf::TypeList6<A1, A2, A3, A4, A5,
3339 A6>::ListType> Imp;
3340
3341 /// `SelfType` is an alias to this class.
3342 typedef Variant6<A1, A2, A3, A4, A5, A6> SelfType;
3343
3346
3347 public:
3348 // TRAITS
3351 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3354 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3357 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3359
3360 // CREATORS
3361
3362 /// Create a variant object in the unset state that uses the currently
3363 /// installed default allocator to supply memory.
3364 Variant6();
3365
3366 /// Create a variant object with the specified `valueOrAllocator` that
3367 /// can be either a value of a type that the variant can hold or an
3368 /// allocator to supply memory. If `valueOrAllocator` is not a
3369 /// `bslma::Allocator *`, then the variant will hold the value and type
3370 /// of `valueOrAllocator`, and use the currently installed default
3371 /// allocator to supply memory. Otherwise, the variant will be unset
3372 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3373 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3374 ///
3375 /// \note Note that this
3376 /// parameterized constructor is defined instead of two constructors
3377 /// (one taking a `bslma::Allocator *` and the other not) because
3378 /// template parameter arguments are always a better match than
3379 /// derived-to-base conversion (a concrete allocator pointer converted
3380 /// to `bslma::Allocator *`).
3381 template <class TYPE_OR_ALLOCATOR>
3382 explicit
3383 Variant6(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3384
3385 /// Create a variant object having the specified `value` of template
3386 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3387 /// supply memory. If `basicAllocator` is 0, the currently installed
3388 /// default allocator is used. `TYPE` must be the same as one of the
3389 /// types that this variant can hold.
3390 template <class TYPE>
3391 Variant6(const TYPE& value, bslma::Allocator *basicAllocator);
3392
3393 template <class TYPE>
3394 explicit
3395#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3396 Variant6(TYPE&& value,
3397 typename bsl::enable_if<
3398 !bsl::is_same<
3399 SelfType,
3400 typename bsl::remove_const<
3401 typename bsl::remove_reference<TYPE>::type>::type>::value
3402 &&
3404 void>::type * = 0);
3405#else
3407#endif
3408 // Create a variant object having the specified 'value' of template
3409 // parameter 'TYPE' by moving the contents of 'value' to the
3410 // newly-created object. Use the currently installed default allocator
3411 // to supply memory. 'value' is left in a valid but unspecified state.
3412 // 'TYPE' must be the same as one of the types that this variant can
3413 // hold. Note that in C++11 mode, this method does not participate in
3414 // overload resolution if it would lead to ambiguity with the move
3415 // constructor that does not take an allocator (below) or with the
3416 // constructor taking a 'valueOrAllocator' (above).
3417
3418 template <class TYPE>
3419#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3420 Variant6(TYPE&& value,
3421 typename bsl::enable_if<
3422 !bsl::is_same<
3423 SelfType,
3424 typename bsl::remove_const<
3425 typename bsl::remove_reference<TYPE>::type>::type>::value,
3426 bslma::Allocator>::type *basicAllocator);
3427#else
3429 bslma::Allocator *basicAllocator);
3430#endif
3431 // Create a variant object having the specified 'value' of template
3432 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3433 // memory. If 'basicAllocator' is 0, the currently installed default
3434 // allocator is used. The contents of 'value' are moved to the
3435 // newly-created object with 'value' left in a valid but unspecified
3436 // state. 'TYPE' must be the same as one of the types that this
3437 // variant can hold. Note that in C++11 mode, this method does not
3438 // participate in overload resolution if it would lead to ambiguity
3439 // with the move constructor that takes an allocator (below).
3440
3441 /// Create a variant object having the type and value of the specified
3442 /// `original` variant. Optionally specify a `basicAllocator` used to
3443 /// supply memory. If `basicAllocator` is 0, the currently installed
3444 /// default allocator is used.
3445 Variant6(const Variant6& original, bslma::Allocator *basicAllocator = 0);
3446
3447 /// Create a variant object having the type and value of the specified
3448 /// `original` object by moving the contents of `original` to the
3449 /// newly-created object. The allocator associated with `original` (if
3450 /// any) is propagated for use in the newly-created object. `original`
3451 /// is left in a valid but unspecified state.
3453
3454 /// Create a variant object having the type and value of the specified
3455 /// `original` object that uses the specified `basicAllocator` to supply
3456 /// memory. If `basicAllocator` is 0, the currently installed default
3457 /// allocator is used. The contents of `original` are moved to the
3458 /// newly-created object with `original` left in a valid but unspecified
3459 /// state.
3461 bslma::Allocator *basicAllocator);
3462
3463 // MANIPULATORS
3464
3465 /// Assign to this object the specified `value` of template parameter
3466 /// `TYPE`, and return a reference providing modifiable access to this
3467 /// object. The value currently held by this variant (if any) is
3468 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3469 /// must be the same as one of the types that this variant can hold.
3470 template <class TYPE>
3471 Variant6& operator=(const TYPE& value);
3472
3473 template <class TYPE>
3474#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3475 typename bsl::enable_if<
3476 !bsl::is_same<SelfType,
3477 typename bsl::remove_cvref<TYPE>::type>::value,
3478 SelfType>::type&
3479 operator=(TYPE&& value);
3480#else
3481 Variant6&
3483#endif
3484 // Assign to this object the specified 'value' of template parameter
3485 // 'TYPE', and return a reference providing modifiable access to this
3486 // object. The contents of 'value' are moved to this object with
3487 // 'value' left in a valid but unspecified state. The value currently
3488 // held by this variant (if any) is destroyed if that value's type is
3489 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3490 // that this variant can hold. Note that in C++11 mode, this method
3491 // does not participate in overload resolution if it would lead to
3492 // ambiguity with the move-assignment operator (below).
3493
3494 /// Assign to this object the type and value currently held by the
3495 /// specified `rhs` object, and return a reference providing modifiable
3496 /// access to this object. The value currently held by this variant
3497 /// (if any) is destroyed if that value's type is not the same as the
3498 /// type held by the `rhs` object.
3499 Variant6& operator=(const Variant6& rhs);
3500
3501 /// Assign to this object the type and value currently held by the
3502 /// specified `rhs` object, and return a reference providing modifiable
3503 /// access to this object. The value currently held by this variant
3504 /// (if any) is destroyed if that value's type is not the same as the
3505 /// type held by the `rhs` object. The contents of `rhs` are either
3506 /// move-inserted into or move-assigned to this object with `rhs` left
3507 /// in a valid but unspecified state.
3508 Variant6& operator=(bslmf::MovableRef<Variant6> rhs);
3509};
3510
3511 // ===================
3512 // class Variant7<...>
3513 // ===================
3514
3515/// This class is a "specialization" of `Variant` for a fixed number (7) of
3516/// types. Its 7 template arguments *must* all be specified (none are
3517/// defaulted to `bslmf::Nil`). It provides the same functionality as
3518/// `Variant<A1, A2, ..., A7>`.
3519template <class A1, class A2, class A3, class A4, class A5, class A6,
3520 class A7>
3521class Variant7 : public VariantImp<typename bslmf::TypeList7<
3522 A1, A2, A3, A4, A5, A6, A7>::ListType> {
3523
3524 // PRIVATE TYPES
3525 typedef VariantImp<typename bslmf::TypeList7<A1, A2, A3, A4, A5, A6,
3526 A7>::ListType> Imp;
3527
3528 /// `SelfType` is an alias to this class.
3529 typedef Variant7<A1, A2, A3, A4, A5, A6, A7> SelfType;
3530
3533
3534 public:
3535 // TRAITS
3538 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3541 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3544 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3546
3547 // CREATORS
3548
3549 /// Create a variant object in the unset state that uses the currently
3550 /// installed default allocator to supply memory.
3551 Variant7();
3552
3553 /// Create a variant object with the specified `valueOrAllocator` that
3554 /// can be either a value of a type that the variant can hold or an
3555 /// allocator to supply memory. If `valueOrAllocator` is not a
3556 /// `bslma::Allocator *`, then the variant will hold the value and type
3557 /// of `valueOrAllocator`, and use the currently installed default
3558 /// allocator to supply memory. Otherwise, the variant will be unset
3559 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3560 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3561 ///
3562 /// \note Note that this
3563 /// parameterized constructor is defined instead of two constructors
3564 /// (one taking a `bslma::Allocator *` and the other not) because
3565 /// template parameter arguments are always a better match than
3566 /// derived-to-base conversion (a concrete allocator pointer converted
3567 /// to `bslma::Allocator *`).
3568 template <class TYPE_OR_ALLOCATOR>
3569 explicit
3570 Variant7(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3571
3572 /// Create a variant object having the specified `value` of template
3573 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3574 /// supply memory. If `basicAllocator` is 0, the currently installed
3575 /// default allocator is used. `TYPE` must be the same as one of the
3576 /// types that this variant can hold.
3577 template <class TYPE>
3578 Variant7(const TYPE& value, bslma::Allocator *basicAllocator);
3579
3580 template <class TYPE>
3581 explicit
3582#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3583 Variant7(TYPE&& value,
3584 typename bsl::enable_if<
3585 !bsl::is_same<
3586 SelfType,
3587 typename bsl::remove_const<
3588 typename bsl::remove_reference<TYPE>::type>::type>::value
3589 &&
3591 void>::type * = 0);
3592#else
3594#endif
3595 // Create a variant object having the specified 'value' of template
3596 // parameter 'TYPE' by moving the contents of 'value' to the
3597 // newly-created object. Use the currently installed default allocator
3598 // to supply memory. 'value' is left in a valid but unspecified state.
3599 // 'TYPE' must be the same as one of the types that this variant can
3600 // hold. Note that in C++11 mode, this method does not participate in
3601 // overload resolution if it would lead to ambiguity with the move
3602 // constructor that does not take an allocator (below) or with the
3603 // constructor taking a 'valueOrAllocator' (above).
3604
3605 template <class TYPE>
3606#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3607 Variant7(TYPE&& value,
3608 typename bsl::enable_if<
3609 !bsl::is_same<
3610 SelfType,
3611 typename bsl::remove_const<
3612 typename bsl::remove_reference<TYPE>::type>::type>::value,
3613 bslma::Allocator>::type *basicAllocator);
3614#else
3616 bslma::Allocator *basicAllocator);
3617#endif
3618 // Create a variant object having the specified 'value' of template
3619 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3620 // memory. If 'basicAllocator' is 0, the currently installed default
3621 // allocator is used. The contents of 'value' are moved to the
3622 // newly-created object with 'value' left in a valid but unspecified
3623 // state. 'TYPE' must be the same as one of the types that this
3624 // variant can hold. Note that in C++11 mode, this method does not
3625 // participate in overload resolution if it would lead to ambiguity
3626 // with the move constructor that takes an allocator (below).
3627
3628 /// Create a variant object having the type and value of the specified
3629 /// `original` variant. Optionally specify a `basicAllocator` used to
3630 /// supply memory. If `basicAllocator` is 0, the currently installed
3631 /// default allocator is used.
3632 Variant7(const Variant7& original, bslma::Allocator *basicAllocator = 0);
3633
3634 /// Create a variant object having the type and value of the specified
3635 /// `original` object by moving the contents of `original` to the
3636 /// newly-created object. The allocator associated with `original` (if
3637 /// any) is propagated for use in the newly-created object. `original`
3638 /// is left in a valid but unspecified state.
3640
3641 /// Create a variant object having the type and value of the specified
3642 /// `original` object that uses the specified `basicAllocator` to supply
3643 /// memory. If `basicAllocator` is 0, the currently installed default
3644 /// allocator is used. The contents of `original` are moved to the
3645 /// newly-created object with `original` left in a valid but unspecified
3646 /// state.
3648 bslma::Allocator *basicAllocator);
3649
3650 // MANIPULATORS
3651
3652 /// Assign to this object the specified `value` of template parameter
3653 /// `TYPE`, and return a reference providing modifiable access to this
3654 /// object. The value currently held by this variant (if any) is
3655 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3656 /// must be the same as one of the types that this variant can hold.
3657 template <class TYPE>
3658 Variant7& operator=(const TYPE& value);
3659
3660 template <class TYPE>
3661#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3662 typename bsl::enable_if<
3663 !bsl::is_same<SelfType,
3664 typename bsl::remove_cvref<TYPE>::type>::value,
3665 SelfType>::type&
3666 operator=(TYPE&& value);
3667#else
3668 Variant7&
3670#endif
3671 // Assign to this object the specified 'value' of template parameter
3672 // 'TYPE', and return a reference providing modifiable access to this
3673 // object. The contents of 'value' are moved to this object with
3674 // 'value' left in a valid but unspecified state. The value currently
3675 // held by this variant (if any) is destroyed if that value's type is
3676 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3677 // that this variant can hold. Note that in C++11 mode, this method
3678 // does not participate in overload resolution if it would lead to
3679 // ambiguity with the move-assignment operator (below).
3680
3681 /// Assign to this object the type and value currently held by the
3682 /// specified `rhs` object, and return a reference providing modifiable
3683 /// access to this object. The value currently held by this variant
3684 /// (if any) is destroyed if that value's type is not the same as the
3685 /// type held by the `rhs` object.
3686 Variant7& operator=(const Variant7& rhs);
3687
3688 /// Assign to this object the type and value currently held by the
3689 /// specified `rhs` object, and return a reference providing modifiable
3690 /// access to this object. The value currently held by this variant
3691 /// (if any) is destroyed if that value's type is not the same as the
3692 /// type held by the `rhs` object. The contents of `rhs` are either
3693 /// move-inserted into or move-assigned to this object with `rhs` left
3694 /// in a valid but unspecified state.
3695 Variant7& operator=(bslmf::MovableRef<Variant7> rhs);
3696};
3697
3698 // ===================
3699 // class Variant8<...>
3700 // ===================
3701
3702/// This class is a "specialization" of `Variant` for a fixed number (8) of
3703/// types. Its 8 template arguments *must* all be specified (none are
3704/// defaulted to `bslmf::Nil`). It provides the same functionality as
3705/// `Variant<A1, A2, ..., A8>`.
3706template <class A1, class A2, class A3, class A4, class A5, class A6,
3707 class A7, class A8>
3708class Variant8 : public VariantImp<typename bslmf::TypeList8<
3709 A1, A2, A3, A4, A5, A6, A7, A8>::ListType> {
3710
3711 // PRIVATE TYPES
3712 typedef VariantImp<typename bslmf::TypeList8<A1, A2, A3, A4, A5, A6, A7,
3713 A8>::ListType> Imp;
3714
3715 /// `SelfType` is an alias to this class.
3717
3720
3721 public:
3722 // TRAITS
3725 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3728 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3731 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3733
3734 // CREATORS
3735
3736 /// Create a variant object in the unset state that uses the currently
3737 /// installed default allocator to supply memory.
3738 Variant8();
3739
3740 /// Create a variant object with the specified `valueOrAllocator` that
3741 /// can be either a value of a type that the variant can hold or an
3742 /// allocator to supply memory. If `valueOrAllocator` is not a
3743 /// `bslma::Allocator *`, then the variant will hold the value and type
3744 /// of `valueOrAllocator`, and use the currently installed default
3745 /// allocator to supply memory. Otherwise, the variant will be unset
3746 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3747 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3748 ///
3749 /// \note Note that this
3750 /// parameterized constructor is defined instead of two constructors
3751 /// (one taking a `bslma::Allocator *` and the other not) because
3752 /// template parameter arguments are always a better match than
3753 /// derived-to-base conversion (a concrete allocator pointer converted
3754 /// to `bslma::Allocator *`).
3755 template <class TYPE_OR_ALLOCATOR>
3756 explicit
3757 Variant8(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3758
3759 /// Create a variant object having the specified `value` of template
3760 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3761 /// supply memory. If `basicAllocator` is 0, the currently installed
3762 /// default allocator is used. `TYPE` must be the same as one of the
3763 /// types that this variant can hold.
3764 template <class TYPE>
3765 Variant8(const TYPE& value, bslma::Allocator *basicAllocator);
3766
3767 template <class TYPE>
3768 explicit
3769#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3770 Variant8(TYPE&& value,
3771 typename bsl::enable_if<
3772 !bsl::is_same<
3773 SelfType,
3774 typename bsl::remove_const<
3775 typename bsl::remove_reference<TYPE>::type>::type>::value
3776 &&
3778 void>::type * = 0);
3779#else
3781#endif
3782 // Create a variant object having the specified 'value' of template
3783 // parameter 'TYPE' by moving the contents of 'value' to the
3784 // newly-created object. Use the currently installed default allocator
3785 // to supply memory. 'value' is left in a valid but unspecified state.
3786 // 'TYPE' must be the same as one of the types that this variant can
3787 // hold. Note that in C++11 mode, this method does not participate in
3788 // overload resolution if it would lead to ambiguity with the move
3789 // constructor that does not take an allocator (below) or with the
3790 // constructor taking a 'valueOrAllocator' (above).
3791
3792 template <class TYPE>
3793#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3794 Variant8(TYPE&& value,
3795 typename bsl::enable_if<
3796 !bsl::is_same<
3797 SelfType,
3798 typename bsl::remove_const<
3799 typename bsl::remove_reference<TYPE>::type>::type>::value,
3800 bslma::Allocator>::type *basicAllocator);
3801#else
3803 bslma::Allocator *basicAllocator);
3804#endif
3805 // Create a variant object having the specified 'value' of template
3806 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3807 // memory. If 'basicAllocator' is 0, the currently installed default
3808 // allocator is used. The contents of 'value' are moved to the
3809 // newly-created object with 'value' left in a valid but unspecified
3810 // state. 'TYPE' must be the same as one of the types that this
3811 // variant can hold. Note that in C++11 mode, this method does not
3812 // participate in overload resolution if it would lead to ambiguity
3813 // with the move constructor that takes an allocator (below).
3814
3815 /// Create a variant object having the type and value of the specified
3816 /// `original` variant. Optionally specify a `basicAllocator` used to
3817 /// supply memory. If `basicAllocator` is 0, the currently installed
3818 /// default allocator is used.
3819 Variant8(const Variant8& original, bslma::Allocator *basicAllocator = 0);
3820
3821 /// Create a variant object having the type and value of the specified
3822 /// `original` object by moving the contents of `original` to the
3823 /// newly-created object. The allocator associated with `original` (if
3824 /// any) is propagated for use in the newly-created object. `original`
3825 /// is left in a valid but unspecified state.
3827
3828 /// Create a variant object having the type and value of the specified
3829 /// `original` object that uses the specified `basicAllocator` to supply
3830 /// memory. If `basicAllocator` is 0, the currently installed default
3831 /// allocator is used. The contents of `original` are moved to the
3832 /// newly-created object with `original` left in a valid but unspecified
3833 /// state.
3835 bslma::Allocator *basicAllocator);
3836
3837 // MANIPULATORS
3838
3839 /// Assign to this object the specified `value` of template parameter
3840 /// `TYPE`, and return a reference providing modifiable access to this
3841 /// object. The value currently held by this variant (if any) is
3842 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3843 /// must be the same as one of the types that this variant can hold.
3844 template <class TYPE>
3845 Variant8& operator=(const TYPE& value);
3846
3847 template <class TYPE>
3848#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3849 typename bsl::enable_if<
3850 !bsl::is_same<SelfType,
3851 typename bsl::remove_cvref<TYPE>::type>::value,
3852 SelfType>::type&
3853 operator=(TYPE&& value);
3854#else
3855 Variant8&
3857#endif
3858 // Assign to this object the specified 'value' of template parameter
3859 // 'TYPE', and return a reference providing modifiable access to this
3860 // object. The contents of 'value' are moved to this object with
3861 // 'value' left in a valid but unspecified state. The value currently
3862 // held by this variant (if any) is destroyed if that value's type is
3863 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3864 // that this variant can hold. Note that in C++11 mode, this method
3865 // does not participate in overload resolution if it would lead to
3866 // ambiguity with the move-assignment operator (below).
3867
3868 /// Assign to this object the type and value currently held by the
3869 /// specified `rhs` object, and return a reference providing modifiable
3870 /// access to this object. The value currently held by this variant
3871 /// (if any) is destroyed if that value's type is not the same as the
3872 /// type held by the `rhs` object.
3873 Variant8& operator=(const Variant8& rhs);
3874
3875 /// Assign to this object the type and value currently held by the
3876 /// specified `rhs` object, and return a reference providing modifiable
3877 /// access to this object. The value currently held by this variant
3878 /// (if any) is destroyed if that value's type is not the same as the
3879 /// type held by the `rhs` object. The contents of `rhs` are either
3880 /// move-inserted into or move-assigned to this object with `rhs` left
3881 /// in a valid but unspecified state.
3882 Variant8& operator=(bslmf::MovableRef<Variant8> rhs);
3883};
3884
3885 // ===================
3886 // class Variant9<...>
3887 // ===================
3888
3889/// This class is a "specialization" of `Variant` for a fixed number (9) of
3890/// types. Its 9 template arguments *must* all be specified (none are
3891/// defaulted to `bslmf::Nil`). It provides the same functionality as
3892/// `Variant<A1, A2, ..., A9>`.
3893template <class A1, class A2, class A3, class A4, class A5, class A6,
3894 class A7, class A8, class A9>
3895class Variant9 : public VariantImp<typename bslmf::TypeList9<
3896 A1, A2, A3, A4, A5, A6, A7, A8, A9>::ListType> {
3897
3898 // PRIVATE TYPES
3899 typedef VariantImp<typename bslmf::TypeList9<A1, A2, A3, A4, A5, A6, A7,
3900 A8, A9>::ListType> Imp;
3901
3902 /// `SelfType` is an alias to this class.
3904
3907
3908 public:
3909 // TRAITS
3912 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3915 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3918 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3920
3921 // CREATORS
3922
3923 /// Create a variant object in the unset state that uses the currently
3924 /// installed default allocator to supply memory.
3925 Variant9();
3926
3927 /// Create a variant object with the specified `valueOrAllocator` that
3928 /// can be either a value of a type that the variant can hold or an
3929 /// allocator to supply memory. If `valueOrAllocator` is not a
3930 /// `bslma::Allocator *`, then the variant will hold the value and type
3931 /// of `valueOrAllocator`, and use the currently installed default
3932 /// allocator to supply memory. Otherwise, the variant will be unset
3933 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3934 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3935 ///
3936 /// \note Note that this
3937 /// parameterized constructor is defined instead of two constructors
3938 /// (one taking a `bslma::Allocator *` and the other not) because
3939 /// template parameter arguments are always a better match than
3940 /// derived-to-base conversion (a concrete allocator pointer converted
3941 /// to `bslma::Allocator *`).
3942 template <class TYPE_OR_ALLOCATOR>
3943 explicit
3944 Variant9(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3945
3946 /// Create a variant object having the specified `value` of template
3947 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3948 /// supply memory. If `basicAllocator` is 0, the currently installed
3949 /// default allocator is used. `TYPE` must be the same as one of the
3950 /// types that this variant can hold.
3951 template <class TYPE>
3952 Variant9(const TYPE& value, bslma::Allocator *basicAllocator);
3953
3954 template <class TYPE>
3955 explicit
3956#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3957 Variant9(TYPE&& value,
3958 typename bsl::enable_if<
3959 !bsl::is_same<
3960 SelfType,
3961 typename bsl::remove_const<
3962 typename bsl::remove_reference<TYPE>::type>::type>::value
3963 &&
3965 void>::type * = 0);
3966#else
3968#endif
3969 // Create a variant object having the specified 'value' of template
3970 // parameter 'TYPE' by moving the contents of 'value' to the
3971 // newly-created object. Use the currently installed default allocator
3972 // to supply memory. 'value' is left in a valid but unspecified state.
3973 // 'TYPE' must be the same as one of the types that this variant can
3974 // hold. Note that in C++11 mode, this method does not participate in
3975 // overload resolution if it would lead to ambiguity with the move
3976 // constructor that does not take an allocator (below) or with the
3977 // constructor taking a 'valueOrAllocator' (above).
3978
3979 template <class TYPE>
3980#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3981 Variant9(TYPE&& value,
3982 typename bsl::enable_if<
3983 !bsl::is_same<
3984 SelfType,
3985 typename bsl::remove_const<
3986 typename bsl::remove_reference<TYPE>::type>::type>::value,
3987 bslma::Allocator>::type *basicAllocator);
3988#else
3990 bslma::Allocator *basicAllocator);
3991#endif
3992 // Create a variant object having the specified 'value' of template
3993 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3994 // memory. If 'basicAllocator' is 0, the currently installed default
3995 // allocator is used. The contents of 'value' are moved to the
3996 // newly-created object with 'value' left in a valid but unspecified
3997 // state. 'TYPE' must be the same as one of the types that this
3998 // variant can hold. Note that in C++11 mode, this method does not
3999 // participate in overload resolution if it would lead to ambiguity
4000 // with the move constructor that takes an allocator (below).
4001
4002 /// Create a variant object having the type and value of the specified
4003 /// `original` variant. Optionally specify a `basicAllocator` used to
4004 /// supply memory. If `basicAllocator` is 0, the currently installed
4005 /// default allocator is used.
4006 Variant9(const Variant9& original, bslma::Allocator *basicAllocator = 0);
4007
4008 /// Create a variant object having the type and value of the specified
4009 /// `original` object by moving the contents of `original` to the
4010 /// newly-created object. The allocator associated with `original` (if
4011 /// any) is propagated for use in the newly-created object. `original`
4012 /// is left in a valid but unspecified state.
4014
4015 /// Create a variant object having the type and value of the specified
4016 /// `original` object that uses the specified `basicAllocator` to supply
4017 /// memory. If `basicAllocator` is 0, the currently installed default
4018 /// allocator is used. The contents of `original` are moved to the
4019 /// newly-created object with `original` left in a valid but unspecified
4020 /// state.
4022 bslma::Allocator *basicAllocator);
4023
4024 // MANIPULATORS
4025
4026 /// Assign to this object the specified `value` of template parameter
4027 /// `TYPE`, and return a reference providing modifiable access to this
4028 /// object. The value currently held by this variant (if any) is
4029 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4030 /// must be the same as one of the types that this variant can hold.
4031 template <class TYPE>
4032 Variant9& operator=(const TYPE& value);
4033
4034 template <class TYPE>
4035#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4036 typename bsl::enable_if<
4037 !bsl::is_same<SelfType,
4038 typename bsl::remove_cvref<TYPE>::type>::value,
4039 SelfType>::type&
4040 operator=(TYPE&& value);
4041#else
4042 Variant9&
4044#endif
4045 // Assign to this object the specified 'value' of template parameter
4046 // 'TYPE', and return a reference providing modifiable access to this
4047 // object. The contents of 'value' are moved to this object with
4048 // 'value' left in a valid but unspecified state. The value currently
4049 // held by this variant (if any) is destroyed if that value's type is
4050 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4051 // that this variant can hold. Note that in C++11 mode, this method
4052 // does not participate in overload resolution if it would lead to
4053 // ambiguity with the move-assignment operator (below).
4054
4055 /// Assign to this object the type and value currently held by the
4056 /// specified `rhs` object, and return a reference providing modifiable
4057 /// access to this object. The value currently held by this variant
4058 /// (if any) is destroyed if that value's type is not the same as the
4059 /// type held by the `rhs` object.
4060 Variant9& operator=(const Variant9& rhs);
4061
4062 /// Assign to this object the type and value currently held by the
4063 /// specified `rhs` object, and return a reference providing modifiable
4064 /// access to this object. The value currently held by this variant
4065 /// (if any) is destroyed if that value's type is not the same as the
4066 /// type held by the `rhs` object. The contents of `rhs` are either
4067 /// move-inserted into or move-assigned to this object with `rhs` left
4068 /// in a valid but unspecified state.
4069 Variant9& operator=(bslmf::MovableRef<Variant9> rhs);
4070};
4071
4072 // ====================
4073 // class Variant10<...>
4074 // ====================
4075
4076/// This class is a "specialization" of `Variant` for a fixed number (10) of
4077/// types. Its 10 template arguments *must* all be specified (none are
4078/// defaulted to `bslmf::Nil`). It provides the same functionality as
4079/// `Variant<A1, A2, ..., A10>`.
4080template <class A1, class A2, class A3, class A4, class A5, class A6,
4081 class A7, class A8, class A9, class A10>
4082class Variant10 : public VariantImp<typename bslmf::TypeList10<
4083 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::ListType> {
4084
4085 // PRIVATE TYPES
4086 typedef VariantImp<typename bslmf::TypeList10<A1, A2, A3, A4, A5, A6, A7,
4087 A8, A9,
4088 A10>::ListType> Imp;
4089
4090 /// `SelfType` is an alias to this class.
4092
4095
4096 public:
4097 // TRAITS
4100 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4103 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4106 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4108
4109 // CREATORS
4110
4111 /// Create a variant object in the unset state that uses the currently
4112 /// installed default allocator to supply memory.
4113 Variant10();
4114
4115 /// Create a variant object with the specified `valueOrAllocator` that
4116 /// can be either a value of a type that the variant can hold or an
4117 /// allocator to supply memory. If `valueOrAllocator` is not a
4118 /// `bslma::Allocator *`, then the variant will hold the value and type
4119 /// of `valueOrAllocator`, and use the currently installed default
4120 /// allocator to supply memory. Otherwise, the variant will be unset
4121 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4122 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4123 ///
4124 /// \note Note that this
4125 /// parameterized constructor is defined instead of two constructors
4126 /// (one taking a `bslma::Allocator *` and the other not) because
4127 /// template parameter arguments are always a better match than
4128 /// derived-to-base conversion (a concrete allocator pointer converted
4129 /// to `bslma::Allocator *`).
4130 template <class TYPE_OR_ALLOCATOR>
4131 explicit
4132 Variant10(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4133
4134 /// Create a variant object having the specified `value` of template
4135 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4136 /// supply memory. If `basicAllocator` is 0, the currently installed
4137 /// default allocator is used. `TYPE` must be the same as one of the
4138 /// types that this variant can hold.
4139 template <class TYPE>
4140 Variant10(const TYPE& value, bslma::Allocator *basicAllocator);
4141
4142 template <class TYPE>
4143 explicit
4144#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4145 Variant10(TYPE&& value,
4146 typename bsl::enable_if<
4147 !bsl::is_same<
4148 SelfType,
4149 typename bsl::remove_const<
4150 typename bsl::remove_reference<TYPE>::type>::type>::value
4151 &&
4153 void>::type * = 0);
4154#else
4156#endif
4157 // Create a variant object having the specified 'value' of template
4158 // parameter 'TYPE' by moving the contents of 'value' to the
4159 // newly-created object. Use the currently installed default allocator
4160 // to supply memory. 'value' is left in a valid but unspecified state.
4161 // 'TYPE' must be the same as one of the types that this variant can
4162 // hold. Note that in C++11 mode, this method does not participate in
4163 // overload resolution if it would lead to ambiguity with the move
4164 // constructor that does not take an allocator (below) or with the
4165 // constructor taking a 'valueOrAllocator' (above).
4166
4167 template <class TYPE>
4168#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4169 Variant10(TYPE&& value,
4170 typename bsl::enable_if<
4171 !bsl::is_same<
4172 SelfType,
4173 typename bsl::remove_const<
4174 typename bsl::remove_reference<TYPE>::type>::type>::value,
4175 bslma::Allocator>::type *basicAllocator);
4176#else
4178 bslma::Allocator *basicAllocator);
4179#endif
4180 // Create a variant object having the specified 'value' of template
4181 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4182 // memory. If 'basicAllocator' is 0, the currently installed default
4183 // allocator is used. The contents of 'value' are moved to the
4184 // newly-created object with 'value' left in a valid but unspecified
4185 // state. 'TYPE' must be the same as one of the types that this
4186 // variant can hold. Note that in C++11 mode, this method does not
4187 // participate in overload resolution if it would lead to ambiguity
4188 // with the move constructor that takes an allocator (below).
4189
4190 /// Create a variant object having the type and value of the specified
4191 /// `original` variant. Optionally specify a `basicAllocator` used to
4192 /// supply memory. If `basicAllocator` is 0, the currently installed
4193 /// default allocator is used.
4194 Variant10(const Variant10& original, bslma::Allocator *basicAllocator = 0);
4195
4196 /// Create a variant object having the type and value of the specified
4197 /// `original` object by moving the contents of `original` to the
4198 /// newly-created object. The allocator associated with `original` (if
4199 /// any) is propagated for use in the newly-created object. `original`
4200 /// is left in a valid but unspecified state.
4202
4203 /// Create a variant object having the type and value of the specified
4204 /// `original` object that uses the specified `basicAllocator` to supply
4205 /// memory. If `basicAllocator` is 0, the currently installed default
4206 /// allocator is used. The contents of `original` are moved to the
4207 /// newly-created object with `original` left in a valid but unspecified
4208 /// state.
4210 bslma::Allocator *basicAllocator);
4211
4212 // MANIPULATORS
4213
4214 /// Assign to this object the specified `value` of template parameter
4215 /// `TYPE`, and return a reference providing modifiable access to this
4216 /// object. The value currently held by this variant (if any) is
4217 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4218 /// must be the same as one of the types that this variant can hold.
4219 template <class TYPE>
4220 Variant10& operator=(const TYPE& value);
4221
4222 template <class TYPE>
4223#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4224 typename bsl::enable_if<
4225 !bsl::is_same<SelfType,
4226 typename bsl::remove_cvref<TYPE>::type>::value,
4227 SelfType>::type&
4228 operator=(TYPE&& value);
4229#else
4230 Variant10&
4232#endif
4233 // Assign to this object the specified 'value' of template parameter
4234 // 'TYPE', and return a reference providing modifiable access to this
4235 // object. The contents of 'value' are moved to this object with
4236 // 'value' left in a valid but unspecified state. The value currently
4237 // held by this variant (if any) is destroyed if that value's type is
4238 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4239 // that this variant can hold. Note that in C++11 mode, this method
4240 // does not participate in overload resolution if it would lead to
4241 // ambiguity with the move-assignment operator (below).
4242
4243 /// Assign to this object the type and value currently held by the
4244 /// specified `rhs` object, and return a reference providing modifiable
4245 /// access to this object. The value currently held by this variant
4246 /// (if any) is destroyed if that value's type is not the same as the
4247 /// type held by the `rhs` object.
4248 Variant10& operator=(const Variant10& rhs);
4249
4250 /// Assign to this object the type and value currently held by the
4251 /// specified `rhs` object, and return a reference providing modifiable
4252 /// access to this object. The value currently held by this variant
4253 /// (if any) is destroyed if that value's type is not the same as the
4254 /// type held by the `rhs` object. The contents of `rhs` are either
4255 /// move-inserted into or move-assigned to this object with `rhs` left
4256 /// in a valid but unspecified state.
4258};
4259
4260 // ====================
4261 // class Variant11<...>
4262 // ====================
4263
4264/// This class is a "specialization" of `Variant` for a fixed number (11) of
4265/// types. Its 11 template arguments *must* all be specified (none are
4266/// defaulted to `bslmf::Nil`). It provides the same functionality as
4267/// `Variant<A1, A2, ..., A11>`.
4268template <class A1, class A2, class A3, class A4, class A5, class A6,
4269 class A7, class A8, class A9, class A10, class A11>
4270class Variant11 : public VariantImp<typename bslmf::TypeList11<
4271 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::ListType> {
4272
4273 // PRIVATE TYPES
4274 typedef VariantImp<typename bslmf::TypeList11<A1, A2, A3, A4, A5, A6, A7,
4275 A8, A9, A10,
4276 A11>::ListType> Imp;
4277
4278 /// `SelfType` is an alias to this class.
4279 typedef Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
4280 A11> SelfType;
4281
4284
4285 public:
4286 // TRAITS
4289 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4292 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4295 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4297
4298 // CREATORS
4299
4300 /// Create a variant object in the unset state that uses the currently
4301 /// installed default allocator to supply memory.
4302 Variant11();
4303
4304 /// Create a variant object with the specified `valueOrAllocator` that
4305 /// can be either a value of a type that the variant can hold or an
4306 /// allocator to supply memory. If `valueOrAllocator` is not a
4307 /// `bslma::Allocator *`, then the variant will hold the value and type
4308 /// of `valueOrAllocator`, and use the currently installed default
4309 /// allocator to supply memory. Otherwise, the variant will be unset
4310 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4311 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4312 ///
4313 /// \note Note that this
4314 /// parameterized constructor is defined instead of two constructors
4315 /// (one taking a `bslma::Allocator *` and the other not) because
4316 /// template parameter arguments are always a better match than
4317 /// derived-to-base conversion (a concrete allocator pointer converted
4318 /// to `bslma::Allocator *`).
4319 template <class TYPE_OR_ALLOCATOR>
4320 explicit
4321 Variant11(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4322
4323 /// Create a variant object having the specified `value` of template
4324 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4325 /// supply memory. If `basicAllocator` is 0, the currently installed
4326 /// default allocator is used. `TYPE` must be the same as one of the
4327 /// types that this variant can hold.
4328 template <class TYPE>
4329 Variant11(const TYPE& value, bslma::Allocator *basicAllocator);
4330
4331 template <class TYPE>
4332 explicit
4333#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4334 Variant11(TYPE&& value,
4335 typename bsl::enable_if<
4336 !bsl::is_same<
4337 SelfType,
4338 typename bsl::remove_const<
4339 typename bsl::remove_reference<TYPE>::type>::type>::value
4340 &&
4342 void>::type * = 0);
4343#else
4345#endif
4346 // Create a variant object having the specified 'value' of template
4347 // parameter 'TYPE' by moving the contents of 'value' to the
4348 // newly-created object. Use the currently installed default allocator
4349 // to supply memory. 'value' is left in a valid but unspecified state.
4350 // 'TYPE' must be the same as one of the types that this variant can
4351 // hold. Note that in C++11 mode, this method does not participate in
4352 // overload resolution if it would lead to ambiguity with the move
4353 // constructor that does not take an allocator (below) or with the
4354 // constructor taking a 'valueOrAllocator' (above).
4355
4356 template <class TYPE>
4357#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4358 Variant11(TYPE&& value,
4359 typename bsl::enable_if<
4360 !bsl::is_same<
4361 SelfType,
4362 typename bsl::remove_const<
4363 typename bsl::remove_reference<TYPE>::type>::type>::value,
4364 bslma::Allocator>::type *basicAllocator);
4365#else
4367 bslma::Allocator *basicAllocator);
4368#endif
4369 // Create a variant object having the specified 'value' of template
4370 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4371 // memory. If 'basicAllocator' is 0, the currently installed default
4372 // allocator is used. The contents of 'value' are moved to the
4373 // newly-created object with 'value' left in a valid but unspecified
4374 // state. 'TYPE' must be the same as one of the types that this
4375 // variant can hold. Note that in C++11 mode, this method does not
4376 // participate in overload resolution if it would lead to ambiguity
4377 // with the move constructor that takes an allocator (below).
4378
4379 /// Create a variant object having the type and value of the specified
4380 /// `original` variant. Optionally specify a `basicAllocator` used to
4381 /// supply memory. If `basicAllocator` is 0, the currently installed
4382 /// default allocator is used.
4383 Variant11(const Variant11& original, bslma::Allocator *basicAllocator = 0);
4384
4385 /// Create a variant object having the type and value of the specified
4386 /// `original` object by moving the contents of `original` to the
4387 /// newly-created object. The allocator associated with `original` (if
4388 /// any) is propagated for use in the newly-created object. `original`
4389 /// is left in a valid but unspecified state.
4391
4392 /// Create a variant object having the type and value of the specified
4393 /// `original` object that uses the specified `basicAllocator` to supply
4394 /// memory. If `basicAllocator` is 0, the currently installed default
4395 /// allocator is used. The contents of `original` are moved to the
4396 /// newly-created object with `original` left in a valid but unspecified
4397 /// state.
4399 bslma::Allocator *basicAllocator);
4400
4401 // MANIPULATORS
4402
4403 /// Assign to this object the specified `value` of template parameter
4404 /// `TYPE`, and return a reference providing modifiable access to this
4405 /// object. The value currently held by this variant (if any) is
4406 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4407 /// must be the same as one of the types that this variant can hold.
4408 template <class TYPE>
4409 Variant11& operator=(const TYPE& value);
4410
4411 template <class TYPE>
4412#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4413 typename bsl::enable_if<
4414 !bsl::is_same<SelfType,
4415 typename bsl::remove_cvref<TYPE>::type>::value,
4416 SelfType>::type&
4417 operator=(TYPE&& value);
4418#else
4419 Variant11&
4421#endif
4422 // Assign to this object the specified 'value' of template parameter
4423 // 'TYPE', and return a reference providing modifiable access to this
4424 // object. The contents of 'value' are moved to this object with
4425 // 'value' left in a valid but unspecified state. The value currently
4426 // held by this variant (if any) is destroyed if that value's type is
4427 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4428 // that this variant can hold. Note that in C++11 mode, this method
4429 // does not participate in overload resolution if it would lead to
4430 // ambiguity with the move-assignment operator (below).
4431
4432 /// Assign to this object the type and value currently held by the
4433 /// specified `rhs` object, and return a reference providing modifiable
4434 /// access to this object. The value currently held by this variant
4435 /// (if any) is destroyed if that value's type is not the same as the
4436 /// type held by the `rhs` object.
4437 Variant11& operator=(const Variant11& rhs);
4438
4439 /// Assign to this object the type and value currently held by the
4440 /// specified `rhs` object, and return a reference providing modifiable
4441 /// access to this object. The value currently held by this variant
4442 /// (if any) is destroyed if that value's type is not the same as the
4443 /// type held by the `rhs` object. The contents of `rhs` are either
4444 /// move-inserted into or move-assigned to this object with `rhs` left
4445 /// in a valid but unspecified state.
4447};
4448
4449 // ====================
4450 // class Variant12<...>
4451 // ====================
4452
4453/// This class is a "specialization" of `Variant` for a fixed number (12) of
4454/// types. Its 12 template arguments *must* all be specified (none are
4455/// defaulted to `bslmf::Nil`). It provides the same functionality as
4456/// `Variant<A1, A2, ..., A12>`.
4457template <class A1, class A2, class A3, class A4, class A5, class A6,
4458 class A7, class A8, class A9, class A10, class A11, class A12>
4459class Variant12 : public VariantImp<typename bslmf::TypeList12<
4460 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::ListType> {
4461
4462 // PRIVATE TYPES
4463 typedef VariantImp<typename bslmf::TypeList12<A1, A2, A3, A4, A5, A6,
4464 A7, A8, A9, A10, A11,
4465 A12>::ListType> Imp;
4466
4467 /// `SelfType` is an alias to this class.
4468 typedef Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
4469 A11, A12> SelfType;
4470
4473
4474 public:
4475 // TRAITS
4478 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4481 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4484 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4486
4487 // CREATORS
4488
4489 /// Create a variant object in the unset state that uses the currently
4490 /// installed default allocator to supply memory.
4491 Variant12();
4492
4493 /// Create a variant object with the specified `valueOrAllocator` that
4494 /// can be either a value of a type that the variant can hold or an
4495 /// allocator to supply memory. If `valueOrAllocator` is not a
4496 /// `bslma::Allocator *`, then the variant will hold the value and type
4497 /// of `valueOrAllocator`, and use the currently installed default
4498 /// allocator to supply memory. Otherwise, the variant will be unset
4499 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4500 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4501 ///
4502 /// \note Note that this
4503 /// parameterized constructor is defined instead of two constructors
4504 /// (one taking a `bslma::Allocator *` and the other not) because
4505 /// template parameter arguments are always a better match than
4506 /// derived-to-base conversion (a concrete allocator pointer converted
4507 /// to `bslma::Allocator *`).
4508 template <class TYPE_OR_ALLOCATOR>
4509 explicit
4510 Variant12(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4511
4512 /// Create a variant object having the specified `value` of template
4513 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4514 /// supply memory. If `basicAllocator` is 0, the currently installed
4515 /// default allocator is used. `TYPE` must be the same as one of the
4516 /// types that this variant can hold.
4517 template <class TYPE>
4518 Variant12(const TYPE& value, bslma::Allocator *basicAllocator);
4519
4520 template <class TYPE>
4521 explicit
4522#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4523 Variant12(TYPE&& value,
4524 typename bsl::enable_if<
4525 !bsl::is_same<
4526 SelfType,
4527 typename bsl::remove_const<
4528 typename bsl::remove_reference<TYPE>::type>::type>::value
4529 &&
4531 void>::type * = 0);
4532#else
4534#endif
4535 // Create a variant object having the specified 'value' of template
4536 // parameter 'TYPE' by moving the contents of 'value' to the
4537 // newly-created object. Use the currently installed default allocator
4538 // to supply memory. 'value' is left in a valid but unspecified state.
4539 // 'TYPE' must be the same as one of the types that this variant can
4540 // hold. Note that in C++11 mode, this method does not participate in
4541 // overload resolution if it would lead to ambiguity with the move
4542 // constructor that does not take an allocator (below) or with the
4543 // constructor taking a 'valueOrAllocator' (above).
4544
4545 template <class TYPE>
4546#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4547 Variant12(TYPE&& value,
4548 typename bsl::enable_if<
4549 !bsl::is_same<
4550 SelfType,
4551 typename bsl::remove_const<
4552 typename bsl::remove_reference<TYPE>::type>::type>::value,
4553 bslma::Allocator>::type *basicAllocator);
4554#else
4556 bslma::Allocator *basicAllocator);
4557#endif
4558 // Create a variant object having the specified 'value' of template
4559 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4560 // memory. If 'basicAllocator' is 0, the currently installed default
4561 // allocator is used. The contents of 'value' are moved to the
4562 // newly-created object with 'value' left in a valid but unspecified
4563 // state. 'TYPE' must be the same as one of the types that this
4564 // variant can hold. Note that in C++11 mode, this method does not
4565 // participate in overload resolution if it would lead to ambiguity
4566 // with the move constructor that takes an allocator (below).
4567
4568 /// Create a variant object having the type and value of the specified
4569 /// `original` variant. Optionally specify a `basicAllocator` used to
4570 /// supply memory. If `basicAllocator` is 0, the currently installed
4571 /// default allocator is used.
4572 Variant12(const Variant12& original, bslma::Allocator *basicAllocator = 0);
4573
4574 /// Create a variant object having the type and value of the specified
4575 /// `original` object by moving the contents of `original` to the
4576 /// newly-created object. The allocator associated with `original` (if
4577 /// any) is propagated for use in the newly-created object. `original`
4578 /// is left in a valid but unspecified state.
4580
4581 /// Create a variant object having the type and value of the specified
4582 /// `original` object that uses the specified `basicAllocator` to supply
4583 /// memory. If `basicAllocator` is 0, the currently installed default
4584 /// allocator is used. The contents of `original` are moved to the
4585 /// newly-created object with `original` left in a valid but unspecified
4586 /// state.
4588 bslma::Allocator *basicAllocator);
4589
4590 // MANIPULATORS
4591
4592 /// Assign to this object the specified `value` of template parameter
4593 /// `TYPE`, and return a reference providing modifiable access to this
4594 /// object. The value currently held by this variant (if any) is
4595 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4596 /// must be the same as one of the types that this variant can hold.
4597 template <class TYPE>
4598 Variant12& operator=(const TYPE& value);
4599
4600 template <class TYPE>
4601#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4602 typename bsl::enable_if<
4603 !bsl::is_same<SelfType,
4604 typename bsl::remove_cvref<TYPE>::type>::value,
4605 SelfType>::type&
4606 operator=(TYPE&& value);
4607#else
4608 Variant12&
4610#endif
4611 // Assign to this object the specified 'value' of template parameter
4612 // 'TYPE', and return a reference providing modifiable access to this
4613 // object. The contents of 'value' are moved to this object with
4614 // 'value' left in a valid but unspecified state. The value currently
4615 // held by this variant (if any) is destroyed if that value's type is
4616 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4617 // that this variant can hold. Note that in C++11 mode, this method
4618 // does not participate in overload resolution if it would lead to
4619 // ambiguity with the move-assignment operator (below).
4620
4621 /// Assign to this object the type and value currently held by the
4622 /// specified `rhs` object, and return a reference providing modifiable
4623 /// access to this object. The value currently held by this variant
4624 /// (if any) is destroyed if that value's type is not the same as the
4625 /// type held by the `rhs` object.
4626 Variant12& operator=(const Variant12& rhs);
4627
4628 /// Assign to this object the type and value currently held by the
4629 /// specified `rhs` object, and return a reference providing modifiable
4630 /// access to this object. The value currently held by this variant
4631 /// (if any) is destroyed if that value's type is not the same as the
4632 /// type held by the `rhs` object. The contents of `rhs` are either
4633 /// move-inserted into or move-assigned to this object with `rhs` left
4634 /// in a valid but unspecified state.
4636};
4637
4638 // ====================
4639 // class Variant13<...>
4640 // ====================
4641
4642/// This class is a "specialization" of `Variant` for a fixed number (13) of
4643/// types. Its 13 template arguments *must* all be specified (none are
4644/// defaulted to `bslmf::Nil`). It provides the same functionality as
4645/// `Variant<A1, A2, ..., A13>`.
4646template <class A1, class A2, class A3, class A4, class A5, class A6,
4647 class A7, class A8, class A9, class A10, class A11, class A12,
4648 class A13>
4649class Variant13 : public VariantImp<typename bslmf::TypeList13<
4650 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::ListType> {
4651
4652 // PRIVATE TYPES
4653 typedef VariantImp<typename bslmf::TypeList13<A1, A2, A3, A4, A5, A6,
4654 A7, A8, A9, A10, A11, A12,
4655 A13>::ListType> Imp;
4656
4657 /// `SelfType` is an alias to this class.
4658 typedef Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4659 A10, A11, A12, A13> SelfType;
4660
4663
4664 public:
4665 // TRAITS
4668 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4671 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4674 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4676
4677 // CREATORS
4678
4679 /// Create a variant object in the unset state that uses the currently
4680 /// installed default allocator to supply memory.
4681 Variant13();
4682
4683 /// Create a variant object with the specified `valueOrAllocator` that
4684 /// can be either a value of a type that the variant can hold or an
4685 /// allocator to supply memory. If `valueOrAllocator` is not a
4686 /// `bslma::Allocator *`, then the variant will hold the value and type
4687 /// of `valueOrAllocator`, and use the currently installed default
4688 /// allocator to supply memory. Otherwise, the variant will be unset
4689 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4690 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4691 ///
4692 /// \note Note that this
4693 /// parameterized constructor is defined instead of two constructors
4694 /// (one taking a `bslma::Allocator *` and the other not) because
4695 /// template parameter arguments are always a better match than
4696 /// derived-to-base conversion (a concrete allocator pointer converted
4697 /// to `bslma::Allocator *`).
4698 template <class TYPE_OR_ALLOCATOR>
4699 explicit
4700 Variant13(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4701
4702 /// Create a variant object having the specified `value` of template
4703 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4704 /// supply memory. If `basicAllocator` is 0, the currently installed
4705 /// default allocator is used. `TYPE` must be the same as one of the
4706 /// types that this variant can hold.
4707 template <class TYPE>
4708 Variant13(const TYPE& value, bslma::Allocator *basicAllocator);
4709
4710 template <class TYPE>
4711 explicit
4712#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4713 Variant13(TYPE&& value,
4714 typename bsl::enable_if<
4715 !bsl::is_same<
4716 SelfType,
4717 typename bsl::remove_const<
4718 typename bsl::remove_reference<TYPE>::type>::type>::value
4719 &&
4721 void>::type * = 0);
4722#else
4724#endif
4725 // Create a variant object having the specified 'value' of template
4726 // parameter 'TYPE' by moving the contents of 'value' to the
4727 // newly-created object. Use the currently installed default allocator
4728 // to supply memory. 'value' is left in a valid but unspecified state.
4729 // 'TYPE' must be the same as one of the types that this variant can
4730 // hold. Note that in C++11 mode, this method does not participate in
4731 // overload resolution if it would lead to ambiguity with the move
4732 // constructor that does not take an allocator (below) or with the
4733 // constructor taking a 'valueOrAllocator' (above).
4734
4735 template <class TYPE>
4736#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4737 Variant13(TYPE&& value,
4738 typename bsl::enable_if<
4739 !bsl::is_same<
4740 SelfType,
4741 typename bsl::remove_const<
4742 typename bsl::remove_reference<TYPE>::type>::type>::value,
4743 bslma::Allocator>::type *basicAllocator);
4744#else
4746 bslma::Allocator *basicAllocator);
4747#endif
4748 // Create a variant object having the specified 'value' of template
4749 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4750 // memory. If 'basicAllocator' is 0, the currently installed default
4751 // allocator is used. The contents of 'value' are moved to the
4752 // newly-created object with 'value' left in a valid but unspecified
4753 // state. 'TYPE' must be the same as one of the types that this
4754 // variant can hold. Note that in C++11 mode, this method does not
4755 // participate in overload resolution if it would lead to ambiguity
4756 // with the move constructor that takes an allocator (below).
4757
4758 /// Create a variant object having the type and value of the specified
4759 /// `original` variant. Optionally specify a `basicAllocator` used to
4760 /// supply memory. If `basicAllocator` is 0, the currently installed
4761 /// default allocator is used.
4762 Variant13(const Variant13& original, bslma::Allocator *basicAllocator = 0);
4763
4764 /// Create a variant object having the type and value of the specified
4765 /// `original` object by moving the contents of `original` to the
4766 /// newly-created object. The allocator associated with `original` (if
4767 /// any) is propagated for use in the newly-created object. `original`
4768 /// is left in a valid but unspecified state.
4770
4771 /// Create a variant object having the type and value of the specified
4772 /// `original` object that uses the specified `basicAllocator` to supply
4773 /// memory. If `basicAllocator` is 0, the currently installed default
4774 /// allocator is used. The contents of `original` are moved to the
4775 /// newly-created object with `original` left in a valid but unspecified
4776 /// state.
4778 bslma::Allocator *basicAllocator);
4779
4780 // MANIPULATORS
4781
4782 /// Assign to this object the specified `value` of template parameter
4783 /// `TYPE`, and return a reference providing modifiable access to this
4784 /// object. The value currently held by this variant (if any) is
4785 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4786 /// must be the same as one of the types that this variant can hold.
4787 template <class TYPE>
4788 Variant13& operator=(const TYPE& value);
4789
4790 template <class TYPE>
4791#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4792 typename bsl::enable_if<
4793 !bsl::is_same<SelfType,
4794 typename bsl::remove_cvref<TYPE>::type>::value,
4795 SelfType>::type&
4796 operator=(TYPE&& value);
4797#else
4798 Variant13&
4800#endif
4801 // Assign to this object the specified 'value' of template parameter
4802 // 'TYPE', and return a reference providing modifiable access to this
4803 // object. The contents of 'value' are moved to this object with
4804 // 'value' left in a valid but unspecified state. The value currently
4805 // held by this variant (if any) is destroyed if that value's type is
4806 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4807 // that this variant can hold. Note that in C++11 mode, this method
4808 // does not participate in overload resolution if it would lead to
4809 // ambiguity with the move-assignment operator (below).
4810
4811 /// Assign to this object the type and value currently held by the
4812 /// specified `rhs` object, and return a reference providing modifiable
4813 /// access to this object. The value currently held by this variant
4814 /// (if any) is destroyed if that value's type is not the same as the
4815 /// type held by the `rhs` object.
4816 Variant13& operator=(const Variant13& rhs);
4817
4818 /// Assign to this object the type and value currently held by the
4819 /// specified `rhs` object, and return a reference providing modifiable
4820 /// access to this object. The value currently held by this variant
4821 /// (if any) is destroyed if that value's type is not the same as the
4822 /// type held by the `rhs` object. The contents of `rhs` are either
4823 /// move-inserted into or move-assigned to this object with `rhs` left
4824 /// in a valid but unspecified state.
4826};
4827
4828 // ====================
4829 // class Variant14<...>
4830 // ====================
4831
4832/// This class is a "specialization" of `Variant` for a fixed number (14) of
4833/// types. Its 14 template arguments *must* all be specified (none are
4834/// defaulted to `bslmf::Nil`). It provides the same functionality as
4835/// `Variant<A1, A2, ..., A14>`.
4836template <class A1, class A2, class A3, class A4, class A5, class A6,
4837 class A7, class A8, class A9, class A10, class A11, class A12,
4838 class A13, class A14>
4839class Variant14 : public VariantImp<typename bslmf::TypeList14<
4840 A1, A2, A3, A4, A5,
4841 A6, A7, A8, A9, A10,
4842 A11, A12, A13, A14>::ListType> {
4843
4844 // PRIVATE TYPES
4845 typedef VariantImp<typename bslmf::TypeList14<A1, A2, A3, A4, A5, A6,
4846 A7, A8, A9, A10, A11, A12,
4847 A13,
4848 A14>::ListType> Imp;
4849
4850 /// `SelfType` is an alias to this class.
4851 typedef Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4852 A10, A11, A12, A13, A14> SelfType;
4853
4856
4857 public:
4858 // TRAITS
4861 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4864 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4867 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4869
4870 // CREATORS
4871
4872 /// Create a variant object in the unset state that uses the currently
4873 /// installed default allocator to supply memory.
4874 Variant14();
4875
4876 /// Create a variant object with the specified `valueOrAllocator` that
4877 /// can be either a value of a type that the variant can hold or an
4878 /// allocator to supply memory. If `valueOrAllocator` is not a
4879 /// `bslma::Allocator *`, then the variant will hold the value and type
4880 /// of `valueOrAllocator`, and use the currently installed default
4881 /// allocator to supply memory. Otherwise, the variant will be unset
4882 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4883 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4884 ///
4885 /// \note Note that this
4886 /// parameterized constructor is defined instead of two constructors
4887 /// (one taking a `bslma::Allocator *` and the other not) because
4888 /// template parameter arguments are always a better match than
4889 /// derived-to-base conversion (a concrete allocator pointer converted
4890 /// to `bslma::Allocator *`).
4891 template <class TYPE_OR_ALLOCATOR>
4892 explicit
4893 Variant14(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4894
4895 /// Create a variant object having the specified `value` of template
4896 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4897 /// supply memory. If `basicAllocator` is 0, the currently installed
4898 /// default allocator is used. `TYPE` must be the same as one of the
4899 /// types that this variant can hold.
4900 template <class TYPE>
4901 Variant14(const TYPE& value, bslma::Allocator *basicAllocator);
4902
4903 template <class TYPE>
4904 explicit
4905#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4906 Variant14(TYPE&& value,
4907 typename bsl::enable_if<
4908 !bsl::is_same<
4909 SelfType,
4910 typename bsl::remove_const<
4911 typename bsl::remove_reference<TYPE>::type>::type>::value
4912 &&
4914 void>::type * = 0);
4915#else
4917#endif
4918 // Create a variant object having the specified 'value' of template
4919 // parameter 'TYPE' by moving the contents of 'value' to the
4920 // newly-created object. Use the currently installed default allocator
4921 // to supply memory. 'value' is left in a valid but unspecified state.
4922 // 'TYPE' must be the same as one of the types that this variant can
4923 // hold. Note that in C++11 mode, this method does not participate in
4924 // overload resolution if it would lead to ambiguity with the move
4925 // constructor that does not take an allocator (below) or with the
4926 // constructor taking a 'valueOrAllocator' (above).
4927
4928 template <class TYPE>
4929#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4930 Variant14(TYPE&& value,
4931 typename bsl::enable_if<
4932 !bsl::is_same<
4933 SelfType,
4934 typename bsl::remove_const<
4935 typename bsl::remove_reference<TYPE>::type>::type>::value,
4936 bslma::Allocator>::type *basicAllocator);
4937#else
4939 bslma::Allocator *basicAllocator);
4940#endif
4941 // Create a variant object having the specified 'value' of template
4942 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4943 // memory. If 'basicAllocator' is 0, the currently installed default
4944 // allocator is used. The contents of 'value' are moved to the
4945 // newly-created object with 'value' left in a valid but unspecified
4946 // state. 'TYPE' must be the same as one of the types that this
4947 // variant can hold. Note that in C++11 mode, this method does not
4948 // participate in overload resolution if it would lead to ambiguity
4949 // with the move constructor that takes an allocator (below).
4950
4951 /// Create a variant object having the type and value of the specified
4952 /// `original` variant. Optionally specify a `basicAllocator` used to
4953 /// supply memory. If `basicAllocator` is 0, the currently installed
4954 /// default allocator is used.
4955 Variant14(const Variant14& original, bslma::Allocator *basicAllocator = 0);
4956
4957 /// Create a variant object having the type and value of the specified
4958 /// `original` object by moving the contents of `original` to the
4959 /// newly-created object. The allocator associated with `original` (if
4960 /// any) is propagated for use in the newly-created object. `original`
4961 /// is left in a valid but unspecified state.
4963
4964 /// Create a variant object having the type and value of the specified
4965 /// `original` object that uses the specified `basicAllocator` to supply
4966 /// memory. If `basicAllocator` is 0, the currently installed default
4967 /// allocator is used. The contents of `original` are moved to the
4968 /// newly-created object with `original` left in a valid but unspecified
4969 /// state.
4971 bslma::Allocator *basicAllocator);
4972
4973 // MANIPULATORS
4974
4975 /// Assign to this object the specified `value` of template parameter
4976 /// `TYPE`, and return a reference providing modifiable access to this
4977 /// object. The value currently held by this variant (if any) is
4978 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4979 /// must be the same as one of the types that this variant can hold.
4980 template <class TYPE>
4981 Variant14& operator=(const TYPE& value);
4982
4983 template <class TYPE>
4984#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4985 typename bsl::enable_if<
4986 !bsl::is_same<SelfType,
4987 typename bsl::remove_cvref<TYPE>::type>::value,
4988 SelfType>::type&
4989 operator=(TYPE&& value);
4990#else
4991 Variant14&
4993#endif
4994 // Assign to this object the specified 'value' of template parameter
4995 // 'TYPE', and return a reference providing modifiable access to this
4996 // object. The contents of 'value' are moved to this object with
4997 // 'value' left in a valid but unspecified state. The value currently
4998 // held by this variant (if any) is destroyed if that value's type is
4999 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5000 // that this variant can hold. Note that in C++11 mode, this method
5001 // does not participate in overload resolution if it would lead to
5002 // ambiguity with the move-assignment operator (below).
5003
5004 /// Assign to this object the type and value currently held by the
5005 /// specified `rhs` object, and return a reference providing modifiable
5006 /// access to this object. The value currently held by this variant
5007 /// (if any) is destroyed if that value's type is not the same as the
5008 /// type held by the `rhs` object.
5009 Variant14& operator=(const Variant14& rhs);
5010
5011 /// Assign to this object the type and value currently held by the
5012 /// specified `rhs` object, and return a reference providing modifiable
5013 /// access to this object. The value currently held by this variant
5014 /// (if any) is destroyed if that value's type is not the same as the
5015 /// type held by the `rhs` object. The contents of `rhs` are either
5016 /// move-inserted into or move-assigned to this object with `rhs` left
5017 /// in a valid but unspecified state.
5019};
5020
5021 // ====================
5022 // class Variant15<...>
5023 // ====================
5024
5025/// This class is a "specialization" of `Variant` for a fixed number (15) of
5026/// types. Its 15 template arguments *must* all be specified (none are
5027/// defaulted to `bslmf::Nil`). It provides the same functionality as
5028/// `Variant<A1, A2, ..., A15>`.
5029template <class A1, class A2, class A3, class A4, class A5, class A6,
5030 class A7, class A8, class A9, class A10, class A11, class A12,
5031 class A13, class A14, class A15>
5032class Variant15 : public VariantImp<typename bslmf::TypeList15<
5033 A1, A2, A3, A4, A5,
5034 A6, A7, A8, A9, A10,
5035 A11, A12, A13, A14, A15>::ListType> {
5036
5037 // PRIVATE TYPES
5038 typedef VariantImp<typename bslmf::TypeList15<A1, A2, A3, A4, A5, A6,
5039 A7, A8, A9, A10, A11, A12,
5040 A13, A14,
5041 A15>::ListType> Imp;
5042
5043 /// `SelfType` is an alias to this class.
5044 typedef Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5045 A10, A11, A12, A13, A14, A15> SelfType;
5046
5049
5050 public:
5051 // TRAITS
5054 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5057 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5060 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5062
5063 // CREATORS
5064
5065 /// Create a variant object in the unset state that uses the currently
5066 /// installed default allocator to supply memory.
5067 Variant15();
5068
5069 /// Create a variant object with the specified `valueOrAllocator` that
5070 /// can be either a value of a type that the variant can hold or an
5071 /// allocator to supply memory. If `valueOrAllocator` is not a
5072 /// `bslma::Allocator *`, then the variant will hold the value and type
5073 /// of `valueOrAllocator`, and use the currently installed default
5074 /// allocator to supply memory. Otherwise, the variant will be unset
5075 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5076 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5077 ///
5078 /// \note Note that this
5079 /// parameterized constructor is defined instead of two constructors
5080 /// (one taking a `bslma::Allocator *` and the other not) because
5081 /// template parameter arguments are always a better match than
5082 /// derived-to-base conversion (a concrete allocator pointer converted
5083 /// to `bslma::Allocator *`).
5084 template <class TYPE_OR_ALLOCATOR>
5085 explicit
5086 Variant15(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5087
5088 /// Create a variant object having the specified `value` of template
5089 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5090 /// supply memory. If `basicAllocator` is 0, the currently installed
5091 /// default allocator is used. `TYPE` must be the same as one of the
5092 /// types that this variant can hold.
5093 template <class TYPE>
5094 Variant15(const TYPE& value, bslma::Allocator *basicAllocator);
5095
5096 template <class TYPE>
5097 explicit
5098#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5099 Variant15(TYPE&& value,
5100 typename bsl::enable_if<
5101 !bsl::is_same<
5102 SelfType,
5103 typename bsl::remove_const<
5104 typename bsl::remove_reference<TYPE>::type>::type>::value
5105 &&
5107 void>::type * = 0);
5108#else
5110#endif
5111 // Create a variant object having the specified 'value' of template
5112 // parameter 'TYPE' by moving the contents of 'value' to the
5113 // newly-created object. Use the currently installed default allocator
5114 // to supply memory. 'value' is left in a valid but unspecified state.
5115 // 'TYPE' must be the same as one of the types that this variant can
5116 // hold. Note that in C++11 mode, this method does not participate in
5117 // overload resolution if it would lead to ambiguity with the move
5118 // constructor that does not take an allocator (below) or with the
5119 // constructor taking a 'valueOrAllocator' (above).
5120
5121 template <class TYPE>
5122#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5123 Variant15(TYPE&& value,
5124 typename bsl::enable_if<
5125 !bsl::is_same<
5126 SelfType,
5127 typename bsl::remove_const<
5128 typename bsl::remove_reference<TYPE>::type>::type>::value,
5129 bslma::Allocator>::type *basicAllocator);
5130#else
5132 bslma::Allocator *basicAllocator);
5133#endif
5134 // Create a variant object having the specified 'value' of template
5135 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5136 // memory. If 'basicAllocator' is 0, the currently installed default
5137 // allocator is used. The contents of 'value' are moved to the
5138 // newly-created object with 'value' left in a valid but unspecified
5139 // state. 'TYPE' must be the same as one of the types that this
5140 // variant can hold. Note that in C++11 mode, this method does not
5141 // participate in overload resolution if it would lead to ambiguity
5142 // with the move constructor that takes an allocator (below).
5143
5144 /// Create a variant object having the type and value of the specified
5145 /// `original` variant. Optionally specify a `basicAllocator` used to
5146 /// supply memory. If `basicAllocator` is 0, the currently installed
5147 /// default allocator is used.
5148 Variant15(const Variant15& original, bslma::Allocator *basicAllocator = 0);
5149
5150 /// Create a variant object having the type and value of the specified
5151 /// `original` object by moving the contents of `original` to the
5152 /// newly-created object. The allocator associated with `original` (if
5153 /// any) is propagated for use in the newly-created object. `original`
5154 /// is left in a valid but unspecified state.
5156
5157 /// Create a variant object having the type and value of the specified
5158 /// `original` object that uses the specified `basicAllocator` to supply
5159 /// memory. If `basicAllocator` is 0, the currently installed default
5160 /// allocator is used. The contents of `original` are moved to the
5161 /// newly-created object with `original` left in a valid but unspecified
5162 /// state.
5164 bslma::Allocator *basicAllocator);
5165
5166 // MANIPULATORS
5167
5168 /// Assign to this object the specified `value` of template parameter
5169 /// `TYPE`, and return a reference providing modifiable access to this
5170 /// object. The value currently held by this variant (if any) is
5171 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5172 /// must be the same as one of the types that this variant can hold.
5173 template <class TYPE>
5174 Variant15& operator=(const TYPE& value);
5175
5176 template <class TYPE>
5177#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5178 typename bsl::enable_if<
5179 !bsl::is_same<SelfType,
5180 typename bsl::remove_cvref<TYPE>::type>::value,
5181 SelfType>::type&
5182 operator=(TYPE&& value);
5183#else
5184 Variant15&
5186#endif
5187 // Assign to this object the specified 'value' of template parameter
5188 // 'TYPE', and return a reference providing modifiable access to this
5189 // object. The contents of 'value' are moved to this object with
5190 // 'value' left in a valid but unspecified state. The value currently
5191 // held by this variant (if any) is destroyed if that value's type is
5192 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5193 // that this variant can hold. Note that in C++11 mode, this method
5194 // does not participate in overload resolution if it would lead to
5195 // ambiguity with the move-assignment operator (below).
5196
5197 /// Assign to this object the type and value currently held by the
5198 /// specified `rhs` object, and return a reference providing modifiable
5199 /// access to this object. The value currently held by this variant
5200 /// (if any) is destroyed if that value's type is not the same as the
5201 /// type held by the `rhs` object.
5202 Variant15& operator=(const Variant15& rhs);
5203
5204 /// Assign to this object the type and value currently held by the
5205 /// specified `rhs` object, and return a reference providing modifiable
5206 /// access to this object. The value currently held by this variant
5207 /// (if any) is destroyed if that value's type is not the same as the
5208 /// type held by the `rhs` object. The contents of `rhs` are either
5209 /// move-inserted into or move-assigned to this object with `rhs` left
5210 /// in a valid but unspecified state.
5212};
5213
5214 // ====================
5215 // class Variant16<...>
5216 // ====================
5217
5218/// This class is a "specialization" of `Variant` for a fixed number (16) of
5219/// types. Its 16 template arguments *must* all be specified (none are
5220/// defaulted to `bslmf::Nil`). It provides the same functionality as
5221/// `Variant<A1, A2, ..., A16>`.
5222template <class A1, class A2, class A3, class A4, class A5, class A6,
5223 class A7, class A8, class A9, class A10, class A11, class A12,
5224 class A13, class A14, class A15, class A16>
5225class Variant16 : public VariantImp<typename bslmf::TypeList16<
5226 A1, A2, A3, A4, A5,
5227 A6, A7, A8, A9, A10,
5228 A11, A12, A13, A14, A15,
5229 A16>::ListType> {
5230
5231 // PRIVATE TYPES
5232 typedef VariantImp<typename bslmf::TypeList16<A1, A2, A3, A4, A5, A6,
5233 A7, A8, A9, A10, A11, A12,
5234 A13, A14, A15,
5235 A16>::ListType> Imp;
5236
5237 /// `SelfType` is an alias to this class.
5238 typedef Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5239 A10, A11, A12, A13, A14, A15, A16> SelfType;
5240
5243
5244 public:
5245 // TRAITS
5248 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5251 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5254 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5256
5257 // CREATORS
5258
5259 /// Create a variant object in the unset state that uses the currently
5260 /// installed default allocator to supply memory.
5261 Variant16();
5262
5263 /// Create a variant object with the specified `valueOrAllocator` that
5264 /// can be either a value of a type that the variant can hold or an
5265 /// allocator to supply memory. If `valueOrAllocator` is not a
5266 /// `bslma::Allocator *`, then the variant will hold the value and type
5267 /// of `valueOrAllocator`, and use the currently installed default
5268 /// allocator to supply memory. Otherwise, the variant will be unset
5269 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5270 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5271 ///
5272 /// \note Note that this
5273 /// parameterized constructor is defined instead of two constructors
5274 /// (one taking a `bslma::Allocator *` and the other not) because
5275 /// template parameter arguments are always a better match than
5276 /// derived-to-base conversion (a concrete allocator pointer converted
5277 /// to `bslma::Allocator *`).
5278 template <class TYPE_OR_ALLOCATOR>
5279 explicit
5280 Variant16(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5281
5282 /// Create a variant object having the specified `value` of template
5283 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5284 /// supply memory. If `basicAllocator` is 0, the currently installed
5285 /// default allocator is used. `TYPE` must be the same as one of the
5286 /// types that this variant can hold.
5287 template <class TYPE>
5288 Variant16(const TYPE& value, bslma::Allocator *basicAllocator);
5289
5290 template <class TYPE>
5291 explicit
5292#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5293 Variant16(TYPE&& value,
5294 typename bsl::enable_if<
5295 !bsl::is_same<
5296 SelfType,
5297 typename bsl::remove_const<
5298 typename bsl::remove_reference<TYPE>::type>::type>::value
5299 &&
5301 void>::type * = 0);
5302#else
5304#endif
5305 // Create a variant object having the specified 'value' of template
5306 // parameter 'TYPE' by moving the contents of 'value' to the
5307 // newly-created object. Use the currently installed default allocator
5308 // to supply memory. 'value' is left in a valid but unspecified state.
5309 // 'TYPE' must be the same as one of the types that this variant can
5310 // hold. Note that in C++11 mode, this method does not participate in
5311 // overload resolution if it would lead to ambiguity with the move
5312 // constructor that does not take an allocator (below) or with the
5313 // constructor taking a 'valueOrAllocator' (above).
5314
5315 template <class TYPE>
5316#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5317 Variant16(TYPE&& value,
5318 typename bsl::enable_if<
5319 !bsl::is_same<
5320 SelfType,
5321 typename bsl::remove_const<
5322 typename bsl::remove_reference<TYPE>::type>::type>::value,
5323 bslma::Allocator>::type *basicAllocator);
5324#else
5326 bslma::Allocator *basicAllocator);
5327#endif
5328 // Create a variant object having the specified 'value' of template
5329 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5330 // memory. If 'basicAllocator' is 0, the currently installed default
5331 // allocator is used. The contents of 'value' are moved to the
5332 // newly-created object with 'value' left in a valid but unspecified
5333 // state. 'TYPE' must be the same as one of the types that this
5334 // variant can hold. Note that in C++11 mode, this method does not
5335 // participate in overload resolution if it would lead to ambiguity
5336 // with the move constructor that takes an allocator (below).
5337
5338 /// Create a variant object having the type and value of the specified
5339 /// `original` variant. Optionally specify a `basicAllocator` used to
5340 /// supply memory. If `basicAllocator` is 0, the currently installed
5341 /// default allocator is used.
5342 Variant16(const Variant16& original, bslma::Allocator *basicAllocator = 0);
5343
5344 /// Create a variant object having the type and value of the specified
5345 /// `original` object by moving the contents of `original` to the
5346 /// newly-created object. The allocator associated with `original` (if
5347 /// any) is propagated for use in the newly-created object. `original`
5348 /// is left in a valid but unspecified state.
5350
5351 /// Create a variant object having the type and value of the specified
5352 /// `original` object that uses the specified `basicAllocator` to supply
5353 /// memory. If `basicAllocator` is 0, the currently installed default
5354 /// allocator is used. The contents of `original` are moved to the
5355 /// newly-created object with `original` left in a valid but unspecified
5356 /// state.
5358 bslma::Allocator *basicAllocator);
5359
5360 // MANIPULATORS
5361
5362 /// Assign to this object the specified `value` of template parameter
5363 /// `TYPE`, and return a reference providing modifiable access to this
5364 /// object. The value currently held by this variant (if any) is
5365 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5366 /// must be the same as one of the types that this variant can hold.
5367 template <class TYPE>
5368 Variant16& operator=(const TYPE& value);
5369
5370 template <class TYPE>
5371#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5372 typename bsl::enable_if<
5373 !bsl::is_same<SelfType,
5374 typename bsl::remove_cvref<TYPE>::type>::value,
5375 SelfType>::type&
5376 operator=(TYPE&& value);
5377#else
5378 Variant16&
5380#endif
5381 // Assign to this object the specified 'value' of template parameter
5382 // 'TYPE', and return a reference providing modifiable access to this
5383 // object. The contents of 'value' are moved to this object with
5384 // 'value' left in a valid but unspecified state. The value currently
5385 // held by this variant (if any) is destroyed if that value's type is
5386 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5387 // that this variant can hold. Note that in C++11 mode, this method
5388 // does not participate in overload resolution if it would lead to
5389 // ambiguity with the move-assignment operator (below).
5390
5391 /// Assign to this object the type and value currently held by the
5392 /// specified `rhs` object, and return a reference providing modifiable
5393 /// access to this object. The value currently held by this variant
5394 /// (if any) is destroyed if that value's type is not the same as the
5395 /// type held by the `rhs` object.
5396 Variant16& operator=(const Variant16& rhs);
5397
5398 /// Assign to this object the type and value currently held by the
5399 /// specified `rhs` object, and return a reference providing modifiable
5400 /// access to this object. The value currently held by this variant
5401 /// (if any) is destroyed if that value's type is not the same as the
5402 /// type held by the `rhs` object. The contents of `rhs` are either
5403 /// move-inserted into or move-assigned to this object with `rhs` left
5404 /// in a valid but unspecified state.
5406};
5407
5408 // ====================
5409 // class Variant17<...>
5410 // ====================
5411
5412/// This class is a "specialization" of `Variant` for a fixed number (17) of
5413/// types. Its 17 template arguments *must* all be specified (none are
5414/// defaulted to `bslmf::Nil`). It provides the same functionality as
5415/// `Variant<A1, A2, ..., A17>`.
5416template <class A1, class A2, class A3, class A4, class A5, class A6,
5417 class A7, class A8, class A9, class A10, class A11, class A12,
5418 class A13, class A14, class A15, class A16, class A17>
5419class Variant17 : public VariantImp<typename bslmf::TypeList17<
5420 A1, A2, A3, A4, A5,
5421 A6, A7, A8, A9, A10,
5422 A11, A12, A13, A14, A15,
5423 A16, A17>::ListType> {
5424
5425 // PRIVATE TYPES
5426 typedef VariantImp<typename bslmf::TypeList17<A1, A2, A3, A4, A5, A6,
5427 A7, A8, A9, A10, A11, A12,
5428 A13, A14, A15, A16,
5429 A17>::ListType> Imp;
5430
5431 /// `SelfType` is an alias to this class.
5432 typedef Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5433 A10, A11, A12, A13, A14, A15, A16, A17> SelfType;
5434
5437
5438 public:
5439 // TRAITS
5442 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5445 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5448 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5450
5451 // CREATORS
5452
5453 /// Create a variant object in the unset state that uses the currently
5454 /// installed default allocator to supply memory.
5455 Variant17();
5456
5457 /// Create a variant object with the specified `valueOrAllocator` that
5458 /// can be either a value of a type that the variant can hold or an
5459 /// allocator to supply memory. If `valueOrAllocator` is not a
5460 /// `bslma::Allocator *`, then the variant will hold the value and type
5461 /// of `valueOrAllocator`, and use the currently installed default
5462 /// allocator to supply memory. Otherwise, the variant will be unset
5463 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5464 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5465 ///
5466 /// \note Note that this
5467 /// parameterized constructor is defined instead of two constructors
5468 /// (one taking a `bslma::Allocator *` and the other not) because
5469 /// template parameter arguments are always a better match than
5470 /// derived-to-base conversion (a concrete allocator pointer converted
5471 /// to `bslma::Allocator *`).
5472 template <class TYPE_OR_ALLOCATOR>
5473 explicit
5474 Variant17(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5475
5476 /// Create a variant object having the specified `value` of template
5477 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5478 /// supply memory. If `basicAllocator` is 0, the currently installed
5479 /// default allocator is used. `TYPE` must be the same as one of the
5480 /// types that this variant can hold.
5481 template <class TYPE>
5482 Variant17(const TYPE& value, bslma::Allocator *basicAllocator);
5483
5484 template <class TYPE>
5485 explicit
5486#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5487 Variant17(TYPE&& value,
5488 typename bsl::enable_if<
5489 !bsl::is_same<
5490 SelfType,
5491 typename bsl::remove_const<
5492 typename bsl::remove_reference<TYPE>::type>::type>::value
5493 &&
5495 void>::type * = 0);
5496#else
5498#endif
5499 // Create a variant object having the specified 'value' of template
5500 // parameter 'TYPE' by moving the contents of 'value' to the
5501 // newly-created object. Use the currently installed default allocator
5502 // to supply memory. 'value' is left in a valid but unspecified state.
5503 // 'TYPE' must be the same as one of the types that this variant can
5504 // hold. Note that in C++11 mode, this method does not participate in
5505 // overload resolution if it would lead to ambiguity with the move
5506 // constructor that does not take an allocator (below) or with the
5507 // constructor taking a 'valueOrAllocator' (above).
5508
5509 template <class TYPE>
5510#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5511 Variant17(TYPE&& value,
5512 typename bsl::enable_if<
5513 !bsl::is_same<
5514 SelfType,
5515 typename bsl::remove_const<
5516 typename bsl::remove_reference<TYPE>::type>::type>::value,
5517 bslma::Allocator>::type *basicAllocator);
5518#else
5520 bslma::Allocator *basicAllocator);
5521#endif
5522 // Create a variant object having the specified 'value' of template
5523 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5524 // memory. If 'basicAllocator' is 0, the currently installed default
5525 // allocator is used. The contents of 'value' are moved to the
5526 // newly-created object with 'value' left in a valid but unspecified
5527 // state. 'TYPE' must be the same as one of the types that this
5528 // variant can hold. Note that in C++11 mode, this method does not
5529 // participate in overload resolution if it would lead to ambiguity
5530 // with the move constructor that takes an allocator (below).
5531
5532 /// Create a variant object having the type and value of the specified
5533 /// `original` variant. Optionally specify a `basicAllocator` used to
5534 /// supply memory. If `basicAllocator` is 0, the currently installed
5535 /// default allocator is used.
5536 Variant17(const Variant17& original, bslma::Allocator *basicAllocator = 0);
5537
5538 /// Create a variant object having the type and value of the specified
5539 /// `original` object by moving the contents of `original` to the
5540 /// newly-created object. The allocator associated with `original` (if
5541 /// any) is propagated for use in the newly-created object. `original`
5542 /// is left in a valid but unspecified state.
5544
5545 /// Create a variant object having the type and value of the specified
5546 /// `original` object that uses the specified `basicAllocator` to supply
5547 /// memory. If `basicAllocator` is 0, the currently installed default
5548 /// allocator is used. The contents of `original` are moved to the
5549 /// newly-created object with `original` left in a valid but unspecified
5550 /// state.
5552 bslma::Allocator *basicAllocator);
5553
5554 // MANIPULATORS
5555
5556 /// Assign to this object the specified `value` of template parameter
5557 /// `TYPE`, and return a reference providing modifiable access to this
5558 /// object. The value currently held by this variant (if any) is
5559 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5560 /// must be the same as one of the types that this variant can hold.
5561 template <class TYPE>
5562 Variant17& operator=(const TYPE& value);
5563
5564 template <class TYPE>
5565#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5566 typename bsl::enable_if<
5567 !bsl::is_same<SelfType,
5568 typename bsl::remove_cvref<TYPE>::type>::value,
5569 SelfType>::type&
5570 operator=(TYPE&& value);
5571#else
5572 Variant17&
5574#endif
5575 // Assign to this object the specified 'value' of template parameter
5576 // 'TYPE', and return a reference providing modifiable access to this
5577 // object. The contents of 'value' are moved to this object with
5578 // 'value' left in a valid but unspecified state. The value currently
5579 // held by this variant (if any) is destroyed if that value's type is
5580 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5581 // that this variant can hold. Note that in C++11 mode, this method
5582 // does not participate in overload resolution if it would lead to
5583 // ambiguity with the move-assignment operator (below).
5584
5585 /// Assign to this object the type and value currently held by the
5586 /// specified `rhs` object, and return a reference providing modifiable
5587 /// access to this object. The value currently held by this variant
5588 /// (if any) is destroyed if that value's type is not the same as the
5589 /// type held by the `rhs` object.
5590 Variant17& operator=(const Variant17& rhs);
5591
5592 /// Assign to this object the type and value currently held by the
5593 /// specified `rhs` object, and return a reference providing modifiable
5594 /// access to this object. The value currently held by this variant
5595 /// (if any) is destroyed if that value's type is not the same as the
5596 /// type held by the `rhs` object. The contents of `rhs` are either
5597 /// move-inserted into or move-assigned to this object with `rhs` left
5598 /// in a valid but unspecified state.
5600};
5601
5602 // ====================
5603 // class Variant18<...>
5604 // ====================
5605
5606/// This class is a "specialization" of `Variant` for a fixed number (18) of
5607/// types. Its 18 template arguments *must* all be specified (none are
5608/// defaulted to `bslmf::Nil`). It provides the same functionality as
5609/// `Variant<A1, A2, ..., A18>`.
5610template <class A1, class A2, class A3, class A4, class A5, class A6,
5611 class A7, class A8, class A9, class A10, class A11, class A12,
5612 class A13, class A14, class A15, class A16, class A17, class A18>
5613class Variant18 : public VariantImp<typename bslmf::TypeList18<
5614 A1, A2, A3, A4, A5,
5615 A6, A7, A8, A9, A10,
5616 A11, A12, A13, A14, A15,
5617 A16, A17, A18>::ListType> {
5618
5619 // PRIVATE TYPES
5620 typedef VariantImp<typename bslmf::TypeList18<A1, A2, A3, A4, A5, A6,
5621 A7, A8, A9, A10, A11, A12,
5622 A13, A14, A15, A16, A17,
5623 A18>::ListType> Imp;
5624
5625 /// `SelfType` is an alias to this class.
5626 typedef Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5627 A10, A11, A12, A13, A14, A15, A16, A17, A18> SelfType;
5628
5631
5632 public:
5633 // TRAITS
5636 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5639 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5642 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5644
5645 // CREATORS
5646
5647 /// Create a variant object in the unset state that uses the currently
5648 /// installed default allocator to supply memory.
5649 Variant18();
5650
5651 /// Create a variant object with the specified `valueOrAllocator` that
5652 /// can be either a value of a type that the variant can hold or an
5653 /// allocator to supply memory. If `valueOrAllocator` is not a
5654 /// `bslma::Allocator *`, then the variant will hold the value and type
5655 /// of `valueOrAllocator`, and use the currently installed default
5656 /// allocator to supply memory. Otherwise, the variant will be unset
5657 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5658 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5659 ///
5660 /// \note Note that this
5661 /// parameterized constructor is defined instead of two constructors
5662 /// (one taking a `bslma::Allocator *` and the other not) because
5663 /// template parameter arguments are always a better match than
5664 /// derived-to-base conversion (a concrete allocator pointer converted
5665 /// to `bslma::Allocator *`).
5666 template <class TYPE_OR_ALLOCATOR>
5667 explicit
5668 Variant18(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5669
5670 /// Create a variant object having the specified `value` of template
5671 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5672 /// supply memory. If `basicAllocator` is 0, the currently installed
5673 /// default allocator is used. `TYPE` must be the same as one of the
5674 /// types that this variant can hold.
5675 template <class TYPE>
5676 Variant18(const TYPE& value, bslma::Allocator *basicAllocator);
5677
5678 template <class TYPE>
5679 explicit
5680#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5681 Variant18(TYPE&& value,
5682 typename bsl::enable_if<
5683 !bsl::is_same<
5684 SelfType,
5685 typename bsl::remove_const<
5686 typename bsl::remove_reference<TYPE>::type>::type>::value
5687 &&
5689 void>::type * = 0);
5690#else
5692#endif
5693 // Create a variant object having the specified 'value' of template
5694 // parameter 'TYPE' by moving the contents of 'value' to the
5695 // newly-created object. Use the currently installed default allocator
5696 // to supply memory. 'value' is left in a valid but unspecified state.
5697 // 'TYPE' must be the same as one of the types that this variant can
5698 // hold. Note that in C++11 mode, this method does not participate in
5699 // overload resolution if it would lead to ambiguity with the move
5700 // constructor that does not take an allocator (below) or with the
5701 // constructor taking a 'valueOrAllocator' (above).
5702
5703 template <class TYPE>
5704#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5705 Variant18(TYPE&& value,
5706 typename bsl::enable_if<
5707 !bsl::is_same<
5708 SelfType,
5709 typename bsl::remove_const<
5710 typename bsl::remove_reference<TYPE>::type>::type>::value,
5711 bslma::Allocator>::type *basicAllocator);
5712#else
5714 bslma::Allocator *basicAllocator);
5715#endif
5716 // Create a variant object having the specified 'value' of template
5717 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5718 // memory. If 'basicAllocator' is 0, the currently installed default
5719 // allocator is used. The contents of 'value' are moved to the
5720 // newly-created object with 'value' left in a valid but unspecified
5721 // state. 'TYPE' must be the same as one of the types that this
5722 // variant can hold. Note that in C++11 mode, this method does not
5723 // participate in overload resolution if it would lead to ambiguity
5724 // with the move constructor that takes an allocator (below).
5725
5726 /// Create a variant object having the type and value of the specified
5727 /// `original` variant. Optionally specify a `basicAllocator` used to
5728 /// supply memory. If `basicAllocator` is 0, the currently installed
5729 /// default allocator is used.
5730 Variant18(const Variant18& original, bslma::Allocator *basicAllocator = 0);
5731
5732 /// Create a variant object having the type and value of the specified
5733 /// `original` object by moving the contents of `original` to the
5734 /// newly-created object. The allocator associated with `original` (if
5735 /// any) is propagated for use in the newly-created object. `original`
5736 /// is left in a valid but unspecified state.
5738
5739 /// Create a variant object having the type and value of the specified
5740 /// `original` object that uses the specified `basicAllocator` to supply
5741 /// memory. If `basicAllocator` is 0, the currently installed default
5742 /// allocator is used. The contents of `original` are moved to the
5743 /// newly-created object with `original` left in a valid but unspecified
5744 /// state.
5746 bslma::Allocator *basicAllocator);
5747
5748 // MANIPULATORS
5749
5750 /// Assign to this object the specified `value` of template parameter
5751 /// `TYPE`, and return a reference providing modifiable access to this
5752 /// object. The value currently held by this variant (if any) is
5753 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5754 /// must be the same as one of the types that this variant can hold.
5755 template <class TYPE>
5756 Variant18& operator=(const TYPE& value);
5757
5758 template <class TYPE>
5759#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5760 typename bsl::enable_if<
5761 !bsl::is_same<SelfType,
5762 typename bsl::remove_cvref<TYPE>::type>::value,
5763 SelfType>::type&
5764 operator=(TYPE&& value);
5765#else
5766 Variant18&
5768#endif
5769 // Assign to this object the specified 'value' of template parameter
5770 // 'TYPE', and return a reference providing modifiable access to this
5771 // object. The contents of 'value' are moved to this object with
5772 // 'value' left in a valid but unspecified state. The value currently
5773 // held by this variant (if any) is destroyed if that value's type is
5774 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5775 // that this variant can hold. Note that in C++11 mode, this method
5776 // does not participate in overload resolution if it would lead to
5777 // ambiguity with the move-assignment operator (below).
5778
5779 /// Assign to this object the type and value currently held by the
5780 /// specified `rhs` object, and return a reference providing modifiable
5781 /// access to this object. The value currently held by this variant
5782 /// (if any) is destroyed if that value's type is not the same as the
5783 /// type held by the `rhs` object.
5784 Variant18& operator=(const Variant18& rhs);
5785
5786 /// Assign to this object the type and value currently held by the
5787 /// specified `rhs` object, and return a reference providing modifiable
5788 /// access to this object. The value currently held by this variant
5789 /// (if any) is destroyed if that value's type is not the same as the
5790 /// type held by the `rhs` object. The contents of `rhs` are either
5791 /// move-inserted into or move-assigned to this object with `rhs` left
5792 /// in a valid but unspecified state.
5794};
5795
5796 // ====================
5797 // class Variant19<...>
5798 // ====================
5799
5800/// This class is a "specialization" of `Variant` for a fixed number (19) of
5801/// types. Its 19 template arguments *must* all be specified (none are
5802/// defaulted to `bslmf::Nil`). It provides the same functionality as
5803/// `Variant<A1, A2, ..., A19>`.
5804template <class A1, class A2, class A3, class A4, class A5, class A6,
5805 class A7, class A8, class A9, class A10, class A11, class A12,
5806 class A13, class A14, class A15, class A16, class A17, class A18,
5807 class A19>
5808class Variant19 : public VariantImp<typename bslmf::TypeList19<
5809 A1, A2, A3, A4, A5,
5810 A6, A7, A8, A9, A10,
5811 A11, A12, A13, A14, A15,
5812 A16, A17, A18, A19>::ListType> {
5813
5814 // PRIVATE TYPES
5815 typedef VariantImp<typename bslmf::TypeList19<A1, A2, A3, A4, A5, A6,
5816 A7, A8, A9, A10, A11, A12,
5817 A13, A14, A15, A16, A17, A18,
5818 A19>::ListType> Imp;
5819
5820 /// `SelfType` is an alias to this class.
5821 typedef Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5822 A10, A11, A12, A13, A14, A15, A16, A17, A18,
5823 A19> SelfType;
5824
5827
5828 public:
5829 // TRAITS
5832 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5835 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5838 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5840
5841 // CREATORS
5842
5843 /// Create a variant object in the unset state that uses the currently
5844 /// installed default allocator to supply memory.
5845 Variant19();
5846
5847 /// Create a variant object with the specified `valueOrAllocator` that
5848 /// can be either a value of a type that the variant can hold or an
5849 /// allocator to supply memory. If `valueOrAllocator` is not a
5850 /// `bslma::Allocator *`, then the variant will hold the value and type
5851 /// of `valueOrAllocator`, and use the currently installed default
5852 /// allocator to supply memory. Otherwise, the variant will be unset
5853 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5854 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5855 ///
5856 /// \note Note that this
5857 /// parameterized constructor is defined instead of two constructors
5858 /// (one taking a `bslma::Allocator *` and the other not) because
5859 /// template parameter arguments are always a better match than
5860 /// derived-to-base conversion (a concrete allocator pointer converted
5861 /// to `bslma::Allocator *`).
5862 template <class TYPE_OR_ALLOCATOR>
5863 explicit
5864 Variant19(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5865
5866 /// Create a variant object having the specified `value` of template
5867 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5868 /// supply memory. If `basicAllocator` is 0, the currently installed
5869 /// default allocator is used. `TYPE` must be the same as one of the
5870 /// types that this variant can hold.
5871 template <class TYPE>
5872 Variant19(const TYPE& value, bslma::Allocator *basicAllocator);
5873
5874 template <class TYPE>
5875 explicit
5876#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5877 Variant19(TYPE&& value,
5878 typename bsl::enable_if<
5879 !bsl::is_same<
5880 SelfType,
5881 typename bsl::remove_const<
5882 typename bsl::remove_reference<TYPE>::type>::type>::value
5883 &&
5885 void>::type * = 0);
5886#else
5888#endif
5889 // Create a variant object having the specified 'value' of template
5890 // parameter 'TYPE' by moving the contents of 'value' to the
5891 // newly-created object. Use the currently installed default allocator
5892 // to supply memory. 'value' is left in a valid but unspecified state.
5893 // 'TYPE' must be the same as one of the types that this variant can
5894 // hold. Note that in C++11 mode, this method does not participate in
5895 // overload resolution if it would lead to ambiguity with the move
5896 // constructor that does not take an allocator (below) or with the
5897 // constructor taking a 'valueOrAllocator' (above).
5898
5899 template <class TYPE>
5900#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5901 Variant19(TYPE&& value,
5902 typename bsl::enable_if<
5903 !bsl::is_same<
5904 SelfType,
5905 typename bsl::remove_const<
5906 typename bsl::remove_reference<TYPE>::type>::type>::value,
5907 bslma::Allocator>::type *basicAllocator);
5908#else
5910 bslma::Allocator *basicAllocator);
5911#endif
5912 // Create a variant object having the specified 'value' of template
5913 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5914 // memory. If 'basicAllocator' is 0, the currently installed default
5915 // allocator is used. The contents of 'value' are moved to the
5916 // newly-created object with 'value' left in a valid but unspecified
5917 // state. 'TYPE' must be the same as one of the types that this
5918 // variant can hold. Note that in C++11 mode, this method does not
5919 // participate in overload resolution if it would lead to ambiguity
5920 // with the move constructor that takes an allocator (below).
5921
5922 /// Create a variant object having the type and value of the specified
5923 /// `original` variant. Optionally specify a `basicAllocator` used to
5924 /// supply memory. If `basicAllocator` is 0, the currently installed
5925 /// default allocator is used.
5926 Variant19(const Variant19& original, bslma::Allocator *basicAllocator = 0);
5927
5928 /// Create a variant object having the type and value of the specified
5929 /// `original` object by moving the contents of `original` to the
5930 /// newly-created object. The allocator associated with `original` (if
5931 /// any) is propagated for use in the newly-created object. `original`
5932 /// is left in a valid but unspecified state.
5934
5935 /// Create a variant object having the type and value of the specified
5936 /// `original` object that uses the specified `basicAllocator` to supply
5937 /// memory. If `basicAllocator` is 0, the currently installed default
5938 /// allocator is used. The contents of `original` are moved to the
5939 /// newly-created object with `original` left in a valid but unspecified
5940 /// state.
5942 bslma::Allocator *basicAllocator);
5943
5944 // MANIPULATORS
5945
5946 /// Assign to this object the specified `value` of template parameter
5947 /// `TYPE`, and return a reference providing modifiable access to this
5948 /// object. The value currently held by this variant (if any) is
5949 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5950 /// must be the same as one of the types that this variant can hold.
5951 template <class TYPE>
5952 Variant19& operator=(const TYPE& value);
5953
5954 template <class TYPE>
5955#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5956 typename bsl::enable_if<
5957 !bsl::is_same<SelfType,
5958 typename bsl::remove_cvref<TYPE>::type>::value,
5959 SelfType>::type&
5960 operator=(TYPE&& value);
5961#else
5962 Variant19&
5964#endif
5965 // Assign to this object the specified 'value' of template parameter
5966 // 'TYPE', and return a reference providing modifiable access to this
5967 // object. The contents of 'value' are moved to this object with
5968 // 'value' left in a valid but unspecified state. The value currently
5969 // held by this variant (if any) is destroyed if that value's type is
5970 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5971 // that this variant can hold. Note that in C++11 mode, this method
5972 // does not participate in overload resolution if it would lead to
5973 // ambiguity with the move-assignment operator (below).
5974
5975 /// Assign to this object the type and value currently held by the
5976 /// specified `rhs` object, and return a reference providing modifiable
5977 /// access to this object. The value currently held by this variant
5978 /// (if any) is destroyed if that value's type is not the same as the
5979 /// type held by the `rhs` object.
5980 Variant19& operator=(const Variant19& rhs);
5981
5982 /// Assign to this object the type and value currently held by the
5983 /// specified `rhs` object, and return a reference providing modifiable
5984 /// access to this object. The value currently held by this variant
5985 /// (if any) is destroyed if that value's type is not the same as the
5986 /// type held by the `rhs` object. The contents of `rhs` are either
5987 /// move-inserted into or move-assigned to this object with `rhs` left
5988 /// in a valid but unspecified state.
5990};
5991
5992// ---- Anything below this line is implementation specific. Do not use. ----
5993
5994 // =====================================
5995 // struct Variant_TypeIndex<TYPES, TYPE>
5996 // =====================================
5997
5998/// Component-private meta-function. Do not use. This meta-function
5999/// computes the index of the template parameter `TYPE` in the template
6000/// parameter list of `TYPES`.
6001///
6002/// See @ref bdlb_variant
6003template <class TYPES, class TYPE>
6005
6006 enum {
6007 value = bsl::is_same<
6009 TYPE>::value ? 1
6010 : bsl::is_same<
6012 TYPE>::value ? 2
6013 : bsl::is_same<
6015 TYPE>::value ? 3
6016 : bsl::is_same<
6018 TYPE>::value ? 4
6019 : bsl::is_same<
6021 TYPE>::value ? 5
6022 : bsl::is_same<
6024 TYPE>::value ? 6
6025 : bsl::is_same<
6027 TYPE>::value ? 7
6028 : bsl::is_same<
6030 TYPE>::value ? 8
6031 : bsl::is_same<
6033 TYPE>::value ? 9
6034 : bsl::is_same<
6036 TYPE>::value ? 10
6037 : bsl::is_same<
6039 TYPE>::value ? 11
6040 : bsl::is_same<
6042 TYPE>::value ? 12
6043 : bsl::is_same<
6045 TYPE>::value ? 13
6046 : bsl::is_same<
6048 TYPE>::value ? 14
6049 : bsl::is_same<
6051 TYPE>::value ? 15
6052 : bsl::is_same<
6054 TYPE>::value ? 16
6055 : bsl::is_same<
6057 TYPE>::value ? 17
6058 : bsl::is_same<
6060 TYPE>::value ? 18
6061 : bsl::is_same<
6063 TYPE>::value ? 19
6064 : bsl::is_same<
6066 TYPE>::value ? 20
6068 ? 21
6069 : 0
6071
6072 BSLMF_ASSERT(0 != value);
6073
6074#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
6075 // See 'testCase17' in the test driver for code snippets that motivate this
6076 // compile-time assertion (see the "out of bounds" comments). In C++03,
6077 // 'TYPES::LENGTH' yields an incorrect value if 'TYPES' has a trailing
6078 // 'bslmf::Nil' (unless the variant is declared using 'VariantN'). It is
6079 // arguably dubious to allow 'bslmf::Nil' as one of the types that a
6080 // variant may hold, but there is such use in production code that needs to
6081 // be considered if that "feature" is to be suppressed. This would do it:
6082 //..
6083 // BSLMF_ASSERT((!bsl::is_same<TYPE, bslmf::Nil>::value));
6084 //..
6085
6086 // TBD The following breaks compilation of some client code in C++11 mode
6087 // that is most likely misusing 'bslmf::Nil'.
6088 // BSLMF_ASSERT(((int)value <= (int)TYPES::LENGTH || 21 == value));
6089#endif
6090};
6091
6092 // ======================================
6093 // struct Variant_DefaultConstructVisitor
6094 // ======================================
6095
6096/// This visitor, when invoked as a non-modifiable function object on an
6097/// instance of some template parameter `TYPE`, will create a default
6098/// instance of `TYPE`.
6099///
6100/// See @ref bdlb_variant
6102
6103 // PUBLIC DATA
6105
6106 // CREATORS
6107 explicit
6109 : d_allocator_p(allocator)
6110 {
6111 }
6112
6113 // ACCESSORS
6114 template <class TYPE>
6115 void operator()(TYPE& value) const
6116 {
6117 bslma::ConstructionUtil::construct(&value, d_allocator_p);
6118 }
6119};
6120
6121 // ===================================
6122 // struct Variant_CopyConstructVisitor
6123 // ===================================
6124
6125/// This visitor, when invoked as a non-modifiable function object on an
6126/// instance of some template parameter `TYPE`, will copy-insert that
6127/// instance to create an instance of the same `TYPE` in an uninitialized
6128/// buffer specified at construction of this visitor.
6129///
6130/// See @ref bdlb_variant
6132
6133 // PUBLIC DATA
6136
6137 // CREATORS
6139 : d_buffer_p(buffer)
6140 , d_allocator_p(allocator)
6141 {
6142 BSLS_ASSERT_SAFE(d_buffer_p);
6143 }
6144
6145 // ACCESSORS
6146 template <class TYPE>
6147 void operator()(const TYPE& value) const
6148 {
6150 reinterpret_cast<TYPE *>(d_buffer_p),
6151 d_allocator_p,
6152 value);
6153 }
6154};
6155
6156 // ===================================
6157 // struct Variant_MoveConstructVisitor
6158 // ===================================
6159
6160/// This visitor, when invoked as a non-modifiable function object on an
6161/// instance of some template parameter `TYPE`, will move-insert that
6162/// instance to create an instance of the same `TYPE` in an uninitialized
6163/// buffer specified at construction of this visitor.
6164///
6165/// See @ref bdlb_variant
6167
6168 // PUBLIC DATA
6171
6172 // CREATORS
6174 : d_buffer_p(buffer)
6175 , d_allocator_p(allocator)
6176 {
6177 BSLS_ASSERT_SAFE(d_buffer_p);
6178 }
6179
6180 // ACCESSORS
6181 template <class TYPE>
6182 void operator()(TYPE& value) const
6183 {
6185 reinterpret_cast<TYPE *>(d_buffer_p),
6186 d_allocator_p,
6188 }
6189};
6190
6191 // ================================
6192 // struct Variant_DestructorVisitor
6193 // ================================
6194
6195/// This visitor, when invoked as a function object on an instance of some
6196/// template parameter `TYPE`, will destroy that instance.
6197///
6198/// See @ref bdlb_variant
6200
6201 // ACCESSORS
6202 template <class TYPE>
6203 void operator()(TYPE& object) const
6204 {
6205 bslma::DestructionUtil::destroy(&object);
6206 }
6207};
6208
6209 // ================================
6210 // struct Variant_CopyAssignVisitor
6211 // ================================
6212
6213/// This visitor, when invoked as a non-modifiable function object on an
6214/// instance of some template parameter `TYPE`, will copy-assign that
6215/// instance to the instance of the same `TYPE` held in a buffer specified
6216/// at construction of this visitor.
6217///
6218/// See @ref bdlb_variant
6220
6221 // PUBLIC DATA
6223
6224 // CREATORS
6225 explicit
6227 : d_buffer_p(buffer)
6228 {
6229 BSLS_ASSERT_SAFE(d_buffer_p);
6230 }
6231
6232 // ACCESSORS
6233 template <class TYPE>
6234 void operator()(const TYPE& value)
6235 {
6236 *reinterpret_cast<TYPE *>(d_buffer_p) = value;
6237 }
6238};
6239
6240 // ================================
6241 // struct Variant_MoveAssignVisitor
6242 // ================================
6243
6244/// This visitor, when invoked as a non-modifiable function object on an
6245/// instance of some template parameter `TYPE`, will move-assign that
6246/// instance to the instance of the same `TYPE` held in a buffer specified
6247/// at construction of this visitor.
6248///
6249/// See @ref bdlb_variant
6251
6252 // PUBLIC DATA
6254
6255 // CREATORS
6256 explicit
6258 : d_buffer_p(buffer)
6259 {
6260 BSLS_ASSERT_SAFE(d_buffer_p);
6261 }
6262
6263 // ACCESSORS
6264 template <class TYPE>
6265 void operator()(TYPE& value)
6266 {
6267 *reinterpret_cast<TYPE *>(d_buffer_p) =
6269 }
6270};
6271
6272 // ==========================
6273 // struct Variant_SwapVisitor
6274 // ==========================
6275
6276/// This visitor swaps the variant object data that it holds with another
6277/// variant object data of parameterize `TYPE`. It requires that the two
6278/// variant objects being swapped contain data of the same type, and use the
6279/// same allocator.
6280///
6281/// See @ref bdlb_variant
6283
6284 // PUBLIC DATA
6286
6287 // CREATORS
6288 explicit
6290 : d_buffer_p(buffer)
6291 {
6292 BSLS_ASSERT_SAFE(d_buffer_p);
6293 }
6294
6295 // MANIPULATORS
6296 template <class TYPE>
6297 void operator()(TYPE& value)
6298 {
6299 bslalg::SwapUtil::swap(reinterpret_cast<TYPE *>(d_buffer_p), &value);
6300 }
6301};
6302
6303#ifndef BDE_OMIT_INTERNAL_DEPRECATED
6304
6305 // ==================================
6306 // struct Variant_BdexStreamInVisitor
6307 // ==================================
6308
6309/// This visitor, when invoked as a non-modifiable function object on an
6310/// initialized instance of some parameterized `TYPE`, will stream in
6311/// a value of the same `TYPE` into that instance from a stream specified at
6312/// construction of this visitor, using a version also specified at
6313/// construction of this visitor.
6314///
6315/// See @ref bdlb_variant
6316template <class STREAM>
6318
6319 // PUBLIC DATA
6320 STREAM& d_stream; // held, not owned
6321 int d_version; // BDEX version
6322
6323 // CREATORS
6324 Variant_BdexStreamInVisitor(STREAM& stream, int version)
6325 : d_stream(stream)
6326 , d_version(version)
6327 {
6328 }
6329
6330 // ACCESSORS
6331 template <class VALUETYPE>
6332 inline
6333 void operator()(VALUETYPE& object) const
6334 {
6335 bslx::InStreamFunctions::bdexStreamIn(d_stream, object, d_version);
6336 }
6337
6338 inline
6340 {
6341 // no op
6342 }
6343};
6344
6345 // ===================================
6346 // struct Variant_BdexStreamOutVisitor
6347 // ===================================
6348
6349/// This visitor, when invoked as a non-modifiable function object on an
6350/// initialized instance of some parameterized `TYPE`, will stream out the
6351/// value of that instance into a stream specified at construction of this
6352/// visitor, using a version also specified at construction of this
6353/// visitor.
6354///
6355/// See @ref bdlb_variant
6356template <class STREAM>
6358
6359 // PUBLIC DATA
6360 STREAM& d_stream; // held, not owned
6361 int d_version; // BDEX version
6362
6363 // CREATORS
6364 Variant_BdexStreamOutVisitor(STREAM& stream, int version)
6365 : d_stream(stream)
6366 , d_version(version)
6367 {
6368 }
6369
6370 // ACCESSORS
6371 template <class VALUETYPE>
6372 inline
6373 void operator()(const VALUETYPE& object) const
6374 {
6375 bslx::OutStreamFunctions::bdexStreamOut(d_stream, object, d_version);
6376 }
6377
6378 inline
6380 {
6381 // no op
6382 }
6383};
6384#endif
6385
6386 // ===========================
6387 // struct Variant_PrintVisitor
6388 // ===========================
6389
6390/// This visitor, when invoked as a non-modifiable function object on an
6391/// instance of some template parameter `TYPE`, writes the value of that
6392/// instance to a stream specified at construction of this visitor, using
6393/// spacing information also specified at construction.
6394///
6395/// See @ref bdlb_variant
6397
6398 // PUBLIC DATA
6399 bsl::ostream *d_stream_p; // held, not owned
6402
6403 // CREATORS
6404 Variant_PrintVisitor(bsl::ostream *stream,
6405 int level,
6406 int spacesPerLevel)
6407 : d_stream_p(stream)
6408 , d_level(level)
6409 , d_spacesPerLevel(spacesPerLevel)
6410 {
6411 BSLS_ASSERT_SAFE(d_stream_p);
6412 }
6413
6414 // ACCESSORS
6415 template <class TYPE>
6416 void operator()(const TYPE& value) const
6417 {
6418 PrintMethods::print(*d_stream_p, value, d_level, d_spacesPerLevel);
6419 }
6420
6422 {
6423 // no op
6424 }
6425};
6426
6427 // ==================================
6428 // struct Variant_EqualityTestVisitor
6429 // ==================================
6430
6431/// This visitor, when invoked as a non-modifiable function object on an
6432/// instance of some template parameter `TYPE`, tests the equality of the
6433/// value of that instance and of another instance held in a buffer
6434/// specified at construction of this visitor, and stores the result into
6435/// its publicly accessible `d_result` member.
6436///
6437/// See @ref bdlb_variant
6439
6440 // PUBLIC DATA
6441 mutable bool d_result;
6442 const void *d_buffer_p; // held, not owned
6443
6444 // CREATORS
6445 explicit
6447 : d_result(true)
6448 , d_buffer_p(buffer)
6449 {
6450 BSLS_ASSERT_SAFE(d_buffer_p);
6451 }
6452
6453 // ACCESSORS
6454 template <class TYPE>
6455 void operator()(const TYPE& value) const
6456 {
6457 d_result = *reinterpret_cast<const TYPE *>(d_buffer_p) == value;
6458 }
6459
6461 {
6462 d_result = true;
6463 }
6464};
6465
6466// ============================================================================
6467// INLINE DEFINITIONS
6468// ============================================================================
6469
6470 // -------------------------------------
6471 // class VariantImp_AllocatorBase<TYPES>
6472 // -------------------------------------
6473
6474// CREATORS
6475template <class TYPES>
6476inline
6478VariantImp_AllocatorBase(int type, bslma::Allocator *basicAllocator)
6479: d_type(type)
6480, d_allocator_p(bslma::Default::allocator(basicAllocator))
6481{
6482}
6483
6484template <class TYPES>
6485inline
6488: d_type(0)
6489, d_allocator_p(bslma::Default::allocator(basicAllocator))
6490{
6491}
6492
6493template <class TYPES>
6494template <class TYPE>
6495inline
6497VariantImp_AllocatorBase(int type, const TYPE&, bsl::false_type)
6498: d_type(type)
6499, d_allocator_p(bslma::Default::allocator(0))
6500{
6501}
6502
6503// ACCESSORS
6504template <class TYPES>
6505inline
6508{
6509 return d_allocator_p;
6510}
6511
6512 // ---------------------------------------
6513 // class VariantImp_NoAllocatorBase<TYPES>
6514 // ---------------------------------------
6515
6516// CREATORS
6517template <class TYPES>
6518inline
6524
6525template <class TYPES>
6526inline
6532
6533template <class TYPES>
6534template <class TYPE>
6535inline
6537VariantImp_NoAllocatorBase(int type, const TYPE&, bsl::false_type)
6538: d_type(type)
6539{
6540}
6541
6542// ACCESSORS
6543template <class TYPES>
6544inline
6547{
6548 return 0;
6549}
6550
6551 // ------------------------------
6552 // class Variant_RawVisitorHelper
6553 // ------------------------------
6554
6555// CREATORS
6556template <class RESULT_TYPE, class VISITOR>
6557inline
6559Variant_RawVisitorHelper(VISITOR *visitor)
6560: d_visitor(visitor)
6561{
6562 BSLS_ASSERT_SAFE(0 != visitor);
6563}
6564
6565// MANIPULATORS
6566template <class RESULT_TYPE, class VISITOR>
6567template <class ARGUMENT_TYPE>
6568inline
6569RESULT_TYPE
6571 ARGUMENT_TYPE& argument)
6572{
6573 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6574}
6575
6576template <class RESULT_TYPE, class VISITOR>
6577template <class ARGUMENT_TYPE>
6578inline
6579RESULT_TYPE
6581 const ARGUMENT_TYPE& argument)
6582{
6583 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6584}
6585
6586// ACCESSORS
6587template <class RESULT_TYPE, class VISITOR>
6588template <class ARGUMENT_TYPE>
6589inline
6590RESULT_TYPE
6592 ARGUMENT_TYPE& argument) const
6593{
6594 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6595}
6596
6597template <class RESULT_TYPE, class VISITOR>
6598template <class ARGUMENT_TYPE>
6599inline
6600RESULT_TYPE
6602 const ARGUMENT_TYPE& argument) const
6603{
6604 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6605}
6606
6607template <class RESULT_TYPE, class VISITOR>
6608RESULT_TYPE
6613
6614 // -----------------------
6615 // class VariantImp<TYPES>
6616 // -----------------------
6617
6618// PRIVATE MANIPULATORS
6619template <class TYPES>
6620template <class TYPE, class VISITOR_REF>
6621inline
6622void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::false_type)
6623{
6624 typedef bsls::ObjectBuffer<TYPE> BufferType;
6625
6626 visitor(reinterpret_cast<BufferType *>(&this->d_value)->object());
6627}
6628
6629template <class TYPES>
6630template <class TYPE, class VISITOR_REF>
6631inline
6632void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::true_type)
6633{
6634 bslmf::Nil nil = bslmf::Nil();
6635 visitor(nil);
6636}
6637
6638template <class TYPES>
6639template <class TYPE, class VISITOR_REF>
6640inline
6641void VariantImp<TYPES>::applyImp(VISITOR_REF visitor)
6642{
6643 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6644 applyImp<TYPE, VISITOR_REF>(visitor, IsUnset());
6645}
6646
6647template <class TYPES>
6648template <class TYPE, class VISITOR_REF, class RET_TYPE>
6649inline
6650RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor, bsl::false_type)
6651{
6652 typedef bsls::ObjectBuffer<TYPE> BufferType;
6653
6654 return visitor(reinterpret_cast<BufferType *>(&this->d_value)->object());
6655}
6656
6657template <class TYPES>
6658template <class TYPE, class VISITOR_REF, class RET_TYPE>
6659inline
6660RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor, bsl::true_type)
6661{
6662 bslmf::Nil nil = bslmf::Nil();
6663 return visitor(nil);
6664}
6665
6666template <class TYPES>
6667template <class TYPE, class VISITOR_REF, class RET_TYPE>
6668inline
6669RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor)
6670{
6671 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6672 return applyImpR<TYPE, VISITOR_REF, RET_TYPE>(visitor, IsUnset());
6673}
6674
6675template <class TYPES>
6676template <class TYPE, class SOURCE_TYPE>
6677void VariantImp<TYPES>::assignImp(const SOURCE_TYPE& value)
6678{
6679 typedef bsls::ObjectBuffer<TYPE> BufferType;
6680
6681 reset();
6683 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6684 this->getAllocator(),
6685 value);
6687}
6688
6689template <class TYPES>
6690template <class TYPE>
6691#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6692void VariantImp<TYPES>::assignImp(TYPE&& value)
6693#else
6694void VariantImp<TYPES>::assignImp(bslmf::MovableRef<TYPE> value)
6695#endif
6696{
6698 BufferType;
6699
6700 reset();
6701
6702#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6704 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6705 this->getAllocator(),
6706 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
6707#else
6708 TYPE& lvalue = value;
6710 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6711 this->getAllocator(),
6713#endif
6714
6715 this->d_type =
6716 Variant_TypeIndex<TYPES,
6717 typename bsl::remove_reference<TYPE>::type>::value;
6718}
6719
6720template <class TYPES>
6721template <class VISITOR_REF>
6722void VariantImp<TYPES>::doApply(VISITOR_REF visitor, int type)
6723{
6724 switch (type) {
6725 case 0: {
6726 BSLS_ASSERT(0 == "'doApply' invoked on an unset variant");
6727 } break;
6728 case 1: {
6729 applyImp<typename Base::Type1, VISITOR_REF>(visitor);
6730 } break;
6731 case 2: {
6732 applyImp<typename Base::Type2, VISITOR_REF>(visitor);
6733 } break;
6734 case 3: {
6735 applyImp<typename Base::Type3, VISITOR_REF>(visitor);
6736 } break;
6737 case 4: {
6738 applyImp<typename Base::Type4, VISITOR_REF>(visitor);
6739 } break;
6740 case 5: {
6741 applyImp<typename Base::Type5, VISITOR_REF>(visitor);
6742 } break;
6743 case 6: {
6744 applyImp<typename Base::Type6, VISITOR_REF>(visitor);
6745 } break;
6746 case 7: {
6747 applyImp<typename Base::Type7, VISITOR_REF>(visitor);
6748 } break;
6749 case 8: {
6750 applyImp<typename Base::Type8, VISITOR_REF>(visitor);
6751 } break;
6752 case 9: {
6753 applyImp<typename Base::Type9, VISITOR_REF>(visitor);
6754 } break;
6755 case 10: {
6756 applyImp<typename Base::Type10, VISITOR_REF>(visitor);
6757 } break;
6758 case 11: {
6759 applyImp<typename Base::Type11, VISITOR_REF>(visitor);
6760 } break;
6761 case 12: {
6762 applyImp<typename Base::Type12, VISITOR_REF>(visitor);
6763 } break;
6764 case 13: {
6765 applyImp<typename Base::Type13, VISITOR_REF>(visitor);
6766 } break;
6767 case 14: {
6768 applyImp<typename Base::Type14, VISITOR_REF>(visitor);
6769 } break;
6770 case 15: {
6771 applyImp<typename Base::Type15, VISITOR_REF>(visitor);
6772 } break;
6773 case 16: {
6774 applyImp<typename Base::Type16, VISITOR_REF>(visitor);
6775 } break;
6776 case 17: {
6777 applyImp<typename Base::Type17, VISITOR_REF>(visitor);
6778 } break;
6779 case 18: {
6780 applyImp<typename Base::Type18, VISITOR_REF>(visitor);
6781 } break;
6782 case 19: {
6783 applyImp<typename Base::Type19, VISITOR_REF>(visitor);
6784 } break;
6785 case 20: {
6786 applyImp<typename Base::Type20, VISITOR_REF>(visitor);
6787 } break;
6788 default: {
6789 BSLS_ASSERT_UNREACHABLE("Variant type index exceeds maximum");
6790 } break;
6791 }
6792}
6793
6794template <class TYPES>
6795template <class TYPE>
6796inline
6797void VariantImp<TYPES>::create(const TYPE& value, bsl::false_type)
6798{
6799 typedef bsls::ObjectBuffer<TYPE> BufferType;
6800
6802 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6803 this->getAllocator(),
6804 value);
6805}
6806
6807template <class TYPES>
6808inline
6809void VariantImp<TYPES>::create(bslma::Allocator *, bsl::true_type)
6810{
6811}
6812
6813template <class TYPES>
6814template <class VISITOR_REF, class RET_TYPE>
6815RET_TYPE VariantImp<TYPES>::doApplyR(VISITOR_REF visitor, int type)
6816{
6817 switch (type) {
6818 case 0: {
6819 BSLS_ASSERT_INVOKE_NORETURN("'doApplyR' invoked on an unset variant");
6820 } break;
6821 case 1: {
6822 return applyImpR<typename Base::Type1,
6823 VISITOR_REF,
6824 RET_TYPE>(visitor); // RETURN
6825 } break;
6826 case 2: {
6827 return applyImpR<typename Base::Type2,
6828 VISITOR_REF,
6829 RET_TYPE>(visitor); // RETURN
6830 } break;
6831 case 3: {
6832 return applyImpR<typename Base::Type3,
6833 VISITOR_REF,
6834 RET_TYPE>(visitor); // RETURN
6835 } break;
6836 case 4: {
6837 return applyImpR<typename Base::Type4,
6838 VISITOR_REF,
6839 RET_TYPE>(visitor); // RETURN
6840 } break;
6841 case 5: {
6842 return applyImpR<typename Base::Type5,
6843 VISITOR_REF,
6844 RET_TYPE>(visitor); // RETURN
6845 } break;
6846 case 6: {
6847 return applyImpR<typename Base::Type6,
6848 VISITOR_REF,
6849 RET_TYPE>(visitor); // RETURN
6850 } break;
6851 case 7: {
6852 return applyImpR<typename Base::Type7,
6853 VISITOR_REF,
6854 RET_TYPE>(visitor); // RETURN
6855 } break;
6856 case 8: {
6857 return applyImpR<typename Base::Type8,
6858 VISITOR_REF,
6859 RET_TYPE>(visitor); // RETURN
6860 } break;
6861 case 9: {
6862 return applyImpR<typename Base::Type9,
6863 VISITOR_REF,
6864 RET_TYPE>(visitor); // RETURN
6865 } break;
6866 case 10: {
6867 return applyImpR<typename Base::Type10,
6868 VISITOR_REF,
6869 RET_TYPE>(visitor); // RETURN
6870 } break;
6871 case 11: {
6872 return applyImpR<typename Base::Type11,
6873 VISITOR_REF,
6874 RET_TYPE>(visitor); // RETURN
6875 } break;
6876 case 12: {
6877 return applyImpR<typename Base::Type12,
6878 VISITOR_REF,
6879 RET_TYPE>(visitor); // RETURN
6880 } break;
6881 case 13: {
6882 return applyImpR<typename Base::Type13,
6883 VISITOR_REF,
6884 RET_TYPE>(visitor); // RETURN
6885 } break;
6886 case 14: {
6887 return applyImpR<typename Base::Type14,
6888 VISITOR_REF,
6889 RET_TYPE>(visitor); // RETURN
6890 } break;
6891 case 15: {
6892 return applyImpR<typename Base::Type15,
6893 VISITOR_REF,
6894 RET_TYPE>(visitor); // RETURN
6895 } break;
6896 case 16: {
6897 return applyImpR<typename Base::Type16,
6898 VISITOR_REF,
6899 RET_TYPE>(visitor); // RETURN
6900 } break;
6901 case 17: {
6902 return applyImpR<typename Base::Type17,
6903 VISITOR_REF,
6904 RET_TYPE>(visitor); // RETURN
6905 } break;
6906 case 18: {
6907 return applyImpR<typename Base::Type18,
6908 VISITOR_REF,
6909 RET_TYPE>(visitor); // RETURN
6910 } break;
6911 case 19: {
6912 return applyImpR<typename Base::Type19,
6913 VISITOR_REF,
6914 RET_TYPE>(visitor); // RETURN
6915 } break;
6916 case 20: {
6917 return applyImpR<typename Base::Type20,
6918 VISITOR_REF,
6919 RET_TYPE>(visitor); // RETURN
6920 } break;
6921 default: {
6922 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
6923 } break;
6924 }
6925}
6926
6927// PRIVATE ACCESSORS
6928template <class TYPES>
6929template <class TYPE, class VISITOR_REF>
6930inline
6931void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::false_type) const
6932{
6933 typedef bsls::ObjectBuffer<TYPE> BufferType;
6934
6935 visitor(reinterpret_cast<const BufferType *>(&this->d_value)->object());
6936}
6937
6938template <class TYPES>
6939template <class TYPE, class VISITOR_REF>
6940inline
6941void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::true_type) const
6942{
6943 bslmf::Nil nil = bslmf::Nil();
6944 visitor(nil);
6945}
6946
6947template <class TYPES>
6948template <class TYPE, class VISITOR_REF>
6949inline
6950void VariantImp<TYPES>::applyImp(VISITOR_REF visitor) const
6951{
6952 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6953 applyImp<TYPE, VISITOR_REF>(visitor, IsUnset());
6954}
6955
6956template <class TYPES>
6957template <class TYPE, class VISITOR_REF, class RET_TYPE>
6958inline
6959RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor,
6960 bsl::false_type) const
6961{
6962 typedef bsls::ObjectBuffer<TYPE> BufferType;
6963
6964 return visitor(reinterpret_cast<const BufferType *>(
6965 &this->d_value)->object());
6966}
6967
6968template <class TYPES>
6969template <class TYPE, class VISITOR_REF, class RET_TYPE>
6970inline
6971RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor,
6972 bsl::true_type) const
6973{
6974 bslmf::Nil nil = bslmf::Nil();
6975 return visitor(nil);
6976}
6977
6978template <class TYPES>
6979template <class TYPE, class VISITOR_REF, class RET_TYPE>
6980inline
6981RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor) const
6982{
6983 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6984 return applyImpR<TYPE, VISITOR_REF, RET_TYPE>(visitor, IsUnset());
6985}
6986
6987template <class TYPES>
6988template <class VISITOR_REF>
6989void VariantImp<TYPES>::doApply(VISITOR_REF visitor, int type) const
6990{
6991 switch (type) {
6992 case 0: {
6993 BSLS_ASSERT_INVOKE_NORETURN("'doApply' invoked on an unset variant");
6994 } break;
6995 case 1: {
6996 applyImp<typename Base::Type1, VISITOR_REF>(visitor);
6997 } break;
6998 case 2: {
6999 applyImp<typename Base::Type2, VISITOR_REF>(visitor);
7000 } break;
7001 case 3: {
7002 applyImp<typename Base::Type3, VISITOR_REF>(visitor);
7003 } break;
7004 case 4: {
7005 applyImp<typename Base::Type4, VISITOR_REF>(visitor);
7006 } break;
7007 case 5: {
7008 applyImp<typename Base::Type5, VISITOR_REF>(visitor);
7009 } break;
7010 case 6: {
7011 applyImp<typename Base::Type6, VISITOR_REF>(visitor);
7012 } break;
7013 case 7: {
7014 applyImp<typename Base::Type7, VISITOR_REF>(visitor);
7015 } break;
7016 case 8: {
7017 applyImp<typename Base::Type8, VISITOR_REF>(visitor);
7018 } break;
7019 case 9: {
7020 applyImp<typename Base::Type9, VISITOR_REF>(visitor);
7021 } break;
7022 case 10: {
7023 applyImp<typename Base::Type10, VISITOR_REF>(visitor);
7024 } break;
7025 case 11: {
7026 applyImp<typename Base::Type11, VISITOR_REF>(visitor);
7027 } break;
7028 case 12: {
7029 applyImp<typename Base::Type12, VISITOR_REF>(visitor);
7030 } break;
7031 case 13: {
7032 applyImp<typename Base::Type13, VISITOR_REF>(visitor);
7033 } break;
7034 case 14: {
7035 applyImp<typename Base::Type14, VISITOR_REF>(visitor);
7036 } break;
7037 case 15: {
7038 applyImp<typename Base::Type15, VISITOR_REF>(visitor);
7039 } break;
7040 case 16: {
7041 applyImp<typename Base::Type16, VISITOR_REF>(visitor);
7042 } break;
7043 case 17: {
7044 applyImp<typename Base::Type17, VISITOR_REF>(visitor);
7045 } break;
7046 case 18: {
7047 applyImp<typename Base::Type18, VISITOR_REF>(visitor);
7048 } break;
7049 case 19: {
7050 applyImp<typename Base::Type19, VISITOR_REF>(visitor);
7051 } break;
7052 case 20: {
7053 applyImp<typename Base::Type20, VISITOR_REF>(visitor);
7054 } break;
7055 default: {
7056 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
7057 } break;
7058 }
7059}
7060
7061template <class TYPES>
7062template <class VISITOR_REF, class RET_TYPE>
7063RET_TYPE VariantImp<TYPES>::doApplyR(VISITOR_REF visitor, int type) const
7064{
7065 switch (type) {
7066 case 0: {
7067 BSLS_ASSERT_INVOKE_NORETURN("'doApplyR' invoked on an unset variant");
7068 } break;
7069 case 1: {
7070 return applyImpR<typename Base::Type1,
7071 VISITOR_REF,
7072 RET_TYPE>(visitor); // RETURN
7073 } break;
7074 case 2: {
7075 return applyImpR<typename Base::Type2,
7076 VISITOR_REF,
7077 RET_TYPE>(visitor); // RETURN
7078 } break;
7079 case 3: {
7080 return applyImpR<typename Base::Type3,
7081 VISITOR_REF,
7082 RET_TYPE>(visitor); // RETURN
7083 } break;
7084 case 4: {
7085 return applyImpR<typename Base::Type4,
7086 VISITOR_REF,
7087 RET_TYPE>(visitor); // RETURN
7088 } break;
7089 case 5: {
7090 return applyImpR<typename Base::Type5,
7091 VISITOR_REF,
7092 RET_TYPE>(visitor); // RETURN
7093 } break;
7094 case 6: {
7095 return applyImpR<typename Base::Type6,
7096 VISITOR_REF,
7097 RET_TYPE>(visitor); // RETURN
7098 } break;
7099 case 7: {
7100 return applyImpR<typename Base::Type7,
7101 VISITOR_REF,
7102 RET_TYPE>(visitor); // RETURN
7103 } break;
7104 case 8: {
7105 return applyImpR<typename Base::Type8,
7106 VISITOR_REF,
7107 RET_TYPE>(visitor); // RETURN
7108 } break;
7109 case 9: {
7110 return applyImpR<typename Base::Type9,
7111 VISITOR_REF,
7112 RET_TYPE>(visitor); // RETURN
7113 } break;
7114 case 10: {
7115 return applyImpR<typename Base::Type10,
7116 VISITOR_REF,
7117 RET_TYPE>(visitor); // RETURN
7118 } break;
7119 case 11: {
7120 return applyImpR<typename Base::Type11,
7121 VISITOR_REF,
7122 RET_TYPE>(visitor); // RETURN
7123 } break;
7124 case 12: {
7125 return applyImpR<typename Base::Type12,
7126 VISITOR_REF,
7127 RET_TYPE>(visitor); // RETURN
7128 } break;
7129 case 13: {
7130 return applyImpR<typename Base::Type13,
7131 VISITOR_REF,
7132 RET_TYPE>(visitor); // RETURN
7133 } break;
7134 case 14: {
7135 return applyImpR<typename Base::Type14,
7136 VISITOR_REF,
7137 RET_TYPE>(visitor); // RETURN
7138 } break;
7139 case 15: {
7140 return applyImpR<typename Base::Type15,
7141 VISITOR_REF,
7142 RET_TYPE>(visitor); // RETURN
7143 } break;
7144 case 16: {
7145 return applyImpR<typename Base::Type16,
7146 VISITOR_REF,
7147 RET_TYPE>(visitor); // RETURN
7148 } break;
7149 case 17: {
7150 return applyImpR<typename Base::Type17,
7151 VISITOR_REF,
7152 RET_TYPE>(visitor); // RETURN
7153 } break;
7154 case 18: {
7155 return applyImpR<typename Base::Type18,
7156 VISITOR_REF,
7157 RET_TYPE>(visitor); // RETURN
7158 } break;
7159 case 19: {
7160 return applyImpR<typename Base::Type19,
7161 VISITOR_REF,
7162 RET_TYPE>(visitor); // RETURN
7163 } break;
7164 case 20: {
7165 return applyImpR<typename Base::Type20,
7166 VISITOR_REF,
7167 RET_TYPE>(visitor); // RETURN
7168 } break;
7169 default: {
7170 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
7171 } break;
7172 }
7173}
7174
7175// CREATORS
7176template <class TYPES>
7177inline
7179: Base(0, 0)
7180{
7181}
7182
7183template <class TYPES>
7184template <class TYPE_OR_ALLOCATOR>
7185inline
7186VariantImp<TYPES>::VariantImp(const TYPE_OR_ALLOCATOR& valueOrAllocator)
7187: Base(Variant_TypeIndex<TYPES, TYPE_OR_ALLOCATOR>::value,
7188 valueOrAllocator,
7189 bsl::integral_constant<bool, bsl::is_convertible<TYPE_OR_ALLOCATOR,
7190 bslma::Allocator *>::value>())
7191{
7192 enum {
7193 k_IS_ALLOCATOR = bsl::is_convertible<TYPE_OR_ALLOCATOR,
7194 bslma::Allocator *>::value
7195 };
7196
7197 create(valueOrAllocator, bsl::integral_constant<bool, k_IS_ALLOCATOR>());
7198}
7199
7200template <class TYPES>
7201template <class TYPE>
7202inline
7204 bslma::Allocator *basicAllocator)
7205: Base(Variant_TypeIndex<TYPES, TYPE>::value, basicAllocator)
7206{
7207 typedef bsls::ObjectBuffer<TYPE> BufferType;
7208
7210 reinterpret_cast<BufferType *>(&this->d_value)->address(),
7211 this->getAllocator(),
7212 value);
7213}
7214
7215template <class TYPES>
7216template <class TYPE>
7218#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7219VariantImp(TYPE&& value,
7220 typename bsl::enable_if<
7221 !bsl::is_same<
7222 SelfType,
7223 typename bsl::remove_const<
7224 typename bsl::remove_reference<TYPE>::type>::type>::value
7225 &&
7227 void>::type *)
7228#else
7230#endif
7231: Base(Variant_TypeIndex<
7232 TYPES,
7233 typename bsl::remove_const<
7234 typename bsl::remove_reference<TYPE>::type>::type>::value,
7235 0)
7236{
7237 typedef bsls::ObjectBuffer<
7238 typename bsl::remove_const<
7239 typename bsl::remove_reference<TYPE>::type>::type> BufferType;
7240
7241#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7243 reinterpret_cast<BufferType *>(&this->d_value)->address(),
7244 this->getAllocator(),
7245 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
7246#else
7247 TYPE& lvalue = value;
7249 reinterpret_cast<BufferType *>(&this->d_value)->address(),
7250 this->getAllocator(),
7252#endif
7253}
7254
7255template <class TYPES>
7256template <class TYPE>
7258#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7259VariantImp(TYPE&& value,
7260 typename bsl::enable_if<
7261 !bsl::is_same<
7262 SelfType,
7263 typename bsl::remove_const<
7264 typename bsl::remove_reference<TYPE>::type>::type>::value,
7265 bslma::Allocator>::type *basicAllocator)
7266#else
7268 bslma::Allocator *basicAllocator)
7269#endif
7270: Base(Variant_TypeIndex<
7271 TYPES,
7272 typename bsl::remove_const<
7273 typename bsl::remove_reference<TYPE>::type>::type>::value,
7274 basicAllocator)
7275{
7276 typedef bsls::ObjectBuffer<
7277 typename bsl::remove_const<
7278 typename bsl::remove_reference<TYPE>::type>::type> BufferType;
7279
7280#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7282 reinterpret_cast<BufferType *>(&this->d_value)->address(),
7283 this->getAllocator(),
7284 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
7285#else
7286 TYPE& lvalue = value;
7288 reinterpret_cast<BufferType *>(&this->d_value)->address(),
7289 this->getAllocator(),
7291#endif
7292}
7293
7294template <class TYPES>
7296 bslma::Allocator *basicAllocator)
7297: Base(original.d_type, basicAllocator)
7298{
7299 if (this->d_type) {
7300 Variant_CopyConstructVisitor copyConstructor(&this->d_value,
7301 this->getAllocator());
7302 original.apply(copyConstructor);
7303 }
7304}
7305
7306template <class TYPES>
7308: Base(MoveUtil::access(original).d_type,
7309 MoveUtil::access(original).getAllocator())
7310{
7311 if (this->d_type) {
7312 Variant_MoveConstructVisitor moveConstructor(&this->d_value,
7313 this->getAllocator());
7314 VariantImp& lvalue = original;
7315
7316 lvalue.apply(moveConstructor);
7317 }
7318}
7319
7320template <class TYPES>
7322 bslma::Allocator *basicAllocator)
7323: Base(MoveUtil::access(original).d_type, basicAllocator)
7324{
7325 if (this->d_type) {
7326 Variant_MoveConstructVisitor moveConstructor(&this->d_value,
7327 this->getAllocator());
7328 VariantImp& lvalue = original;
7329
7330 lvalue.apply(moveConstructor);
7331 }
7332}
7333
7334template <class TYPES>
7335inline
7337{
7338 reset();
7339}
7340
7341// MANIPULATORS
7342template <class TYPES>
7343template <class TYPE>
7344inline
7347{
7348 return assign(value);
7349}
7350
7351template <class TYPES>
7352template <class TYPE>
7353inline
7354#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7355typename bsl::enable_if<
7357 typename bsl::remove_cvref<TYPE>::type>::value,
7358VariantImp<TYPES> >::type&
7359VariantImp<TYPES>::operator=(TYPE&& value)
7360#else
7363#endif
7364{
7365#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7366 return assign(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
7367#else
7368 TYPE& lvalue = value;
7369 return assign(MoveUtil::move(lvalue));
7370#endif
7371}
7372
7373template <class TYPES>
7376{
7377 if (&rhs != this) {
7378 if (this->d_type == rhs.d_type) {
7379 if (this->d_type) {
7380 Variant_CopyAssignVisitor assigner(&this->d_value);
7381 rhs.apply(assigner);
7382 }
7383 }
7384 else {
7385 reset();
7386 if (rhs.d_type) {
7387 Variant_CopyConstructVisitor copyConstructor(
7388 &this->d_value,
7389 this->getAllocator());
7390 rhs.apply(copyConstructor);
7391 this->d_type = rhs.d_type;
7392 }
7393 }
7394 }
7395
7396 return *this;
7397}
7398
7399template <class TYPES>
7402{
7403 VariantImp& lvalue = rhs;
7404
7405 if (&lvalue != this) {
7406 if (this->d_type == lvalue.d_type) {
7407 if (this->d_type) {
7408 Variant_MoveAssignVisitor assigner(&this->d_value);
7409 lvalue.apply(assigner);
7410 }
7411 }
7412 else {
7413 reset();
7414 if (lvalue.d_type) {
7415 Variant_MoveConstructVisitor moveConstructor(
7416 &this->d_value,
7417 this->getAllocator());
7418 lvalue.apply(moveConstructor);
7419 this->d_type = lvalue.d_type;
7420 }
7421 }
7422 }
7423
7424 return *this;
7425}
7426
7427template <class TYPES>
7428template <class RET_TYPE, class VISITOR>
7429inline
7430RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor)
7431{
7432 if (this->d_type) {
7433 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7434 }
7435
7436 bslmf::Nil nil = bslmf::Nil();
7437 return visitor(nil);
7438}
7439
7440template <class TYPES>
7441template <class RET_TYPE, class VISITOR>
7442inline
7443RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor)
7444{
7445 if (this->d_type) {
7446 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7447 // RETURN
7448 }
7449
7450 bslmf::Nil nil = bslmf::Nil();
7451 return visitor(nil);
7452}
7453
7454template <class TYPES>
7455template <class RET_TYPE, class VISITOR, class TYPE>
7456inline
7457RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor, const TYPE& defaultValue)
7458{
7459 if (this->d_type) {
7460 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7461 }
7462
7463 return visitor(defaultValue);
7464}
7465
7466template <class TYPES>
7467template <class RET_TYPE, class VISITOR, class TYPE>
7468inline
7469RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor,
7470 const TYPE& defaultValue)
7471{
7472 if (this->d_type) {
7473 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7474 // RETURN
7475 }
7476
7477 return visitor(defaultValue);
7478}
7479
7480template <class TYPES>
7481template <class RET_TYPE, class VISITOR>
7482inline
7483RET_TYPE VariantImp<TYPES>::applyRaw(VISITOR& visitor)
7484{
7486
7487 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7488}
7489
7490template <class TYPES>
7491template <class RET_TYPE, class VISITOR>
7492inline
7493RET_TYPE VariantImp<TYPES>::applyRaw(const VISITOR& visitor)
7494{
7496
7497 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7498}
7499
7500template <class TYPES>
7501template <class TYPE>
7503{
7504 typedef bsls::ObjectBuffer<TYPE> BufferType;
7505
7506 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type) {
7507 reinterpret_cast<BufferType *>(&this->d_value)->object() = value;
7508 }
7509 else {
7510 assignImp<TYPE, TYPE>(value);
7511 }
7512
7513 return *this;
7514}
7515
7516template <class TYPES>
7517template <class TYPE>
7518#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7520#else
7522#endif
7523{
7525 BufferType;
7526
7527#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7528 if (Variant_TypeIndex<TYPES,
7529 typename bsl::remove_reference<TYPE>::type>::value
7530 == this->d_type) {
7531 reinterpret_cast<BufferType *>(&this->d_value)->object() =
7532 BSLS_COMPILERFEATURES_FORWARD(TYPE, value);
7533 }
7534 else {
7535 assignImp<TYPE>(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
7536 }
7537#else
7538 TYPE& lvalue = value;
7539
7540 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type) {
7541 reinterpret_cast<BufferType *>(&this->d_value)->object() =
7542 MoveUtil::move(lvalue);
7543 }
7544 else {
7545 assignImp<TYPE>(MoveUtil::move(lvalue));
7546 }
7547#endif
7548
7549 return *this;
7550}
7551
7552template <class TYPES>
7553template <class TYPE, class SOURCE_TYPE>
7555{
7556 typedef bsls::ObjectBuffer<TYPE> BufferType;
7557
7558 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type
7560 reinterpret_cast<BufferType *>(&this->d_value)->object() = value;
7561 }
7562 else {
7563 assignImp<TYPE, SOURCE_TYPE>(value);
7564 }
7565
7566 return *this;
7567}
7568
7569#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=14
7570
7571template <class TYPES>
7572template <class TYPE, class... ARGS>
7573inline
7574TYPE& VariantImp<TYPES>::createInPlace(ARGS&&... arguments)
7575{
7576 typedef bsls::ObjectBuffer<TYPE> BufferType;
7577 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7578
7579 reset();
7581 bufR.address(),
7582 this->getAllocator(),
7583 BSLS_COMPILERFEATURES_FORWARD(ARGS, arguments)...);
7585
7586 return bufR.object();
7587}
7588
7589#endif
7590
7591template <class TYPES>
7593{
7594 if (this->d_type) {
7595 Variant_DestructorVisitor destructor;
7596 apply(destructor);
7597 this->d_type = 0;
7598 }
7599}
7600
7601template <class TYPES>
7603{
7604 if (!this->d_type) {
7605 if (!other.d_type) {
7606 return; // RETURN
7607 }
7608 *this = other;
7609 other.reset();
7610 }
7611 else if (!other.d_type) {
7612 other = *this;
7613 this->reset();
7614 }
7615 else {
7616 if (this->d_type == other.d_type
7617 && this->getAllocator() == other.getAllocator()) {
7618 // Same types and same allocators, so use a visitor that calls
7619 // 'swap'.
7620
7621 Variant_SwapVisitor swapper(&this->d_value);
7622 other.apply(swapper);
7623 }
7624 else {
7625 // Different types and/or allocators, so swap via assignment. Note
7626 // that this doesn't fit the usual pattern for calling 'swap'
7627 // because infinite recursion would result.
7628
7629 bsl::swap(*this, other);
7630 }
7631 }
7632}
7633
7634template <class TYPES>
7635template <class TYPE>
7636inline
7638{
7641
7642 typedef bsls::ObjectBuffer<TYPE> BufferType;
7643
7644 return reinterpret_cast<BufferType *>(&this->d_value)->object();
7645}
7646
7647// ACCESSORS
7648template <class TYPES>
7649template <class RET_TYPE, class VISITOR>
7650inline
7651RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor) const
7652{
7653 if (this->d_type) {
7654 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7655 }
7656
7657 bslmf::Nil nil = bslmf::Nil();
7658 return visitor(nil);
7659}
7660
7661template <class TYPES>
7662template <class RET_TYPE, class VISITOR>
7663inline
7664RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor) const
7665{
7666 if (this->d_type) {
7667 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7668 // RETURN
7669 }
7670
7671 bslmf::Nil nil = bslmf::Nil();
7672 return visitor(nil);
7673}
7674
7675template <class TYPES>
7676template <class RET_TYPE, class VISITOR, class TYPE>
7677inline
7678RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor,
7679 const TYPE& defaultValue) const
7680{
7681 if (this->d_type) {
7682 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7683 }
7684
7685 return visitor(defaultValue);
7686}
7687
7688template <class TYPES>
7689template <class RET_TYPE, class VISITOR, class TYPE>
7690inline
7691RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor,
7692 const TYPE& defaultValue) const
7693{
7694 if (this->d_type) {
7695 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7696 // RETURN
7697 }
7698
7699 return visitor(defaultValue);
7700}
7701
7702template <class TYPES>
7703template <class RET_TYPE, class VISITOR>
7704inline
7705RET_TYPE VariantImp<TYPES>::applyRaw(VISITOR& visitor) const
7706{
7708
7709 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7710}
7711
7712template <class TYPES>
7713template <class RET_TYPE, class VISITOR>
7714inline
7715RET_TYPE VariantImp<TYPES>::applyRaw(const VISITOR& visitor) const
7716{
7718
7719 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7720}
7721
7722template <class TYPES>
7723template <class TYPE>
7724inline
7726{
7727 return Variant_TypeIndex<TYPES, TYPE>::value == this->d_type;
7728}
7729
7730template <class TYPES>
7731inline
7733{
7734 return !this->d_type;
7735}
7736
7737template <class TYPES>
7738bsl::ostream&
7739VariantImp<TYPES>::print(bsl::ostream& stream,
7740 int level,
7741 int spacesPerLevel) const
7742{
7743 if (this->d_type) {
7744 Variant_PrintVisitor visitor(&stream, level, spacesPerLevel);
7745
7746 doApply<const Variant_PrintVisitor&>(visitor, this->d_type);
7747 }
7748 return stream;
7749}
7750
7751template <class TYPES>
7752template <class TYPE>
7753inline
7754const TYPE& VariantImp<TYPES>::the() const
7755{
7758
7759 typedef bsls::ObjectBuffer<TYPE> BufferType;
7760
7761 return reinterpret_cast<const BufferType *>(&this->d_value)->object();
7762}
7763
7764template <class TYPES>
7765inline
7767{
7768 return this->d_type;
7769}
7770
7771#ifndef BDE_OMIT_INTERNAL_DEPRECATED
7772template <class TYPES>
7773inline
7774const bsl::type_info& VariantImp<TYPES>::typeInfo() const
7775{
7776 return typeid(void);
7777}
7778
7779template <class TYPES>
7780template <class STREAM>
7781STREAM& VariantImp<TYPES>::bdexStreamIn(STREAM& stream, int version)
7782{
7783 int type;
7785
7786 if (!stream || type < 0 || 20 < type) {
7787 stream.invalidate();
7788 return stream;
7789 }
7790
7791 if (type != this->d_type) {
7792 reset();
7793
7794 if (type) {
7795 Variant_DefaultConstructVisitor defaultConstructor(
7796 this->getAllocator());
7797 doApply(defaultConstructor, type);
7798 }
7799
7800 this->d_type = type;
7801 }
7802
7803 if (type) {
7804 Variant_BdexStreamInVisitor<STREAM> streamer(stream, version);
7805 doApply(streamer, type);
7806 }
7807 return stream;
7808}
7809
7810template <class TYPES>
7811inline
7813{
7814 return 1;
7815}
7816
7817template <class TYPES>
7818template <class STREAM>
7819STREAM& VariantImp<TYPES>::bdexStreamOut(STREAM& stream, int version) const
7820{
7821 bslx::OutStreamFunctions::bdexStreamOut(stream, this->d_type, 0);
7822
7823 if (this->d_type) {
7824 typedef Variant_BdexStreamOutVisitor<STREAM> Streamer;
7825
7826 Streamer streamer(stream, version);
7827 doApply<Streamer&>(streamer, this->d_type);
7828 }
7829 return stream;
7830}
7831
7832#endif // BDE_OMIT_INTERNAL_DEPRECATED
7833
7834} // close package namespace
7835
7836// FREE OPERATORS
7837template <class TYPES>
7838bool bdlb::operator==(const VariantImp<TYPES>& lhs,
7839 const VariantImp<TYPES>& rhs)
7840{
7841 if (lhs.typeIndex() != rhs.typeIndex()) {
7842 return false; // RETURN
7843 }
7844
7845 if (0 == lhs.typeIndex()) {
7846 return true; // RETURN
7847 }
7848
7849 Variant_EqualityTestVisitor visitor(&rhs.d_value);
7850 lhs.apply(visitor);
7851
7852 return visitor.d_result;
7853}
7854
7855template <class TYPES>
7856inline
7857bool bdlb::operator!=(const VariantImp<TYPES>& lhs,
7858 const VariantImp<TYPES>& rhs)
7859{
7860 return !(lhs == rhs);
7861}
7862
7863template <class TYPES>
7864inline
7865bsl::ostream& bdlb::operator<<(bsl::ostream& stream,
7866 const VariantImp<TYPES>& object)
7867{
7868 return object.print(stream, 0, -1);
7869}
7870
7871// FREE FUNCTIONS
7872template <class TYPES>
7873inline
7874void bdlb::swap(VariantImp<TYPES>& a, VariantImp<TYPES>& b)
7875{
7876 a.swap(b);
7877}
7878
7879namespace bdlb {
7880
7881 // ------------------
7882 // class Variant<...>
7883 // ------------------
7884
7885// CREATORS
7886#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
7887template <class ...TYPES>
7888inline
7890{
7891}
7892
7893template <class ...TYPES>
7894template <class TYPE_OR_ALLOCATOR>
7895inline
7896Variant<TYPES...>::Variant(const TYPE_OR_ALLOCATOR& valueOrAllocator)
7897: Imp(valueOrAllocator)
7898{
7899}
7900
7901template <class ...TYPES>
7902template <class TYPE>
7903inline
7904Variant<TYPES...>::Variant(const TYPE& value, bslma::Allocator *basicAllocator)
7905: Imp(value, basicAllocator)
7906{
7907}
7908
7909template <class ...TYPES>
7910template <class TYPE>
7911inline
7912Variant<TYPES...>::
7913#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7914Variant(TYPE&& value,
7915 typename bsl::enable_if<
7916 !bsl::is_same<
7917 SelfType,
7918 typename bsl::remove_const<
7919 typename bsl::remove_reference<TYPE>::type>::type>::value
7920 &&
7922 void>::type *)
7923: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
7924#else
7925Variant(bslmf::MovableRef<TYPE> value)
7926: Imp(MoveUtil::move(value))
7927#endif
7928{
7929}
7930
7931template <class ...TYPES>
7932template <class TYPE>
7933inline
7934Variant<TYPES...>::
7935#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7936Variant(TYPE&& value,
7937 typename bsl::enable_if<
7938 !bsl::is_same<
7939 SelfType,
7940 typename bsl::remove_const<
7941 typename bsl::remove_reference<TYPE>::type>::type>::value,
7942 bslma::Allocator>::type *basicAllocator)
7943: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
7944#else
7945Variant(bslmf::MovableRef<TYPE> value,
7946 bslma::Allocator *basicAllocator)
7947: Imp(MoveUtil::move(value), basicAllocator)
7948#endif
7949{
7950}
7951
7952/// Up-cast needed since template matching has higher overloading precedence
7953/// than derived-to-base matching.
7954template <class ...TYPES>
7955inline
7956Variant<TYPES...>::Variant(const Variant& original,
7957 bslma::Allocator *basicAllocator)
7958: Imp(static_cast<const Imp&>(original), basicAllocator)
7959{
7960}
7961
7962template <class ...TYPES>
7963inline
7965: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
7966{
7967}
7968
7969template <class ...TYPES>
7970inline
7972 bslma::Allocator *basicAllocator)
7973: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
7974 basicAllocator)
7975{
7976}
7977
7978// MANIPULATORS
7979template <class ...TYPES>
7980template <class TYPE>
7981inline
7982Variant<TYPES...>& Variant<TYPES...>::operator=(const TYPE& value)
7983{
7984 Imp::operator=(value);
7985 return *this;
7986}
7987
7988template <class ...TYPES>
7989template <class TYPE>
7990inline
7991#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7992typename bsl::enable_if<
7993 !bsl::is_same<Variant<TYPES...>,
7994 typename bsl::remove_cvref<TYPE>::type>::value,
7995Variant<TYPES...> >::type&
7996Variant<TYPES...>::operator=(TYPE&& value)
7997#else
7998Variant<TYPES...>&
8000#endif
8001{
8002#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8003 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8004#else
8005 TYPE& lvalue = value;
8006 Imp::operator=(MoveUtil::move(lvalue));
8007#endif
8008
8009 return *this;
8010}
8011
8012template <class ...TYPES>
8013inline
8014Variant<TYPES...>& Variant<TYPES...>::operator=(const Variant& rhs)
8015{
8016 // Up-cast needed since template matching has higher overloading precedence
8017 // than derived-to-base matching.
8018
8019 Imp::operator=(static_cast<const Imp&>(rhs));
8020 return *this;
8021}
8022
8023template <class ...TYPES>
8024inline
8026{
8027 // Up-cast needed since template matching has higher overloading precedence
8028 // than derived-to-base matching.
8029
8030 Variant& lvalue = rhs;
8031
8032 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8033 return *this;
8034}
8035
8036#else // BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8037template <class A1, class A2, class A3, class A4, class A5, class A6,
8038 class A7, class A8, class A9, class A10, class A11, class A12,
8039 class A13, class A14, class A15, class A16, class A17, class A18,
8040 class A19, class A20>
8041inline
8042Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8043 A13, A14, A15, A16, A17, A18, A19, A20>::Variant()
8044{
8045}
8046
8047template <class A1, class A2, class A3, class A4, class A5, class A6,
8048 class A7, class A8, class A9, class A10, class A11, class A12,
8049 class A13, class A14, class A15, class A16, class A17, class A18,
8050 class A19, class A20>
8051template <class TYPE_OR_ALLOCATOR>
8052inline
8053Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8054 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8055 const TYPE_OR_ALLOCATOR& valueOrAllocator)
8056: Imp(valueOrAllocator)
8057{
8058}
8059
8060template <class A1, class A2, class A3, class A4, class A5, class A6,
8061 class A7, class A8, class A9, class A10, class A11, class A12,
8062 class A13, class A14, class A15, class A16, class A17, class A18,
8063 class A19, class A20>
8064template <class TYPE>
8065inline
8066Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8067 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8068 const TYPE& value,
8069 bslma::Allocator *basicAllocator)
8070: Imp(value, basicAllocator)
8071{
8072}
8073
8074template <class A1, class A2, class A3, class A4, class A5, class A6,
8075 class A7, class A8, class A9, class A10, class A11, class A12,
8076 class A13, class A14, class A15, class A16, class A17, class A18,
8077 class A19, class A20>
8078template <class TYPE>
8079inline
8080Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8081 A13, A14, A15, A16, A17, A18, A19, A20>::
8082#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8083Variant(TYPE&& value,
8084 typename bsl::enable_if<
8085 !bsl::is_same<
8086 SelfType,
8087 typename bsl::remove_const<
8088 typename bsl::remove_reference<TYPE>::type>::type>::value
8089 &&
8091 void>::type *)
8092: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8093#else
8094Variant(bslmf::MovableRef<TYPE> value)
8095: Imp(MoveUtil::move(value))
8096#endif
8097{
8098}
8099
8100template <class A1, class A2, class A3, class A4, class A5, class A6,
8101 class A7, class A8, class A9, class A10, class A11, class A12,
8102 class A13, class A14, class A15, class A16, class A17, class A18,
8103 class A19, class A20>
8104template <class TYPE>
8105inline
8106Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8107 A13, A14, A15, A16, A17, A18, A19, A20>::
8108#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8109Variant(TYPE&& value,
8110 typename bsl::enable_if<
8111 !bsl::is_same<
8112 SelfType,
8113 typename bsl::remove_const<
8114 typename bsl::remove_reference<TYPE>::type>::type>::value,
8115 bslma::Allocator>::type *basicAllocator)
8116: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8117#else
8118Variant(bslmf::MovableRef<TYPE> value,
8119 bslma::Allocator *basicAllocator)
8120: Imp(MoveUtil::move(value), basicAllocator)
8121#endif
8122{
8123}
8124
8125template <class A1, class A2, class A3, class A4, class A5, class A6,
8126 class A7, class A8, class A9, class A10, class A11, class A12,
8127 class A13, class A14, class A15, class A16, class A17, class A18,
8128 class A19, class A20>
8129inline
8130Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8131 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8132 const Variant& original,
8133 bslma::Allocator *basicAllocator)
8134: Imp(static_cast<const Imp&>(original), basicAllocator)
8135 // Up-cast needed since template matching has higher overloading precedence
8136 // than derived-to-base matching.
8137{
8138}
8139
8140template <class A1, class A2, class A3, class A4, class A5, class A6,
8141 class A7, class A8, class A9, class A10, class A11, class A12,
8142 class A13, class A14, class A15, class A16, class A17, class A18,
8143 class A19, class A20>
8144inline
8145Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8146 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8148: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8149{
8150}
8151
8152template <class A1, class A2, class A3, class A4, class A5, class A6,
8153 class A7, class A8, class A9, class A10, class A11, class A12,
8154 class A13, class A14, class A15, class A16, class A17, class A18,
8155 class A19, class A20>
8156inline
8157Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8158 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8160 bslma::Allocator *basicAllocator)
8161: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8162 basicAllocator)
8163{
8164}
8165
8166// MANIPULATORS
8167template <class A1, class A2, class A3, class A4, class A5, class A6,
8168 class A7, class A8, class A9, class A10, class A11, class A12,
8169 class A13, class A14, class A15, class A16, class A17, class A18,
8170 class A19, class A20>
8171template <class TYPE>
8172inline
8173Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8174 A13, A14, A15, A16, A17, A18, A19, A20>&
8175Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8176 A13, A14, A15, A16, A17, A18, A19, A20>::operator=(const TYPE& value)
8177{
8178 Imp::operator=(value);
8179 return *this;
8180}
8181
8182template <class A1, class A2, class A3, class A4, class A5, class A6,
8183 class A7, class A8, class A9, class A10, class A11, class A12,
8184 class A13, class A14, class A15, class A16, class A17, class A18,
8185 class A19, class A20>
8186template <class TYPE>
8187inline
8188#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8189typename bsl::enable_if<
8190 !bsl::is_same<Variant<A1, A2, A3, A4, A5, A6, A7,
8191 A8, A9, A10, A11, A12, A13, A14,
8192 A15, A16, A17, A18, A19, A20>,
8193 typename bsl::remove_cvref<TYPE>::type>::value,
8194Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8195 A16, A17, A18, A19, A20> >::type&
8196Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8197 A16, A17, A18, A19, A20>::operator=(TYPE&& value)
8198#else
8199Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8200 A16, A17, A18, A19, A20>&
8201Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8202 A16, A17, A18, A19, A20>::operator=(bslmf::MovableRef<TYPE> value)
8203#endif
8204{
8205#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8206 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8207#else
8208 TYPE& lvalue = value;
8209 Imp::operator=(MoveUtil::move(lvalue));
8210#endif
8211
8212 return *this;
8213}
8214
8215template <class A1, class A2, class A3, class A4, class A5, class A6,
8216 class A7, class A8, class A9, class A10, class A11, class A12,
8217 class A13, class A14, class A15, class A16, class A17, class A18,
8218 class A19, class A20>
8219inline
8220Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8221 A13, A14, A15, A16, A17, A18, A19, A20>&
8222Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8223 A13, A14, A15, A16, A17, A18, A19, A20>::operator=(const Variant& rhs)
8224{
8225 // Up-cast needed since template matching has higher overloading precedence
8226 // than derived-to-base matching.
8227
8228 Imp::operator=(static_cast<const Imp&>(rhs));
8229 return *this;
8230}
8231
8232template <class A1, class A2, class A3, class A4, class A5, class A6,
8233 class A7, class A8, class A9, class A10, class A11, class A12,
8234 class A13, class A14, class A15, class A16, class A17, class A18,
8235 class A19, class A20>
8236inline
8237Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8238 A13, A14, A15, A16, A17, A18, A19, A20>&
8239Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8240 A13, A14, A15, A16, A17, A18, A19, A20>::
8241operator=(bslmf::MovableRef<Variant> rhs)
8242{
8243 // Up-cast needed since template matching has higher overloading precedence
8244 // than derived-to-base matching.
8245
8246 Variant& lvalue = rhs;
8247
8248 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8249 return *this;
8250}
8251
8252#endif // BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8253
8254#ifdef BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8255#undef BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8256#endif
8257
8258 // -------------------
8259 // class Variant2<...>
8260 // -------------------
8261
8262// CREATORS
8263template <class A1, class A2>
8264inline
8268
8269template <class A1, class A2>
8270template <class TYPE_OR_ALLOCATOR>
8271inline
8272Variant2<A1, A2>::Variant2(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8273: Imp(valueOrAllocator)
8274{
8275}
8276
8277template <class A1, class A2>
8278template <class TYPE>
8279inline
8281 bslma::Allocator *basicAllocator)
8282: Imp(value, basicAllocator)
8283{
8284}
8285
8286template <class A1, class A2>
8287template <class TYPE>
8288inline
8290#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8291Variant2(TYPE&& value,
8292 typename bsl::enable_if<
8293 !bsl::is_same<
8294 SelfType,
8295 typename bsl::remove_const<
8296 typename bsl::remove_reference<TYPE>::type>::type>::value
8297 &&
8299 void>::type *)
8300: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8301#else
8302Variant2(bslmf::MovableRef<TYPE> value)
8303: Imp(MoveUtil::move(value))
8304#endif
8305{
8306}
8307
8308template <class A1, class A2>
8309template <class TYPE>
8310inline
8312#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8313Variant2(TYPE&& value,
8314 typename bsl::enable_if<
8315 !bsl::is_same<
8316 SelfType,
8317 typename bsl::remove_const<
8318 typename bsl::remove_reference<TYPE>::type>::type>::value,
8319 bslma::Allocator>::type *basicAllocator)
8320: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8321#else
8322Variant2(bslmf::MovableRef<TYPE> value,
8323 bslma::Allocator *basicAllocator)
8324: Imp(MoveUtil::move(value), basicAllocator)
8325#endif
8326{
8327}
8328
8329template <class A1, class A2>
8330inline
8332 bslma::Allocator *basicAllocator)
8333: Imp(static_cast<const Imp&>(original), basicAllocator)
8334{
8335}
8336
8337template <class A1, class A2>
8338inline
8340: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8341{
8342}
8343
8344template <class A1, class A2>
8345inline
8347 bslma::Allocator *basicAllocator)
8348: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8349 basicAllocator)
8350{
8351}
8352
8353// MANIPULATORS
8354template <class A1, class A2>
8355template <class TYPE>
8356inline
8359{
8360 Imp::operator=(value);
8361 return *this;
8362}
8363
8364template <class A1, class A2>
8365template <class TYPE>
8366inline
8367#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8368typename bsl::enable_if<
8370 typename bsl::remove_cvref<TYPE>::type>::value,
8371Variant2<A1, A2> >::type&
8372Variant2<A1, A2>::operator=(TYPE&& value)
8373#else
8376#endif
8377{
8378#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8379 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8380#else
8381 TYPE& lvalue = value;
8382 Imp::operator=(MoveUtil::move(lvalue));
8383#endif
8384
8385 return *this;
8386}
8387
8388template <class A1, class A2>
8389inline
8392{
8393 Imp::operator=(static_cast<const Imp&>(rhs));
8394 return *this;
8395}
8396
8397template <class A1, class A2>
8398inline
8401{
8402 Variant2& lvalue = rhs;
8403
8404 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8405 return *this;
8406}
8407
8408 // -------------------
8409 // class Variant3<...>
8410 // -------------------
8411
8412// CREATORS
8413template <class A1, class A2, class A3>
8414inline
8418
8419template <class A1, class A2, class A3>
8420template <class TYPE_OR_ALLOCATOR>
8421inline
8423Variant3(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8424: Imp(valueOrAllocator)
8425{
8426}
8427
8428template <class A1, class A2, class A3>
8429template <class TYPE>
8430inline
8432Variant3(const TYPE& value, bslma::Allocator *basicAllocator)
8433: Imp(value, basicAllocator)
8434{
8435}
8436
8437template <class A1, class A2, class A3>
8438template <class TYPE>
8439inline
8441#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8442Variant3(TYPE&& value,
8443 typename bsl::enable_if<
8444 !bsl::is_same<
8445 SelfType,
8446 typename bsl::remove_const<
8447 typename bsl::remove_reference<TYPE>::type>::type>::value
8448 &&
8450 void>::type *)
8451: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8452#else
8453Variant3(bslmf::MovableRef<TYPE> value)
8454: Imp(MoveUtil::move(value))
8455#endif
8456{
8457}
8458
8459template <class A1, class A2, class A3>
8460template <class TYPE>
8461inline
8463#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8464Variant3(TYPE&& value,
8465 typename bsl::enable_if<
8466 !bsl::is_same<
8467 SelfType,
8468 typename bsl::remove_const<
8469 typename bsl::remove_reference<TYPE>::type>::type>::value,
8470 bslma::Allocator>::type *basicAllocator)
8471: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8472#else
8473Variant3(bslmf::MovableRef<TYPE> value,
8474 bslma::Allocator *basicAllocator)
8475: Imp(MoveUtil::move(value), basicAllocator)
8476#endif
8477{
8478}
8479
8480template <class A1, class A2, class A3>
8481inline
8483Variant3(const Variant3& original, bslma::Allocator *basicAllocator)
8484: Imp(static_cast<const Imp&>(original), basicAllocator)
8485{
8486}
8487
8488template <class A1, class A2, class A3>
8489inline
8492: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8493{
8494}
8495
8496template <class A1, class A2, class A3>
8497inline
8500 bslma::Allocator *basicAllocator)
8501: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8502 basicAllocator)
8503{
8504}
8505
8506// MANIPULATORS
8507template <class A1, class A2, class A3>
8508template <class TYPE>
8509inline
8512{
8513 Imp::operator=(value);
8514 return *this;
8515}
8516
8517template <class A1, class A2, class A3>
8518template <class TYPE>
8519inline
8520#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8521typename bsl::enable_if<
8523 typename bsl::remove_cvref<TYPE>::type>::value,
8524Variant3<A1, A2, A3> >::type&
8526#else
8529#endif
8530{
8531#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8532 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8533#else
8534 TYPE& lvalue = value;
8535 Imp::operator=(MoveUtil::move(lvalue));
8536#endif
8537
8538 return *this;
8539}
8540
8541template <class A1, class A2, class A3>
8542inline
8545{
8546 Imp::operator=(static_cast<const Imp&>(rhs));
8547 return *this;
8548}
8549
8550template <class A1, class A2, class A3>
8551inline
8554{
8555 Variant3& lvalue = rhs;
8556
8557 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8558 return *this;
8559}
8560
8561 // -------------------
8562 // class Variant4<...>
8563 // -------------------
8564
8565// CREATORS
8566template <class A1, class A2, class A3, class A4>
8567inline
8571
8572template <class A1, class A2, class A3, class A4>
8573template <class TYPE_OR_ALLOCATOR>
8574inline
8576Variant4(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8577: Imp(valueOrAllocator)
8578{
8579}
8580
8581template <class A1, class A2, class A3, class A4>
8582template <class TYPE>
8583inline
8585Variant4(const TYPE& value, bslma::Allocator *basicAllocator)
8586: Imp(value, basicAllocator)
8587{
8588}
8589
8590template <class A1, class A2, class A3, class A4>
8591template <class TYPE>
8592inline
8594#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8595Variant4(TYPE&& value,
8596 typename bsl::enable_if<
8597 !bsl::is_same<
8598 SelfType,
8599 typename bsl::remove_const<
8600 typename bsl::remove_reference<TYPE>::type>::type>::value
8601 &&
8603 void>::type *)
8604: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8605#else
8606Variant4(bslmf::MovableRef<TYPE> value)
8607: Imp(MoveUtil::move(value))
8608#endif
8609{
8610}
8611
8612template <class A1, class A2, class A3, class A4>
8613template <class TYPE>
8614inline
8616#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8617Variant4(TYPE&& value,
8618 typename bsl::enable_if<
8619 !bsl::is_same<
8620 SelfType,
8621 typename bsl::remove_const<
8622 typename bsl::remove_reference<TYPE>::type>::type>::value,
8623 bslma::Allocator>::type *basicAllocator)
8624: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8625#else
8626Variant4(bslmf::MovableRef<TYPE> value,
8627 bslma::Allocator *basicAllocator)
8628: Imp(MoveUtil::move(value), basicAllocator)
8629#endif
8630{
8631}
8632
8633template <class A1, class A2, class A3, class A4>
8634inline
8636Variant4(const Variant4& original, bslma::Allocator *basicAllocator)
8637: Imp(static_cast<const Imp&>(original), basicAllocator)
8638{
8639}
8640
8641template <class A1, class A2, class A3, class A4>
8642inline
8645: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8646{
8647}
8648
8649template <class A1, class A2, class A3, class A4>
8650inline
8653 bslma::Allocator *basicAllocator)
8654: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8655 basicAllocator)
8656{
8657}
8658
8659// MANIPULATORS
8660template <class A1, class A2, class A3, class A4>
8661template <class TYPE>
8662inline
8665{
8666 Imp::operator=(value);
8667 return *this;
8668}
8669
8670template <class A1, class A2, class A3, class A4>
8671template <class TYPE>
8672inline
8673#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8674typename bsl::enable_if<
8676 typename bsl::remove_cvref<TYPE>::type>::value,
8679#else
8682#endif
8683{
8684#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8685 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8686#else
8687 TYPE& lvalue = value;
8688 Imp::operator=(MoveUtil::move(lvalue));
8689#endif
8690
8691 return *this;
8692}
8693
8694template <class A1, class A2, class A3, class A4>
8695inline
8698{
8699 Imp::operator=(static_cast<const Imp&>(rhs));
8700 return *this;
8701}
8702
8703template <class A1, class A2, class A3, class A4>
8704inline
8707{
8708 Variant4& lvalue = rhs;
8709
8710 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8711 return *this;
8712}
8713
8714 // -------------------
8715 // class Variant5<...>
8716 // -------------------
8717
8718// CREATORS
8719template <class A1, class A2, class A3, class A4, class A5>
8720inline
8724
8725template <class A1, class A2, class A3, class A4, class A5>
8726template <class TYPE_OR_ALLOCATOR>
8727inline
8729Variant5(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8730: Imp(valueOrAllocator)
8731{
8732}
8733
8734template <class A1, class A2, class A3, class A4, class A5>
8735template <class TYPE>
8736inline
8738Variant5(const TYPE& value, bslma::Allocator *basicAllocator)
8739: Imp(value, basicAllocator)
8740{
8741}
8742
8743template <class A1, class A2, class A3, class A4, class A5>
8744template <class TYPE>
8745inline
8747#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8748Variant5(TYPE&& value,
8749 typename bsl::enable_if<
8750 !bsl::is_same<
8751 SelfType,
8752 typename bsl::remove_const<
8753 typename bsl::remove_reference<TYPE>::type>::type>::value
8754 &&
8756 void>::type *)
8757: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8758#else
8759Variant5(bslmf::MovableRef<TYPE> value)
8760: Imp(MoveUtil::move(value))
8761#endif
8762{
8763}
8764
8765template <class A1, class A2, class A3, class A4, class A5>
8766template <class TYPE>
8767inline
8769#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8770Variant5(TYPE&& value,
8771 typename bsl::enable_if<
8772 !bsl::is_same<
8773 SelfType,
8774 typename bsl::remove_const<
8775 typename bsl::remove_reference<TYPE>::type>::type>::value,
8776 bslma::Allocator>::type *basicAllocator)
8777: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8778#else
8779Variant5(bslmf::MovableRef<TYPE> value,
8780 bslma::Allocator *basicAllocator)
8781: Imp(MoveUtil::move(value), basicAllocator)
8782#endif
8783{
8784}
8785
8786template <class A1, class A2, class A3, class A4, class A5>
8787inline
8789Variant5(const Variant5& original, bslma::Allocator *basicAllocator)
8790: Imp(static_cast<const Imp&>(original), basicAllocator)
8791{
8792}
8793
8794template <class A1, class A2, class A3, class A4, class A5>
8795inline
8798: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8799{
8800}
8801
8802template <class A1, class A2, class A3, class A4, class A5>
8803inline
8806 bslma::Allocator *basicAllocator)
8807: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8808 basicAllocator)
8809{
8810}
8811
8812// MANIPULATORS
8813template <class A1, class A2, class A3, class A4, class A5>
8814template <class TYPE>
8815inline
8818{
8819 Imp::operator=(value);
8820 return *this;
8821}
8822
8823template <class A1, class A2, class A3, class A4, class A5>
8824template <class TYPE>
8825inline
8826#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8827typename bsl::enable_if<
8829 typename bsl::remove_cvref<TYPE>::type>::value,
8832#else
8835#endif
8836{
8837#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8838 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8839#else
8840 TYPE& lvalue = value;
8841 Imp::operator=(MoveUtil::move(lvalue));
8842#endif
8843
8844 return *this;
8845}
8846
8847template <class A1, class A2, class A3, class A4, class A5>
8848inline
8851{
8852 Imp::operator=(static_cast<const Imp&>(rhs));
8853 return *this;
8854}
8855
8856template <class A1, class A2, class A3, class A4, class A5>
8857inline
8860{
8861 Variant5& lvalue = rhs;
8862
8863 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8864 return *this;
8865}
8866
8867 // -------------------
8868 // class Variant6<...>
8869 // -------------------
8870
8871// CREATORS
8872template <class A1, class A2, class A3, class A4, class A5, class A6>
8873inline
8877
8878template <class A1, class A2, class A3, class A4, class A5, class A6>
8879template <class TYPE_OR_ALLOCATOR>
8880inline
8882Variant6(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8883: Imp(valueOrAllocator)
8884{
8885}
8886
8887template <class A1, class A2, class A3, class A4, class A5, class A6>
8888template <class TYPE>
8889inline
8891Variant6(const TYPE& value, bslma::Allocator *basicAllocator)
8892: Imp(value, basicAllocator)
8893{
8894}
8895
8896template <class A1, class A2, class A3, class A4, class A5, class A6>
8897template <class TYPE>
8898inline
8900#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8901Variant6(TYPE&& value,
8902 typename bsl::enable_if<
8903 !bsl::is_same<
8904 SelfType,
8905 typename bsl::remove_const<
8906 typename bsl::remove_reference<TYPE>::type>::type>::value
8907 &&
8909 void>::type *)
8910: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8911#else
8912Variant6(bslmf::MovableRef<TYPE> value)
8913: Imp(MoveUtil::move(value))
8914#endif
8915{
8916}
8917
8918template <class A1, class A2, class A3, class A4, class A5, class A6>
8919template <class TYPE>
8920inline
8922#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8923Variant6(TYPE&& value,
8924 typename bsl::enable_if<
8925 !bsl::is_same<
8926 SelfType,
8927 typename bsl::remove_const<
8928 typename bsl::remove_reference<TYPE>::type>::type>::value,
8929 bslma::Allocator>::type *basicAllocator)
8930: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8931#else
8932Variant6(bslmf::MovableRef<TYPE> value,
8933 bslma::Allocator *basicAllocator)
8934: Imp(MoveUtil::move(value), basicAllocator)
8935#endif
8936{
8937}
8938
8939template <class A1, class A2, class A3, class A4, class A5, class A6>
8940inline
8942Variant6(const Variant6& original, bslma::Allocator *basicAllocator)
8943: Imp(static_cast<const Imp&>(original), basicAllocator)
8944{
8945}
8946
8947template <class A1, class A2, class A3, class A4, class A5, class A6>
8948inline
8951: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8952{
8953}
8954
8955template <class A1, class A2, class A3, class A4, class A5, class A6>
8956inline
8959 bslma::Allocator *basicAllocator)
8960: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8961 basicAllocator)
8962{
8963}
8964
8965// MANIPULATORS
8966template <class A1, class A2, class A3, class A4, class A5, class A6>
8967template <class TYPE>
8968inline
8971{
8972 Imp::operator=(value);
8973 return *this;
8974}
8975
8976template <class A1, class A2, class A3, class A4, class A5, class A6>
8977template <class TYPE>
8978inline
8979#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8980typename bsl::enable_if<
8982 typename bsl::remove_cvref<TYPE>::type>::value,
8985#else
8988#endif
8989{
8990#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8991 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8992#else
8993 TYPE& lvalue = value;
8994 Imp::operator=(MoveUtil::move(lvalue));
8995#endif
8996
8997 return *this;
8998}
8999
9000template <class A1, class A2, class A3, class A4, class A5, class A6>
9001inline
9004{
9005 Imp::operator=(static_cast<const Imp&>(rhs));
9006 return *this;
9007}
9008
9009template <class A1, class A2, class A3, class A4, class A5, class A6>
9010inline
9013{
9014 Variant6& lvalue = rhs;
9015
9016 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9017 return *this;
9018}
9019
9020 // -------------------
9021 // class Variant7<...>
9022 // -------------------
9023
9024// CREATORS
9025template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9026inline
9030
9031template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9032template <class TYPE_OR_ALLOCATOR>
9033inline
9035Variant7(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9036: Imp(valueOrAllocator)
9037{
9038}
9039
9040template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9041template <class TYPE>
9042inline
9044Variant7(const TYPE& value, bslma::Allocator *basicAllocator)
9045: Imp(value, basicAllocator)
9046{
9047}
9048
9049template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9050template <class TYPE>
9051inline
9053#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9054Variant7(TYPE&& value,
9055 typename bsl::enable_if<
9056 !bsl::is_same<
9057 SelfType,
9058 typename bsl::remove_const<
9059 typename bsl::remove_reference<TYPE>::type>::type>::value
9060 &&
9062 void>::type *)
9063: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9064#else
9065Variant7(bslmf::MovableRef<TYPE> value)
9066: Imp(MoveUtil::move(value))
9067#endif
9068{
9069}
9070
9071template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9072template <class TYPE>
9073inline
9075#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9076Variant7(TYPE&& value,
9077 typename bsl::enable_if<
9078 !bsl::is_same<
9079 SelfType,
9080 typename bsl::remove_const<
9081 typename bsl::remove_reference<TYPE>::type>::type>::value,
9082 bslma::Allocator>::type *basicAllocator)
9083: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9084#else
9085Variant7(bslmf::MovableRef<TYPE> value,
9086 bslma::Allocator *basicAllocator)
9087: Imp(MoveUtil::move(value), basicAllocator)
9088#endif
9089{
9090}
9091
9092template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9093inline
9095Variant7(const Variant7& original, bslma::Allocator *basicAllocator)
9096: Imp(static_cast<const Imp&>(original), basicAllocator)
9097{
9098}
9099
9100template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9101inline
9104: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9105{
9106}
9107
9108template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9109inline
9112 bslma::Allocator *basicAllocator)
9113: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9114 basicAllocator)
9115{
9116}
9117
9118// MANIPULATORS
9119template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9120template <class TYPE>
9121inline
9124{
9125 Imp::operator=(value);
9126 return *this;
9127}
9128
9129template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9130template <class TYPE>
9131inline
9132#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9133typename bsl::enable_if<
9135 typename bsl::remove_cvref<TYPE>::type>::value,
9138#else
9141#endif
9142{
9143#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9144 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9145#else
9146 TYPE& lvalue = value;
9147 Imp::operator=(MoveUtil::move(lvalue));
9148#endif
9149
9150 return *this;
9151}
9152
9153template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9154inline
9157operator=(const Variant7& rhs)
9158{
9159 Imp::operator=(static_cast<const Imp&>(rhs));
9160 return *this;
9161}
9162
9163template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9164inline
9168{
9169 Variant7& lvalue = rhs;
9170
9171 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9172 return *this;
9173}
9174
9175 // -------------------
9176 // class Variant8<...>
9177 // -------------------
9178
9179// CREATORS
9180template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9181 class A8>
9182inline
9186
9187template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9188 class A8>
9189template <class TYPE_OR_ALLOCATOR>
9190inline
9192Variant8(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9193: Imp(valueOrAllocator)
9194{
9195}
9196
9197template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9198 class A8>
9199template <class TYPE>
9200inline
9202Variant8(const TYPE& value, bslma::Allocator *basicAllocator)
9203: Imp(value, basicAllocator)
9204{
9205}
9206
9207template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9208 class A8>
9209template <class TYPE>
9210inline
9212#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9213Variant8(TYPE&& value,
9214 typename bsl::enable_if<
9215 !bsl::is_same<
9216 SelfType,
9217 typename bsl::remove_const<
9218 typename bsl::remove_reference<TYPE>::type>::type>::value
9219 &&
9221 void>::type *)
9222: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9223#else
9224Variant8(bslmf::MovableRef<TYPE> value)
9225: Imp(MoveUtil::move(value))
9226#endif
9227{
9228}
9229
9230template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9231 class A8>
9232template <class TYPE>
9233inline
9235#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9236Variant8(TYPE&& value,
9237 typename bsl::enable_if<
9238 !bsl::is_same<
9239 SelfType,
9240 typename bsl::remove_const<
9241 typename bsl::remove_reference<TYPE>::type>::type>::value,
9242 bslma::Allocator>::type *basicAllocator)
9243: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9244#else
9245Variant8(bslmf::MovableRef<TYPE> value,
9246 bslma::Allocator *basicAllocator)
9247: Imp(MoveUtil::move(value), basicAllocator)
9248#endif
9249{
9250}
9251
9252template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9253 class A8>
9254inline
9256Variant8(const Variant8& original, bslma::Allocator *basicAllocator)
9257: Imp(static_cast<const Imp&>(original), basicAllocator)
9258{
9259}
9260
9261template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9262 class A8>
9263inline
9266: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9267{
9268}
9269
9270template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9271 class A8>
9272inline
9275 bslma::Allocator *basicAllocator)
9276: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9277 basicAllocator)
9278{
9279}
9280
9281// MANIPULATORS
9282template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9283 class A8>
9284template <class TYPE>
9285inline
9288{
9289 Imp::operator=(value);
9290 return *this;
9291}
9292
9293template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9294 class A8>
9295template <class TYPE>
9296inline
9297#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9298typename bsl::enable_if<
9300 typename bsl::remove_cvref<TYPE>::type>::value,
9303operator=(TYPE&& value)
9304#else
9308#endif
9309{
9310#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9311 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9312#else
9313 TYPE& lvalue = value;
9314 Imp::operator=(MoveUtil::move(lvalue));
9315#endif
9316
9317 return *this;
9318}
9319
9320template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9321 class A8>
9322inline
9325operator=(const Variant8& rhs)
9326{
9327 Imp::operator=(static_cast<const Imp&>(rhs));
9328 return *this;
9329}
9330
9331template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9332 class A8>
9333inline
9337{
9338 Variant8& lvalue = rhs;
9339
9340 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9341 return *this;
9342}
9343
9344 // -------------------
9345 // class Variant9<...>
9346 // -------------------
9347
9348// CREATORS
9349template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9350 class A8, class A9>
9351inline
9355
9356template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9357 class A8, class A9>
9358template <class TYPE_OR_ALLOCATOR>
9359inline
9361Variant9(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9362: Imp(valueOrAllocator)
9363{
9364}
9365
9366template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9367 class A8, class A9>
9368template <class TYPE>
9369inline
9371Variant9(const TYPE& value, bslma::Allocator *basicAllocator)
9372: Imp(value, basicAllocator)
9373{
9374}
9375
9376template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9377 class A8, class A9>
9378template <class TYPE>
9379inline
9381#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9382Variant9(TYPE&& value,
9383 typename bsl::enable_if<
9384 !bsl::is_same<
9385 SelfType,
9386 typename bsl::remove_const<
9387 typename bsl::remove_reference<TYPE>::type>::type>::value
9388 &&
9390 void>::type *)
9391: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9392#else
9393Variant9(bslmf::MovableRef<TYPE> value)
9394: Imp(MoveUtil::move(value))
9395#endif
9396{
9397}
9398
9399template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9400 class A8, class A9>
9401template <class TYPE>
9402inline
9404#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9405Variant9(TYPE&& value,
9406 typename bsl::enable_if<
9407 !bsl::is_same<
9408 SelfType,
9409 typename bsl::remove_const<
9410 typename bsl::remove_reference<TYPE>::type>::type>::value,
9411 bslma::Allocator>::type *basicAllocator)
9412: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9413#else
9414Variant9(bslmf::MovableRef<TYPE> value,
9415 bslma::Allocator *basicAllocator)
9416: Imp(MoveUtil::move(value), basicAllocator)
9417#endif
9418{
9419}
9420
9421template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9422 class A8, class A9>
9423inline
9425Variant9(const Variant9& original, bslma::Allocator *basicAllocator)
9426: Imp(static_cast<const Imp&>(original), basicAllocator)
9427{
9428}
9429
9430template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9431 class A8, class A9>
9432inline
9435: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9436{
9437}
9438
9439template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9440 class A8, class A9>
9441inline
9444 bslma::Allocator *basicAllocator)
9445: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9446 basicAllocator)
9447{
9448}
9449
9450// MANIPULATORS
9451template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9452 class A8, class A9>
9453template <class TYPE>
9454inline
9457operator=(const TYPE& value)
9458{
9459 Imp::operator=(value);
9460 return *this;
9461}
9462
9463template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9464 class A8, class A9>
9465template <class TYPE>
9466inline
9467#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9468typename bsl::enable_if<
9470 typename bsl::remove_cvref<TYPE>::type>::value,
9473operator=(TYPE&& value)
9474#else
9478#endif
9479{
9480#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9481 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9482#else
9483 TYPE& lvalue = value;
9484 Imp::operator=(MoveUtil::move(lvalue));
9485#endif
9486
9487 return *this;
9488}
9489
9490template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9491 class A8, class A9>
9492inline
9495operator=(const Variant9& rhs)
9496{
9497 Imp::operator=(static_cast<const Imp&>(rhs));
9498 return *this;
9499}
9500
9501template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9502 class A8, class A9>
9503inline
9507{
9508 Variant9& lvalue = rhs;
9509
9510 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9511 return *this;
9512}
9513
9514 // --------------------
9515 // class Variant10<...>
9516 // --------------------
9517
9518// CREATORS
9519template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9520 class A8, class A9, class A10>
9521inline
9525
9526template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9527 class A8, class A9, class A10>
9528template <class TYPE_OR_ALLOCATOR>
9529inline
9531Variant10(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9532: Imp(valueOrAllocator)
9533{
9534}
9535
9536template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9537 class A8, class A9, class A10>
9538template <class TYPE>
9539inline
9541Variant10(const TYPE& value, bslma::Allocator *basicAllocator)
9542: Imp(value, basicAllocator)
9543{
9544}
9545
9546template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9547 class A8, class A9, class A10>
9548template <class TYPE>
9549inline
9551#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9552Variant10(TYPE&& value,
9553 typename bsl::enable_if<
9554 !bsl::is_same<
9555 SelfType,
9556 typename bsl::remove_const<
9557 typename bsl::remove_reference<TYPE>::type>::type>::value
9558 &&
9560 void>::type *)
9561: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9562#else
9563Variant10(bslmf::MovableRef<TYPE> value)
9564: Imp(MoveUtil::move(value))
9565#endif
9566{
9567}
9568
9569template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9570 class A8, class A9, class A10>
9571template <class TYPE>
9572inline
9574#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9575Variant10(TYPE&& value,
9576 typename bsl::enable_if<
9577 !bsl::is_same<
9578 SelfType,
9579 typename bsl::remove_const<
9580 typename bsl::remove_reference<TYPE>::type>::type>::value,
9581 bslma::Allocator>::type *basicAllocator)
9582: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9583#else
9584Variant10(bslmf::MovableRef<TYPE> value,
9585 bslma::Allocator *basicAllocator)
9586: Imp(MoveUtil::move(value), basicAllocator)
9587#endif
9588{
9589}
9590
9591template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9592 class A8, class A9, class A10>
9593inline
9595Variant10(const Variant10& original, bslma::Allocator *basicAllocator)
9596: Imp(static_cast<const Imp&>(original), basicAllocator)
9597{
9598}
9599
9600template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9601 class A8, class A9, class A10>
9602inline
9605: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9606{
9607}
9608
9609template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9610 class A8, class A9, class A10>
9611inline
9614 bslma::Allocator *basicAllocator)
9615: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9616 basicAllocator)
9617{
9618}
9619
9620// MANIPULATORS
9621template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9622 class A8, class A9, class A10>
9623template <class TYPE>
9624inline
9627operator=(const TYPE& value)
9628{
9629 Imp::operator=(value);
9630 return *this;
9631}
9632
9633template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9634 class A8, class A9, class A10>
9635template <class TYPE>
9636inline
9637#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9638typename bsl::enable_if<
9640 typename bsl::remove_cvref<TYPE>::type>::value,
9643operator=(TYPE&& value)
9644#else
9648#endif
9649{
9650#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9651 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9652#else
9653 TYPE& lvalue = value;
9654 Imp::operator=(MoveUtil::move(lvalue));
9655#endif
9656
9657 return *this;
9658}
9659
9660template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9661 class A8, class A9, class A10>
9662inline
9665operator=(const Variant10& rhs)
9666{
9667 Imp::operator=(static_cast<const Imp&>(rhs));
9668 return *this;
9669}
9670
9671template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9672 class A8, class A9, class A10>
9673inline
9677{
9678 Variant10& lvalue = rhs;
9679
9680 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9681 return *this;
9682}
9683
9684 // --------------------
9685 // class Variant11<...>
9686 // --------------------
9687
9688// CREATORS
9689template <class A1, class A2, class A3, class A4, class A5, class A6,
9690 class A7, class A8, class A9, class A10, class A11>
9691inline
9696
9697template <class A1, class A2, class A3, class A4, class A5, class A6,
9698 class A7, class A8, class A9, class A10, class A11>
9699template <class TYPE_OR_ALLOCATOR>
9700inline
9702Variant11(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9703: Imp(valueOrAllocator)
9704{
9705}
9706
9707template <class A1, class A2, class A3, class A4, class A5, class A6,
9708 class A7, class A8, class A9, class A10, class A11>
9709template <class TYPE>
9710inline
9712Variant11(const TYPE& value, bslma::Allocator *basicAllocator)
9713: Imp(value, basicAllocator)
9714{
9715}
9716
9717template <class A1, class A2, class A3, class A4, class A5, class A6,
9718 class A7, class A8, class A9, class A10, class A11>
9719template <class TYPE>
9720inline
9722#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9723Variant11(TYPE&& value,
9724 typename bsl::enable_if<
9725 !bsl::is_same<
9726 SelfType,
9727 typename bsl::remove_const<
9728 typename bsl::remove_reference<TYPE>::type>::type>::value
9729 &&
9731 void>::type *)
9732: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9733#else
9734Variant11(bslmf::MovableRef<TYPE> value)
9735: Imp(MoveUtil::move(value))
9736#endif
9737{
9738}
9739
9740template <class A1, class A2, class A3, class A4, class A5, class A6,
9741 class A7, class A8, class A9, class A10, class A11>
9742template <class TYPE>
9743inline
9745#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9746Variant11(TYPE&& value,
9747 typename bsl::enable_if<
9748 !bsl::is_same<
9749 SelfType,
9750 typename bsl::remove_const<
9751 typename bsl::remove_reference<TYPE>::type>::type>::value,
9752 bslma::Allocator>::type *basicAllocator)
9753: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9754#else
9755Variant11(bslmf::MovableRef<TYPE> value,
9756 bslma::Allocator *basicAllocator)
9757: Imp(MoveUtil::move(value), basicAllocator)
9758#endif
9759{
9760}
9761
9762template <class A1, class A2, class A3, class A4, class A5, class A6,
9763 class A7, class A8, class A9, class A10, class A11>
9764inline
9766Variant11(const Variant11& original, bslma::Allocator *basicAllocator)
9767: Imp(static_cast<const Imp&>(original), basicAllocator)
9768{
9769}
9770
9771template <class A1, class A2, class A3, class A4, class A5, class A6,
9772 class A7, class A8, class A9, class A10, class A11>
9773inline
9776: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9777{
9778}
9779
9780template <class A1, class A2, class A3, class A4, class A5, class A6,
9781 class A7, class A8, class A9, class A10, class A11>
9782inline
9785 bslma::Allocator *basicAllocator)
9786: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9787 basicAllocator)
9788{
9789}
9790
9791// MANIPULATORS
9792template <class A1, class A2, class A3, class A4, class A5, class A6,
9793 class A7, class A8, class A9, class A10, class A11>
9794template <class TYPE>
9795inline
9798operator=(const TYPE& value)
9799{
9800 Imp::operator=(value);
9801 return *this;
9802}
9803
9804template <class A1, class A2, class A3, class A4, class A5, class A6,
9805 class A7, class A8, class A9, class A10, class A11>
9806template <class TYPE>
9807inline
9808#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9809typename bsl::enable_if<
9811 typename bsl::remove_cvref<TYPE>::type>::value,
9814operator=(TYPE&& value)
9815#else
9819#endif
9820{
9821#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9822 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9823#else
9824 TYPE& lvalue = value;
9825 Imp::operator=(MoveUtil::move(lvalue));
9826#endif
9827
9828 return *this;
9829}
9830
9831template <class A1, class A2, class A3, class A4, class A5, class A6,
9832 class A7, class A8, class A9, class A10, class A11>
9833inline
9836operator=(const Variant11& rhs)
9837{
9838 Imp::operator=(static_cast<const Imp&>(rhs));
9839 return *this;
9840}
9841
9842template <class A1, class A2, class A3, class A4, class A5, class A6,
9843 class A7, class A8, class A9, class A10, class A11>
9844inline
9848{
9849 Variant11& lvalue = rhs;
9850
9851 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9852 return *this;
9853}
9854
9855 // --------------------
9856 // class Variant12<...>
9857 // --------------------
9858
9859// CREATORS
9860template <class A1, class A2, class A3, class A4, class A5, class A6,
9861 class A7, class A8, class A9, class A10, class A11, class A12>
9862inline
9867
9868template <class A1, class A2, class A3, class A4, class A5, class A6,
9869 class A7, class A8, class A9, class A10, class A11, class A12>
9870template <class TYPE_OR_ALLOCATOR>
9871inline
9873Variant12(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9874: Imp(valueOrAllocator)
9875{
9876}
9877
9878template <class A1, class A2, class A3, class A4, class A5, class A6,
9879 class A7, class A8, class A9, class A10, class A11, class A12>
9880template <class TYPE>
9881inline
9883Variant12(const TYPE& value, bslma::Allocator *basicAllocator)
9884: Imp(value, basicAllocator)
9885{
9886}
9887
9888template <class A1, class A2, class A3, class A4, class A5, class A6,
9889 class A7, class A8, class A9, class A10, class A11, class A12>
9890template <class TYPE>
9891inline
9893#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9894Variant12(TYPE&& value,
9895 typename bsl::enable_if<
9896 !bsl::is_same<
9897 SelfType,
9898 typename bsl::remove_const<
9899 typename bsl::remove_reference<TYPE>::type>::type>::value
9900 &&
9902 void>::type *)
9903: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9904#else
9905Variant12(bslmf::MovableRef<TYPE> value)
9906: Imp(MoveUtil::move(value))
9907#endif
9908{
9909}
9910
9911template <class A1, class A2, class A3, class A4, class A5, class A6,
9912 class A7, class A8, class A9, class A10, class A11, class A12>
9913template <class TYPE>
9914inline
9916#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9917Variant12(TYPE&& value,
9918 typename bsl::enable_if<
9919 !bsl::is_same<
9920 SelfType,
9921 typename bsl::remove_const<
9922 typename bsl::remove_reference<TYPE>::type>::type>::value,
9923 bslma::Allocator>::type *basicAllocator)
9924: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9925#else
9926Variant12(bslmf::MovableRef<TYPE> value,
9927 bslma::Allocator *basicAllocator)
9928: Imp(MoveUtil::move(value), basicAllocator)
9929#endif
9930{
9931}
9932
9933template <class A1, class A2, class A3, class A4, class A5, class A6,
9934 class A7, class A8, class A9, class A10, class A11, class A12>
9935inline
9937Variant12(const Variant12& original, bslma::Allocator *basicAllocator)
9938: Imp(static_cast<const Imp&>(original), basicAllocator)
9939{
9940}
9941
9942template <class A1, class A2, class A3, class A4, class A5, class A6,
9943 class A7, class A8, class A9, class A10, class A11, class A12>
9944inline
9947: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9948{
9949}
9950
9951template <class A1, class A2, class A3, class A4, class A5, class A6,
9952 class A7, class A8, class A9, class A10, class A11, class A12>
9953inline
9956 bslma::Allocator *basicAllocator)
9957: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9958 basicAllocator)
9959{
9960}
9961
9962// MANIPULATORS
9963template <class A1, class A2, class A3, class A4, class A5, class A6,
9964 class A7, class A8, class A9, class A10, class A11, class A12>
9965template <class TYPE>
9966inline
9969operator=(const TYPE& value)
9970{
9971 Imp::operator=(value);
9972 return *this;
9973}
9974
9975template <class A1, class A2, class A3, class A4, class A5, class A6,
9976 class A7, class A8, class A9, class A10, class A11, class A12>
9977template <class TYPE>
9978inline
9979#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9980typename bsl::enable_if<
9982 typename bsl::remove_cvref<TYPE>::type>::value,
9985operator=(TYPE&& value)
9986#else
9990#endif
9991{
9992#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9993 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9994#else
9995 TYPE& lvalue = value;
9996 Imp::operator=(MoveUtil::move(lvalue));
9997#endif
9998
9999 return *this;
10000}
10001
10002template <class A1, class A2, class A3, class A4, class A5, class A6,
10003 class A7, class A8, class A9, class A10, class A11, class A12>
10004inline
10007operator=(const Variant12& rhs)
10008{
10009 Imp::operator=(static_cast<const Imp&>(rhs));
10010 return *this;
10011}
10012
10013template <class A1, class A2, class A3, class A4, class A5, class A6,
10014 class A7, class A8, class A9, class A10, class A11, class A12>
10015inline
10019{
10020 Variant12& lvalue = rhs;
10021
10022 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10023 return *this;
10024}
10025
10026 // --------------------
10027 // class Variant13<...>
10028 // --------------------
10029
10030// CREATORS
10031template <class A1, class A2, class A3, class A4, class A5, class A6,
10032 class A7, class A8, class A9, class A10, class A11, class A12,
10033 class A13>
10034inline
10039
10040template <class A1, class A2, class A3, class A4, class A5, class A6,
10041 class A7, class A8, class A9, class A10, class A11, class A12,
10042 class A13>
10043template <class TYPE_OR_ALLOCATOR>
10044inline
10046Variant13(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10047: Imp(valueOrAllocator)
10048{
10049}
10050
10051template <class A1, class A2, class A3, class A4, class A5, class A6,
10052 class A7, class A8, class A9, class A10, class A11, class A12,
10053 class A13>
10054template <class TYPE>
10055inline
10057Variant13(const TYPE& value, bslma::Allocator *basicAllocator)
10058: Imp(value, basicAllocator)
10059{
10060}
10061
10062template <class A1, class A2, class A3, class A4, class A5, class A6,
10063 class A7, class A8, class A9, class A10, class A11, class A12,
10064 class A13>
10065template <class TYPE>
10066inline
10068#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10069Variant13(TYPE&& value,
10070 typename bsl::enable_if<
10071 !bsl::is_same<
10072 SelfType,
10073 typename bsl::remove_const<
10074 typename bsl::remove_reference<TYPE>::type>::type>::value
10075 &&
10077 void>::type *)
10078: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10079#else
10080Variant13(bslmf::MovableRef<TYPE> value)
10081: Imp(MoveUtil::move(value))
10082#endif
10083{
10084}
10085
10086template <class A1, class A2, class A3, class A4, class A5, class A6,
10087 class A7, class A8, class A9, class A10, class A11, class A12,
10088 class A13>
10089template <class TYPE>
10090inline
10092#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10093Variant13(TYPE&& value,
10094 typename bsl::enable_if<
10095 !bsl::is_same<
10096 SelfType,
10097 typename bsl::remove_const<
10098 typename bsl::remove_reference<TYPE>::type>::type>::value,
10099 bslma::Allocator>::type *basicAllocator)
10100: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10101#else
10102Variant13(bslmf::MovableRef<TYPE> value,
10103 bslma::Allocator *basicAllocator)
10104: Imp(MoveUtil::move(value), basicAllocator)
10105#endif
10106{
10107}
10108
10109template <class A1, class A2, class A3, class A4, class A5, class A6,
10110 class A7, class A8, class A9, class A10, class A11, class A12,
10111 class A13>
10112inline
10114Variant13(const Variant13& original, bslma::Allocator *basicAllocator)
10115: Imp(static_cast<const Imp&>(original), basicAllocator)
10116{
10117}
10118
10119template <class A1, class A2, class A3, class A4, class A5, class A6,
10120 class A7, class A8, class A9, class A10, class A11, class A12,
10121 class A13>
10122inline
10125: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10126{
10127}
10128
10129template <class A1, class A2, class A3, class A4, class A5, class A6,
10130 class A7, class A8, class A9, class A10, class A11, class A12,
10131 class A13>
10132inline
10135 bslma::Allocator *basicAllocator)
10136: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10137 basicAllocator)
10138{
10139}
10140
10141// MANIPULATORS
10142template <class A1, class A2, class A3, class A4, class A5, class A6,
10143 class A7, class A8, class A9, class A10, class A11, class A12,
10144 class A13>
10145template <class TYPE>
10146inline
10149operator=(const TYPE& value)
10150{
10151 Imp::operator=(value);
10152 return *this;
10153}
10154
10155template <class A1, class A2, class A3, class A4, class A5, class A6,
10156 class A7, class A8, class A9, class A10, class A11, class A12,
10157 class A13>
10158template <class TYPE>
10159inline
10160#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10161typename bsl::enable_if<
10162 !bsl::is_same<Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
10163 A13>,
10164 typename bsl::remove_cvref<TYPE>::type>::value,
10167operator=(TYPE&& value)
10168#else
10172#endif
10173{
10174#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10175 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10176#else
10177 TYPE& lvalue = value;
10178 Imp::operator=(MoveUtil::move(lvalue));
10179#endif
10180
10181 return *this;
10182}
10183
10184template <class A1, class A2, class A3, class A4, class A5, class A6,
10185 class A7, class A8, class A9, class A10, class A11, class A12,
10186 class A13>
10187inline
10190operator=(const Variant13& rhs)
10191{
10192 Imp::operator=(static_cast<const Imp&>(rhs));
10193 return *this;
10194}
10195
10196template <class A1, class A2, class A3, class A4, class A5, class A6,
10197 class A7, class A8, class A9, class A10, class A11, class A12,
10198 class A13>
10199inline
10203{
10204 Variant13& lvalue = rhs;
10205
10206 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10207 return *this;
10208}
10209
10210 // --------------------
10211 // class Variant14<...>
10212 // --------------------
10213
10214// CREATORS
10215template <class A1, class A2, class A3, class A4, class A5, class A6,
10216 class A7, class A8, class A9, class A10, class A11, class A12,
10217 class A13, class A14>
10218inline
10223
10224template <class A1, class A2, class A3, class A4, class A5, class A6,
10225 class A7, class A8, class A9, class A10, class A11, class A12,
10226 class A13, class A14>
10227template <class TYPE_OR_ALLOCATOR>
10228inline
10230Variant14(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10231: Imp(valueOrAllocator)
10232{
10233}
10234
10235template <class A1, class A2, class A3, class A4, class A5, class A6,
10236 class A7, class A8, class A9, class A10, class A11, class A12,
10237 class A13, class A14>
10238template <class TYPE>
10239inline
10241Variant14(const TYPE& value, bslma::Allocator *basicAllocator)
10242: Imp(value, basicAllocator)
10243{
10244}
10245
10246template <class A1, class A2, class A3, class A4, class A5, class A6,
10247 class A7, class A8, class A9, class A10, class A11, class A12,
10248 class A13, class A14>
10249template <class TYPE>
10250inline
10252#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10253Variant14(TYPE&& value,
10254 typename bsl::enable_if<
10255 !bsl::is_same<
10256 SelfType,
10257 typename bsl::remove_const<
10258 typename bsl::remove_reference<TYPE>::type>::type>::value
10259 &&
10261 void>::type *)
10262: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10263#else
10264Variant14(bslmf::MovableRef<TYPE> value)
10265: Imp(MoveUtil::move(value))
10266#endif
10267{
10268}
10269
10270template <class A1, class A2, class A3, class A4, class A5, class A6,
10271 class A7, class A8, class A9, class A10, class A11, class A12,
10272 class A13, class A14>
10273template <class TYPE>
10274inline
10276#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10277Variant14(TYPE&& value,
10278 typename bsl::enable_if<
10279 !bsl::is_same<
10280 SelfType,
10281 typename bsl::remove_const<
10282 typename bsl::remove_reference<TYPE>::type>::type>::value,
10283 bslma::Allocator>::type *basicAllocator)
10284: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10285#else
10286Variant14(bslmf::MovableRef<TYPE> value,
10287 bslma::Allocator *basicAllocator)
10288: Imp(MoveUtil::move(value), basicAllocator)
10289#endif
10290{
10291}
10292
10293template <class A1, class A2, class A3, class A4, class A5, class A6,
10294 class A7, class A8, class A9, class A10, class A11, class A12,
10295 class A13, class A14>
10296inline
10298Variant14(const Variant14& original, bslma::Allocator *basicAllocator)
10299: Imp(static_cast<const Imp&>(original), basicAllocator)
10300{
10301}
10302
10303template <class A1, class A2, class A3, class A4, class A5, class A6,
10304 class A7, class A8, class A9, class A10, class A11, class A12,
10305 class A13, class A14>
10306inline
10309: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10310{
10311}
10312
10313template <class A1, class A2, class A3, class A4, class A5, class A6,
10314 class A7, class A8, class A9, class A10, class A11, class A12,
10315 class A13, class A14>
10316inline
10319 bslma::Allocator *basicAllocator)
10320: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10321 basicAllocator)
10322{
10323}
10324
10325// MANIPULATORS
10326template <class A1, class A2, class A3, class A4, class A5, class A6,
10327 class A7, class A8, class A9, class A10, class A11, class A12,
10328 class A13, class A14>
10329template <class TYPE>
10330inline
10333operator=(const TYPE& value)
10334{
10335 Imp::operator=(value);
10336 return *this;
10337}
10338
10339template <class A1, class A2, class A3, class A4, class A5, class A6,
10340 class A7, class A8, class A9, class A10, class A11, class A12,
10341 class A13, class A14>
10342template <class TYPE>
10343inline
10344#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10345typename bsl::enable_if<
10346 !bsl::is_same<Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
10347 A13, A14>,
10348 typename bsl::remove_cvref<TYPE>::type>::value,
10351operator=(TYPE&& value)
10352#else
10356#endif
10357{
10358#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10359 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10360#else
10361 TYPE& lvalue = value;
10362 Imp::operator=(MoveUtil::move(lvalue));
10363#endif
10364
10365 return *this;
10366}
10367
10368template <class A1, class A2, class A3, class A4, class A5, class A6,
10369 class A7, class A8, class A9, class A10, class A11, class A12,
10370 class A13, class A14>
10371inline
10374operator=(const Variant14& rhs)
10375{
10376 Imp::operator=(static_cast<const Imp&>(rhs));
10377 return *this;
10378}
10379
10380template <class A1, class A2, class A3, class A4, class A5, class A6,
10381 class A7, class A8, class A9, class A10, class A11, class A12,
10382 class A13, class A14>
10383inline
10387{
10388 Variant14& lvalue = rhs;
10389
10390 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10391 return *this;
10392}
10393
10394 // --------------------
10395 // class Variant15<...>
10396 // --------------------
10397
10398// CREATORS
10399template <class A1, class A2, class A3, class A4, class A5, class A6,
10400 class A7, class A8, class A9, class A10, class A11, class A12,
10401 class A13, class A14, class A15>
10402inline
10407
10408template <class A1, class A2, class A3, class A4, class A5, class A6,
10409 class A7, class A8, class A9, class A10, class A11, class A12,
10410 class A13, class A14, class A15>
10411template <class TYPE_OR_ALLOCATOR>
10412inline
10414Variant15(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10415: Imp(valueOrAllocator)
10416{
10417}
10418
10419template <class A1, class A2, class A3, class A4, class A5, class A6,
10420 class A7, class A8, class A9, class A10, class A11, class A12,
10421 class A13, class A14, class A15>
10422template <class TYPE>
10423inline
10425Variant15(const TYPE& value, bslma::Allocator *basicAllocator)
10426: Imp(value, basicAllocator)
10427{
10428}
10429
10430template <class A1, class A2, class A3, class A4, class A5, class A6,
10431 class A7, class A8, class A9, class A10, class A11, class A12,
10432 class A13, class A14, class A15>
10433template <class TYPE>
10434inline
10436#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10437Variant15(TYPE&& value,
10438 typename bsl::enable_if<
10439 !bsl::is_same<
10440 SelfType,
10441 typename bsl::remove_const<
10442 typename bsl::remove_reference<TYPE>::type>::type>::value
10443 &&
10445 void>::type *)
10446: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10447#else
10448Variant15(bslmf::MovableRef<TYPE> value)
10449: Imp(MoveUtil::move(value))
10450#endif
10451{
10452}
10453
10454template <class A1, class A2, class A3, class A4, class A5, class A6,
10455 class A7, class A8, class A9, class A10, class A11, class A12,
10456 class A13, class A14, class A15>
10457template <class TYPE>
10458inline
10460#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10461Variant15(TYPE&& value,
10462 typename bsl::enable_if<
10463 !bsl::is_same<
10464 SelfType,
10465 typename bsl::remove_const<
10466 typename bsl::remove_reference<TYPE>::type>::type>::value,
10467 bslma::Allocator>::type *basicAllocator)
10468: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10469#else
10470Variant15(bslmf::MovableRef<TYPE> value,
10471 bslma::Allocator *basicAllocator)
10472: Imp(MoveUtil::move(value), basicAllocator)
10473#endif
10474{
10475}
10476
10477template <class A1, class A2, class A3, class A4, class A5, class A6,
10478 class A7, class A8, class A9, class A10, class A11, class A12,
10479 class A13, class A14, class A15>
10480inline
10482Variant15(const Variant15& original, bslma::Allocator *basicAllocator)
10483: Imp(static_cast<const Imp&>(original), basicAllocator)
10484{
10485}
10486
10487template <class A1, class A2, class A3, class A4, class A5, class A6,
10488 class A7, class A8, class A9, class A10, class A11, class A12,
10489 class A13, class A14, class A15>
10490inline
10493: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10494{
10495}
10496
10497template <class A1, class A2, class A3, class A4, class A5, class A6,
10498 class A7, class A8, class A9, class A10, class A11, class A12,
10499 class A13, class A14, class A15>
10500inline
10503 bslma::Allocator *basicAllocator)
10504: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10505 basicAllocator)
10506{
10507}
10508
10509// MANIPULATORS
10510template <class A1, class A2, class A3, class A4, class A5, class A6,
10511 class A7, class A8, class A9, class A10, class A11, class A12,
10512 class A13, class A14, class A15>
10513template <class TYPE>
10514inline
10517operator=(const TYPE& value)
10518{
10519 Imp::operator=(value);
10520 return *this;
10521}
10522
10523template <class A1, class A2, class A3, class A4, class A5, class A6,
10524 class A7, class A8, class A9, class A10, class A11, class A12,
10525 class A13, class A14, class A15>
10526template <class TYPE>
10527inline
10528#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10529typename bsl::enable_if<
10530 !bsl::is_same<Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
10531 A12, A13, A14, A15>,
10532 typename bsl::remove_cvref<TYPE>::type>::value,
10533Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10534 A15> >::type&
10536operator=(TYPE&& value)
10537#else
10541#endif
10542{
10543#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10544 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10545#else
10546 TYPE& lvalue = value;
10547 Imp::operator=(MoveUtil::move(lvalue));
10548#endif
10549
10550 return *this;
10551}
10552
10553template <class A1, class A2, class A3, class A4, class A5, class A6,
10554 class A7, class A8, class A9, class A10, class A11, class A12,
10555 class A13, class A14, class A15>
10556inline
10559operator=(const Variant15& rhs)
10560{
10561 Imp::operator=(static_cast<const Imp&>(rhs));
10562 return *this;
10563}
10564
10565template <class A1, class A2, class A3, class A4, class A5, class A6,
10566 class A7, class A8, class A9, class A10, class A11, class A12,
10567 class A13, class A14, class A15>
10568inline
10572{
10573 Variant15& lvalue = rhs;
10574
10575 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10576 return *this;
10577}
10578
10579 // --------------------
10580 // class Variant16<...>
10581 // --------------------
10582
10583// CREATORS
10584template <class A1, class A2, class A3, class A4, class A5, class A6,
10585 class A7, class A8, class A9, class A10, class A11, class A12,
10586 class A13, class A14, class A15, class A16>
10587inline
10588Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10589 A15, A16>::
10590Variant16()
10591{
10592}
10593
10594template <class A1, class A2, class A3, class A4, class A5, class A6,
10595 class A7, class A8, class A9, class A10, class A11, class A12,
10596 class A13, class A14, class A15, class A16>
10597template <class TYPE_OR_ALLOCATOR>
10598inline
10599Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10600 A15, A16>::
10601Variant16(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10602: Imp(valueOrAllocator)
10603{
10604}
10605
10606template <class A1, class A2, class A3, class A4, class A5, class A6,
10607 class A7, class A8, class A9, class A10, class A11, class A12,
10608 class A13, class A14, class A15, class A16>
10609template <class TYPE>
10610inline
10611Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10612 A15, A16>::
10613Variant16(const TYPE& value, bslma::Allocator *basicAllocator)
10614: Imp(value, basicAllocator)
10615{
10616}
10617
10618template <class A1, class A2, class A3, class A4, class A5, class A6,
10619 class A7, class A8, class A9, class A10, class A11, class A12,
10620 class A13, class A14, class A15, class A16>
10621template <class TYPE>
10622inline
10623Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10624 A15, A16>::
10625#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10626Variant16(TYPE&& value,
10627 typename bsl::enable_if<
10628 !bsl::is_same<
10629 SelfType,
10630 typename bsl::remove_const<
10631 typename bsl::remove_reference<TYPE>::type>::type>::value
10632 &&
10634 void>::type *)
10635: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10636#else
10637Variant16(bslmf::MovableRef<TYPE> value)
10638: Imp(MoveUtil::move(value))
10639#endif
10640{
10641}
10642
10643template <class A1, class A2, class A3, class A4, class A5, class A6,
10644 class A7, class A8, class A9, class A10, class A11, class A12,
10645 class A13, class A14, class A15, class A16>
10646template <class TYPE>
10647inline
10648Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10649 A15, A16>::
10650#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10651Variant16(TYPE&& value,
10652 typename bsl::enable_if<
10653 !bsl::is_same<
10654 SelfType,
10655 typename bsl::remove_const<
10656 typename bsl::remove_reference<TYPE>::type>::type>::value,
10657 bslma::Allocator>::type *basicAllocator)
10658: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10659#else
10660Variant16(bslmf::MovableRef<TYPE> value,
10661 bslma::Allocator *basicAllocator)
10662: Imp(MoveUtil::move(value), basicAllocator)
10663#endif
10664{
10665}
10666
10667template <class A1, class A2, class A3, class A4, class A5, class A6,
10668 class A7, class A8, class A9, class A10, class A11, class A12,
10669 class A13, class A14, class A15, class A16>
10670inline
10671Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10672 A15, A16>::
10673Variant16(const Variant16& original, bslma::Allocator *basicAllocator)
10674: Imp(static_cast<const Imp&>(original), basicAllocator)
10675{
10676}
10677
10678template <class A1, class A2, class A3, class A4, class A5, class A6,
10679 class A7, class A8, class A9, class A10, class A11, class A12,
10680 class A13, class A14, class A15, class A16>
10681inline
10682Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10683 A15, A16>::
10684Variant16(bslmf::MovableRef<Variant16> original)
10685: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10686{
10687}
10688
10689template <class A1, class A2, class A3, class A4, class A5, class A6,
10690 class A7, class A8, class A9, class A10, class A11, class A12,
10691 class A13, class A14, class A15, class A16>
10692inline
10693Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10694 A15, A16>::
10695Variant16(bslmf::MovableRef<Variant16> original,
10696 bslma::Allocator *basicAllocator)
10697: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10698 basicAllocator)
10699{
10700}
10701
10702// MANIPULATORS
10703template <class A1, class A2, class A3, class A4, class A5, class A6,
10704 class A7, class A8, class A9, class A10, class A11, class A12,
10705 class A13, class A14, class A15, class A16>
10706template <class TYPE>
10707inline
10708Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10709 A15, A16>&
10710Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10711 A15, A16>::
10712operator=(const TYPE& value)
10713{
10714 Imp::operator=(value);
10715 return *this;
10716}
10717
10718template <class A1, class A2, class A3, class A4, class A5, class A6,
10719 class A7, class A8, class A9, class A10, class A11, class A12,
10720 class A13, class A14, class A15, class A16>
10721template <class TYPE>
10722inline
10723#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10724typename bsl::enable_if<
10725 !bsl::is_same<Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
10726 A12, A13, A14, A15, A16>,
10727 typename bsl::remove_cvref<TYPE>::type>::value,
10728Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10729 A16> >::type&
10730Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10731 A16>::operator=(TYPE&& value)
10732#else
10733Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10734 A16>&
10735Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10736 A16>::operator=(bslmf::MovableRef<TYPE> value)
10737#endif
10738{
10739#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10740 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10741#else
10742 TYPE& lvalue = value;
10743 Imp::operator=(MoveUtil::move(lvalue));
10744#endif
10745
10746 return *this;
10747}
10748
10749template <class A1, class A2, class A3, class A4, class A5, class A6,
10750 class A7, class A8, class A9, class A10, class A11, class A12,
10751 class A13, class A14, class A15, class A16>
10752inline
10753Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10754 A15, A16>&
10755Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10756 A15, A16>::
10757operator=(const Variant16& rhs)
10758{
10759 Imp::operator=(static_cast<const Imp&>(rhs));
10760 return *this;
10761}
10762
10763template <class A1, class A2, class A3, class A4, class A5, class A6,
10764 class A7, class A8, class A9, class A10, class A11, class A12,
10765 class A13, class A14, class A15, class A16>
10766inline
10767Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10768 A15, A16>&
10769Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10770 A15, A16>::
10771operator=(bslmf::MovableRef<Variant16> rhs)
10772{
10773 Variant16& lvalue = rhs;
10774
10775 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10776 return *this;
10777}
10778
10779 // --------------------
10780 // class Variant17<...>
10781 // --------------------
10782
10783// CREATORS
10784template <class A1, class A2, class A3, class A4, class A5, class A6,
10785 class A7, class A8, class A9, class A10, class A11, class A12,
10786 class A13, class A14, class A15, class A16, class A17>
10787inline
10788Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10789 A15, A16, A17>::
10790Variant17()
10791{
10792}
10793
10794template <class A1, class A2, class A3, class A4, class A5, class A6,
10795 class A7, class A8, class A9, class A10, class A11, class A12,
10796 class A13, class A14, class A15, class A16, class A17>
10797template <class TYPE_OR_ALLOCATOR>
10798inline
10799Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10800 A15, A16, A17>::
10801Variant17(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10802: Imp(valueOrAllocator)
10803{
10804}
10805
10806template <class A1, class A2, class A3, class A4, class A5, class A6,
10807 class A7, class A8, class A9, class A10, class A11, class A12,
10808 class A13, class A14, class A15, class A16, class A17>
10809template <class TYPE>
10810inline
10811Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10812 A15, A16, A17>::
10813Variant17(const TYPE& value, bslma::Allocator *basicAllocator)
10814: Imp(value, basicAllocator)
10815{
10816}
10817
10818template <class A1, class A2, class A3, class A4, class A5, class A6,
10819 class A7, class A8, class A9, class A10, class A11, class A12,
10820 class A13, class A14, class A15, class A16, class A17>
10821template <class TYPE>
10822inline
10823Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10824 A15, A16, A17>::
10825#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10826Variant17(TYPE&& value,
10827 typename bsl::enable_if<
10828 !bsl::is_same<
10829 SelfType,
10830 typename bsl::remove_const<
10831 typename bsl::remove_reference<TYPE>::type>::type>::value
10832 &&
10834 void>::type *)
10835: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10836#else
10837Variant17(bslmf::MovableRef<TYPE> value)
10838: Imp(MoveUtil::move(value))
10839#endif
10840{
10841}
10842
10843template <class A1, class A2, class A3, class A4, class A5, class A6,
10844 class A7, class A8, class A9, class A10, class A11, class A12,
10845 class A13, class A14, class A15, class A16, class A17>
10846template <class TYPE>
10847inline
10848Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10849 A15, A16, A17>::
10850#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10851Variant17(TYPE&& value,
10852 typename bsl::enable_if<
10853 !bsl::is_same<
10854 SelfType,
10855 typename bsl::remove_const<
10856 typename bsl::remove_reference<TYPE>::type>::type>::value,
10857 bslma::Allocator>::type *basicAllocator)
10858: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10859#else
10860Variant17(bslmf::MovableRef<TYPE> value,
10861 bslma::Allocator *basicAllocator)
10862: Imp(MoveUtil::move(value), basicAllocator)
10863#endif
10864{
10865}
10866
10867template <class A1, class A2, class A3, class A4, class A5, class A6,
10868 class A7, class A8, class A9, class A10, class A11, class A12,
10869 class A13, class A14, class A15, class A16, class A17>
10870inline
10871Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10872 A15, A16, A17>::
10873Variant17(const Variant17& original, bslma::Allocator *basicAllocator)
10874: Imp(static_cast<const Imp&>(original), basicAllocator)
10875{
10876}
10877
10878template <class A1, class A2, class A3, class A4, class A5, class A6,
10879 class A7, class A8, class A9, class A10, class A11, class A12,
10880 class A13, class A14, class A15, class A16, class A17>
10881inline
10882Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10883 A15, A16, A17>::
10884Variant17(bslmf::MovableRef<Variant17> original)
10885: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10886{
10887}
10888
10889template <class A1, class A2, class A3, class A4, class A5, class A6,
10890 class A7, class A8, class A9, class A10, class A11, class A12,
10891 class A13, class A14, class A15, class A16, class A17>
10892inline
10893Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10894 A15, A16, A17>::
10895Variant17(bslmf::MovableRef<Variant17> original,
10896 bslma::Allocator *basicAllocator)
10897: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10898 basicAllocator)
10899{
10900}
10901
10902// MANIPULATORS
10903template <class A1, class A2, class A3, class A4, class A5, class A6,
10904 class A7, class A8, class A9, class A10, class A11, class A12,
10905 class A13, class A14, class A15, class A16, class A17>
10906template <class TYPE>
10907inline
10908Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10909 A15, A16, A17>&
10910Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10911 A15, A16, A17>::
10912operator=(const TYPE& value)
10913{
10914 Imp::operator=(value);
10915 return *this;
10916}
10917
10918template <class A1, class A2, class A3, class A4, class A5, class A6,
10919 class A7, class A8, class A9, class A10, class A11, class A12,
10920 class A13, class A14, class A15, class A16, class A17>
10921template <class TYPE>
10922inline
10923#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10924typename bsl::enable_if<
10925 !bsl::is_same<Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
10926 A12, A13, A14, A15, A16, A17>,
10927 typename bsl::remove_cvref<TYPE>::type>::value,
10928Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10929 A16, A17> >::type&
10930Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10931 A16, A17>::operator=(TYPE&& value)
10932#else
10933Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10934 A16, A17>&
10935Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10936 A16, A17>::operator=(bslmf::MovableRef<TYPE> value)
10937#endif
10938{
10939#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10940 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10941#else
10942 TYPE& lvalue = value;
10943 Imp::operator=(MoveUtil::move(lvalue));
10944#endif
10945
10946 return *this;
10947}
10948
10949template <class A1, class A2, class A3, class A4, class A5, class A6,
10950 class A7, class A8, class A9, class A10, class A11, class A12,
10951 class A13, class A14, class A15, class A16, class A17>
10952inline
10953Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10954 A15, A16, A17>&
10955Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10956 A15, A16, A17>::
10957operator=(const Variant17& rhs)
10958{
10959 Imp::operator=(static_cast<const Imp&>(rhs));
10960 return *this;
10961}
10962
10963template <class A1, class A2, class A3, class A4, class A5, class A6,
10964 class A7, class A8, class A9, class A10, class A11, class A12,
10965 class A13, class A14, class A15, class A16, class A17>
10966inline
10967Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10968 A15, A16, A17>&
10969Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10970 A15, A16, A17>::
10971operator=(bslmf::MovableRef<Variant17> rhs)
10972{
10973 Variant17& lvalue = rhs;
10974
10975 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10976 return *this;
10977}
10978
10979 // --------------------
10980 // class Variant18<...>
10981 // --------------------
10982
10983// CREATORS
10984template <class A1, class A2, class A3, class A4, class A5, class A6,
10985 class A7, class A8, class A9, class A10, class A11, class A12,
10986 class A13, class A14, class A15, class A16, class A17, class A18>
10987inline
10988Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10989 A15, A16, A17, A18>::
10990Variant18()
10991{
10992}
10993
10994template <class A1, class A2, class A3, class A4, class A5, class A6,
10995 class A7, class A8, class A9, class A10, class A11, class A12,
10996 class A13, class A14, class A15, class A16, class A17, class A18>
10997template <class TYPE_OR_ALLOCATOR>
10998inline
10999Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11000 A15, A16, A17, A18>::
11001Variant18(const TYPE_OR_ALLOCATOR& valueOrAllocator)
11002: Imp(valueOrAllocator)
11003{
11004}
11005
11006template <class A1, class A2, class A3, class A4, class A5, class A6,
11007 class A7, class A8, class A9, class A10, class A11, class A12,
11008 class A13, class A14, class A15, class A16, class A17, class A18>
11009template <class TYPE>
11010inline
11011Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11012 A15, A16, A17, A18>::
11013Variant18(const TYPE& value, bslma::Allocator *basicAllocator)
11014: Imp(value, basicAllocator)
11015{
11016}
11017
11018template <class A1, class A2, class A3, class A4, class A5, class A6,
11019 class A7, class A8, class A9, class A10, class A11, class A12,
11020 class A13, class A14, class A15, class A16, class A17, class A18>
11021template <class TYPE>
11022inline
11023Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11024 A15, A16, A17, A18>::
11025#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11026Variant18(TYPE&& value,
11027 typename bsl::enable_if<
11028 !bsl::is_same<
11029 SelfType,
11030 typename bsl::remove_const<
11031 typename bsl::remove_reference<TYPE>::type>::type>::value
11032 &&
11034 void>::type *)
11035: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
11036#else
11037Variant18(bslmf::MovableRef<TYPE> value)
11038: Imp(MoveUtil::move(value))
11039#endif
11040{
11041}
11042
11043template <class A1, class A2, class A3, class A4, class A5, class A6,
11044 class A7, class A8, class A9, class A10, class A11, class A12,
11045 class A13, class A14, class A15, class A16, class A17, class A18>
11046template <class TYPE>
11047inline
11048Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11049 A15, A16, A17, A18>::
11050#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11051Variant18(TYPE&& value,
11052 typename bsl::enable_if<
11053 !bsl::is_same<
11054 SelfType,
11055 typename bsl::remove_const<
11056 typename bsl::remove_reference<TYPE>::type>::type>::value,
11057 bslma::Allocator>::type *basicAllocator)
11058: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
11059#else
11060Variant18(bslmf::MovableRef<TYPE> value,
11061 bslma::Allocator *basicAllocator)
11062: Imp(MoveUtil::move(value), basicAllocator)
11063#endif
11064{
11065}
11066
11067template <class A1, class A2, class A3, class A4, class A5, class A6,
11068 class A7, class A8, class A9, class A10, class A11, class A12,
11069 class A13, class A14, class A15, class A16, class A17, class A18>
11070inline
11071Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11072 A15, A16, A17, A18>::
11073Variant18(const Variant18& original, bslma::Allocator *basicAllocator)
11074: Imp(static_cast<const Imp&>(original), basicAllocator)
11075{
11076}
11077
11078template <class A1, class A2, class A3, class A4, class A5, class A6,
11079 class A7, class A8, class A9, class A10, class A11, class A12,
11080 class A13, class A14, class A15, class A16, class A17, class A18>
11081inline
11082Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11083 A15, A16, A17, A18>::
11084Variant18(bslmf::MovableRef<Variant18> original)
11085: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
11086{
11087}
11088
11089template <class A1, class A2, class A3, class A4, class A5, class A6,
11090 class A7, class A8, class A9, class A10, class A11, class A12,
11091 class A13, class A14, class A15, class A16, class A17, class A18>
11092inline
11093Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11094 A15, A16, A17, A18>::
11095Variant18(bslmf::MovableRef<Variant18> original,
11096 bslma::Allocator *basicAllocator)
11097: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
11098 basicAllocator)
11099{
11100}
11101
11102// MANIPULATORS
11103template <class A1, class A2, class A3, class A4, class A5, class A6,
11104 class A7, class A8, class A9, class A10, class A11, class A12,
11105 class A13, class A14, class A15, class A16, class A17, class A18>
11106template <class TYPE>
11107inline
11108Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11109 A15, A16, A17, A18>&
11110Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11111 A15, A16, A17, A18>::
11112operator=(const TYPE& value)
11113{
11114 Imp::operator=(value);
11115 return *this;
11116}
11117
11118template <class A1, class A2, class A3, class A4, class A5, class A6,
11119 class A7, class A8, class A9, class A10, class A11, class A12,
11120 class A13, class A14, class A15, class A16, class A17, class A18>
11121template <class TYPE>
11122inline
11123#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11124typename bsl::enable_if<
11125 !bsl::is_same<Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
11126 A11, A12, A13, A14, A15, A16, A17, A18>,
11127 typename bsl::remove_cvref<TYPE>::type>::value,
11128Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11129 A16, A17, A18> >::type&
11130Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11131 A16, A17, A18>::operator=(TYPE&& value)
11132#else
11133Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11134 A16, A17, A18>&
11135Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11136 A16, A17, A18>::operator=(bslmf::MovableRef<TYPE> value)
11137#endif
11138{
11139#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11140 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
11141#else
11142 TYPE& lvalue = value;
11143 Imp::operator=(MoveUtil::move(lvalue));
11144#endif
11145
11146 return *this;
11147}
11148
11149template <class A1, class A2, class A3, class A4, class A5, class A6,
11150 class A7, class A8, class A9, class A10, class A11, class A12,
11151 class A13, class A14, class A15, class A16, class A17, class A18>
11152inline
11153Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11154 A15, A16, A17, A18>&
11155Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11156 A15, A16, A17, A18>::
11157operator=(const Variant18& rhs)
11158{
11159 Imp::operator=(static_cast<const Imp&>(rhs));
11160 return *this;
11161}
11162
11163template <class A1, class A2, class A3, class A4, class A5, class A6,
11164 class A7, class A8, class A9, class A10, class A11, class A12,
11165 class A13, class A14, class A15, class A16, class A17, class A18>
11166inline
11167Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11168 A15, A16, A17, A18>&
11169Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11170 A15, A16, A17, A18>::
11171operator=(bslmf::MovableRef<Variant18> rhs)
11172{
11173 Variant18& lvalue = rhs;
11174
11175 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
11176 return *this;
11177}
11178
11179 // --------------------
11180 // class Variant19<...>
11181 // --------------------
11182
11183// CREATORS
11184template <class A1, class A2, class A3, class A4, class A5, class A6,
11185 class A7, class A8, class A9, class A10, class A11, class A12,
11186 class A13, class A14, class A15, class A16, class A17, class A18,
11187 class A19>
11188inline
11189Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11190 A15, A16, A17, A18, A19>::
11191Variant19()
11192{
11193}
11194
11195template <class A1, class A2, class A3, class A4, class A5, class A6,
11196 class A7, class A8, class A9, class A10, class A11, class A12,
11197 class A13, class A14, class A15, class A16, class A17, class A18,
11198 class A19>
11199template <class TYPE_OR_ALLOCATOR>
11200inline
11201Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11202 A15, A16, A17, A18, A19>::
11203Variant19(const TYPE_OR_ALLOCATOR& valueOrAllocator)
11204: Imp(valueOrAllocator)
11205{
11206}
11207
11208template <class A1, class A2, class A3, class A4, class A5, class A6,
11209 class A7, class A8, class A9, class A10, class A11, class A12,
11210 class A13, class A14, class A15, class A16, class A17, class A18,
11211 class A19>
11212template <class TYPE>
11213inline
11214Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11215 A15, A16, A17, A18, A19>::
11216Variant19(const TYPE& value, bslma::Allocator *basicAllocator)
11217: Imp(value, basicAllocator)
11218{
11219}
11220
11221template <class A1, class A2, class A3, class A4, class A5, class A6,
11222 class A7, class A8, class A9, class A10, class A11, class A12,
11223 class A13, class A14, class A15, class A16, class A17, class A18,
11224 class A19>
11225template <class TYPE>
11226inline
11227Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11228 A15, A16, A17, A18, A19>::
11229#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11230Variant19(TYPE&& value,
11231 typename bsl::enable_if<
11232 !bsl::is_same<
11233 SelfType,
11234 typename bsl::remove_const<
11235 typename bsl::remove_reference<TYPE>::type>::type>::value
11236 &&
11238 void>::type *)
11239: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
11240#else
11241Variant19(bslmf::MovableRef<TYPE> value)
11242: Imp(MoveUtil::move(value))
11243#endif
11244{
11245}
11246
11247template <class A1, class A2, class A3, class A4, class A5, class A6,
11248 class A7, class A8, class A9, class A10, class A11, class A12,
11249 class A13, class A14, class A15, class A16, class A17, class A18,
11250 class A19>
11251template <class TYPE>
11252inline
11253Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11254 A15, A16, A17, A18, A19>::
11255#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11256Variant19(TYPE&& value,
11257 typename bsl::enable_if<
11258 !bsl::is_same<
11259 SelfType,
11260 typename bsl::remove_const<
11261 typename bsl::remove_reference<TYPE>::type>::type>::value,
11262 bslma::Allocator>::type *basicAllocator)
11263: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
11264#else
11265Variant19(bslmf::MovableRef<TYPE> value,
11266 bslma::Allocator *basicAllocator)
11267: Imp(MoveUtil::move(value), basicAllocator)
11268#endif
11269{
11270}
11271
11272template <class A1, class A2, class A3, class A4, class A5, class A6,
11273 class A7, class A8, class A9, class A10, class A11, class A12,
11274 class A13, class A14, class A15, class A16, class A17, class A18,
11275 class A19>
11276inline
11277Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11278 A15, A16, A17, A18, A19>::
11279Variant19(const Variant19& original, bslma::Allocator *basicAllocator)
11280: Imp(static_cast<const Imp&>(original), basicAllocator)
11281{
11282}
11283
11284template <class A1, class A2, class A3, class A4, class A5, class A6,
11285 class A7, class A8, class A9, class A10, class A11, class A12,
11286 class A13, class A14, class A15, class A16, class A17, class A18,
11287 class A19>
11288inline
11289Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11290 A15, A16, A17, A18, A19>::
11291Variant19(bslmf::MovableRef<Variant19> original)
11292: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
11293{
11294}
11295
11296template <class A1, class A2, class A3, class A4, class A5, class A6,
11297 class A7, class A8, class A9, class A10, class A11, class A12,
11298 class A13, class A14, class A15, class A16, class A17, class A18,
11299 class A19>
11300inline
11301Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11302 A15, A16, A17, A18, A19>::
11303Variant19(bslmf::MovableRef<Variant19> original,
11304 bslma::Allocator *basicAllocator)
11305: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
11306 basicAllocator)
11307{
11308}
11309
11310// MANIPULATORS
11311template <class A1, class A2, class A3, class A4, class A5, class A6,
11312 class A7, class A8, class A9, class A10, class A11, class A12,
11313 class A13, class A14, class A15, class A16, class A17, class A18,
11314 class A19>
11315template <class TYPE>
11316inline
11317Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11318 A15, A16, A17, A18, A19>&
11319Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11320 A15, A16, A17, A18, A19>::
11321operator=(const TYPE& value)
11322{
11323 Imp::operator=(value);
11324 return *this;
11325}
11326
11327template <class A1, class A2, class A3, class A4, class A5, class A6,
11328 class A7, class A8, class A9, class A10, class A11, class A12,
11329 class A13, class A14, class A15, class A16, class A17, class A18,
11330 class A19>
11331template <class TYPE>
11332inline
11333#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11334typename bsl::enable_if<
11335 !bsl::is_same<Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
11336 A11, A12, A13, A14, A15, A16, A17, A18, A19>,
11337 typename bsl::remove_cvref<TYPE>::type>::value,
11338Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11339 A16, A17, A18, A19> >::type&
11340Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11341 A16, A17, A18, A19>::operator=(TYPE&& value)
11342#else
11343Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11344 A16, A17, A18, A19>&
11345Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11346 A16, A17, A18, A19>::operator=(bslmf::MovableRef<TYPE> value)
11347#endif
11348{
11349#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11350 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
11351#else
11352 TYPE& lvalue = value;
11353 Imp::operator=(MoveUtil::move(lvalue));
11354#endif
11355
11356 return *this;
11357}
11358
11359template <class A1, class A2, class A3, class A4, class A5, class A6,
11360 class A7, class A8, class A9, class A10, class A11, class A12,
11361 class A13, class A14, class A15, class A16, class A17, class A18,
11362 class A19>
11363inline
11364Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11365 A15, A16, A17, A18, A19>&
11366Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11367 A15, A16, A17, A18, A19>::
11368operator=(const Variant19& rhs)
11369{
11370 Imp::operator=(static_cast<const Imp&>(rhs));
11371 return *this;
11372}
11373
11374template <class A1, class A2, class A3, class A4, class A5, class A6,
11375 class A7, class A8, class A9, class A10, class A11, class A12,
11376 class A13, class A14, class A15, class A16, class A17, class A18,
11377 class A19>
11378inline
11379Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11380 A15, A16, A17, A18, A19>&
11381Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11382 A15, A16, A17, A18, A19>::
11383operator=(bslmf::MovableRef<Variant19> rhs)
11384{
11385 Variant19& lvalue = rhs;
11386
11387 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
11388 return *this;
11389}
11390
11391} // close package namespace
11392
11393
11394#endif // End C++11 code
11395
11396#endif
11397
11398// ----------------------------------------------------------------------------
11399// Copyright 2015 Bloomberg Finance L.P.
11400//
11401// Licensed under the Apache License, Version 2.0 (the "License");
11402// you may not use this file except in compliance with the License.
11403// You may obtain a copy of the License at
11404//
11405// http://www.apache.org/licenses/LICENSE-2.0
11406//
11407// Unless required by applicable law or agreed to in writing, software
11408// distributed under the License is distributed on an "AS IS" BASIS,
11409// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11410// See the License for the specific language governing permissions and
11411// limitations under the License.
11412// ----------------------------- END-OF-FILE ----------------------------------
11413
11414/** @} */
11415/** @} */
11416/** @} */
Definition bdlb_variant.h:4083
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant10, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant10, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant10 & operator=(const TYPE &value)
Variant10 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant10, HasPrintMethod)
Variant10()
Definition bdlb_variant.h:9522
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant10, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Definition bdlb_variant.h:4271
Variant11 & operator=(const TYPE &value)
Variant11()
Definition bdlb_variant.h:9693
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant11, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant11, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant11 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant11, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant11, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Definition bdlb_variant.h:4460
BSLMF_NESTED_TRAIT_DECLARATION(Variant12, HasPrintMethod)
Variant12 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant12, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant12()
Definition bdlb_variant.h:9864
Variant12 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant12, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant12, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Definition bdlb_variant.h:4650
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant13, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant13()
Definition bdlb_variant.h:10036
Variant13 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant13, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION(Variant13, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant13, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant13 & operator=(bslmf::MovableRef< TYPE > value)
Definition bdlb_variant.h:4842
Variant14 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant14, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant14, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant14 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant14, HasPrintMethod)
Variant14()
Definition bdlb_variant.h:10220
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant14, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Definition bdlb_variant.h:5035
BSLMF_NESTED_TRAIT_DECLARATION(Variant15, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant15, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant15 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant15, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant15()
Definition bdlb_variant.h:10404
Variant15 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant15, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Definition bdlb_variant.h:5229
BSLMF_NESTED_TRAIT_DECLARATION(Variant16, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant16, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant16 & operator=(const TYPE &value)
Variant16 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant16, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant16, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Definition bdlb_variant.h:5423
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant17, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant17 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant17, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant17, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION(Variant17, HasPrintMethod)
Variant17 & operator=(bslmf::MovableRef< TYPE > value)
Definition bdlb_variant.h:5617
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant18, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant18, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION(Variant18, HasPrintMethod)
Variant18 & operator=(bslmf::MovableRef< TYPE > value)
Variant18 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant18, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Definition bdlb_variant.h:5812
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant19, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant19 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant19, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant19 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant19, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION(Variant19, HasPrintMethod)
Definition bdlb_variant.h:2592
BSLMF_NESTED_TRAIT_DECLARATION(Variant2, HasPrintMethod)
Variant2()
Definition bdlb_variant.h:8265
Variant2 & operator=(const TYPE &value)
Variant2 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant2, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant2, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant2, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Definition bdlb_variant.h:2777
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant3, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant3 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant3, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant3 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant3, HasPrintMethod)
Variant3()
Definition bdlb_variant.h:8415
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant3, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Definition bdlb_variant.h:2963
Variant4 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant4, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant4, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant4, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant4()
Definition bdlb_variant.h:8568
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant4, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant4 & operator=(bslmf::MovableRef< TYPE > value)
Definition bdlb_variant.h:3149
Variant5()
Definition bdlb_variant.h:8721
Variant5 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant5, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION(Variant5, HasPrintMethod)
Variant5 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant5, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant5, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Definition bdlb_variant.h:3335
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant6, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant6 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant6, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant6()
Definition bdlb_variant.h:8874
Variant6 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION(Variant6, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant6, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Definition bdlb_variant.h:3522
BSLMF_NESTED_TRAIT_DECLARATION(Variant7, HasPrintMethod)
Variant7 & operator=(const TYPE &value)
Variant7 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant7, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant7, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant7, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant7()
Definition bdlb_variant.h:9027
Definition bdlb_variant.h:3709
Variant8()
Definition bdlb_variant.h:9183
Variant8 & operator=(bslmf::MovableRef< TYPE > value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant8, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
BSLMF_NESTED_TRAIT_DECLARATION(Variant8, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant8, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant8, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant8 & operator=(const TYPE &value)
Definition bdlb_variant.h:3896
Variant9 & operator=(bslmf::MovableRef< TYPE > value)
Variant9()
Definition bdlb_variant.h:9352
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant9, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant9 & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant9, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant9, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
BSLMF_NESTED_TRAIT_DECLARATION(Variant9, HasPrintMethod)
Definition bdlb_variant.h:824
TYPES TypeList
Definition bdlb_variant.h:831
bslmf::TypeListTypeOf< 20, TYPES >::TypeOrDefault Type20
Definition bdlb_variant.h:856
bslmf::TypeListTypeOf< 10, TYPES >::TypeOrDefault Type10
Definition bdlb_variant.h:842
bslmf::TypeListTypeOf< 2, TYPES >::TypeOrDefault Type2
Definition bdlb_variant.h:834
bslmf::TypeListTypeOf< 8, TYPES >::TypeOrDefault Type8
Definition bdlb_variant.h:840
bslmf::TypeListTypeOf< 15, TYPES >::TypeOrDefault Type15
Definition bdlb_variant.h:847
bslmf::TypeListTypeOf< 14, TYPES >::TypeOrDefault Type14
Definition bdlb_variant.h:846
bslmf::TypeListTypeOf< 9, TYPES >::TypeOrDefault Type9
Definition bdlb_variant.h:841
BSLMF_NESTED_TRAIT_DECLARATION(VariantImp_AllocatorBase, bslma::UsesBslmaAllocator)
bslmf::TypeListTypeOf< 4, TYPES >::TypeOrDefault Type4
Definition bdlb_variant.h:836
bslmf::TypeListTypeOf< 7, TYPES >::TypeOrDefault Type7
Definition bdlb_variant.h:839
friend bool operator==(const VariantImp< VARIANT_TYPES > &, const VariantImp< VARIANT_TYPES > &)
bslmf::TypeListTypeOf< 6, TYPES >::TypeOrDefault Type6
Definition bdlb_variant.h:838
bslmf::TypeListTypeOf< 12, TYPES >::TypeOrDefault Type12
Definition bdlb_variant.h:844
bslmf::TypeListTypeOf< 11, TYPES >::TypeOrDefault Type11
Definition bdlb_variant.h:843
bslmf::TypeListTypeOf< 5, TYPES >::TypeOrDefault Type5
Definition bdlb_variant.h:837
bslmf::TypeListTypeOf< 16, TYPES >::TypeOrDefault Type16
Definition bdlb_variant.h:848
bslmf::TypeListTypeOf< 13, TYPES >::TypeOrDefault Type13
Definition bdlb_variant.h:845
bslma::Allocator * getAllocator() const
Return the allocator used by this object to supply memory.
Definition bdlb_variant.h:6507
bslmf::TypeListTypeOf< 18, TYPES >::TypeOrDefault Type18
Definition bdlb_variant.h:850
bslmf::TypeListTypeOf< 3, TYPES >::TypeOrDefault Type3
Definition bdlb_variant.h:835
bslmf::TypeListTypeOf< 19, TYPES >::TypeOrDefault Type19
Definition bdlb_variant.h:851
bslmf::TypeListTypeOf< 1, TYPES >::TypeOrDefault Type1
Definition bdlb_variant.h:833
VariantImp_AllocatorBase(int type, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:6478
bslmf::TypeListTypeOf< 17, TYPES >::TypeOrDefault Type17
Definition bdlb_variant.h:849
Definition bdlb_variant.h:939
bslma::Allocator * getAllocator() const
Definition bdlb_variant.h:6546
bslmf::TypeListTypeOf< 17, TYPES >::TypeOrDefault Type17
Definition bdlb_variant.h:964
bslmf::TypeListTypeOf< 6, TYPES >::TypeOrDefault Type6
Definition bdlb_variant.h:953
bslmf::TypeListTypeOf< 4, TYPES >::TypeOrDefault Type4
Definition bdlb_variant.h:951
friend bool operator==(const VariantImp< VARIANT_TYPES > &, const VariantImp< VARIANT_TYPES > &)
bslmf::TypeListTypeOf< 8, TYPES >::TypeOrDefault Type8
Definition bdlb_variant.h:955
bslmf::TypeListTypeOf< 14, TYPES >::TypeOrDefault Type14
Definition bdlb_variant.h:961
bslmf::TypeListTypeOf< 1, TYPES >::TypeOrDefault Type1
Definition bdlb_variant.h:948
bslmf::TypeListTypeOf< 18, TYPES >::TypeOrDefault Type18
Definition bdlb_variant.h:965
bslmf::TypeListTypeOf< 10, TYPES >::TypeOrDefault Type10
Definition bdlb_variant.h:957
bslmf::TypeListTypeOf< 15, TYPES >::TypeOrDefault Type15
Definition bdlb_variant.h:962
bslmf::TypeListTypeOf< 2, TYPES >::TypeOrDefault Type2
Definition bdlb_variant.h:949
bslmf::TypeListTypeOf< 20, TYPES >::TypeOrDefault Type20
Definition bdlb_variant.h:971
bslmf::TypeListTypeOf< 7, TYPES >::TypeOrDefault Type7
Definition bdlb_variant.h:954
bslmf::TypeListTypeOf< 16, TYPES >::TypeOrDefault Type16
Definition bdlb_variant.h:963
bslmf::TypeListTypeOf< 12, TYPES >::TypeOrDefault Type12
Definition bdlb_variant.h:959
bslmf::TypeListTypeOf< 19, TYPES >::TypeOrDefault Type19
Definition bdlb_variant.h:966
bslmf::TypeListTypeOf< 3, TYPES >::TypeOrDefault Type3
Definition bdlb_variant.h:950
bslmf::TypeListTypeOf< 9, TYPES >::TypeOrDefault Type9
Definition bdlb_variant.h:956
TYPES TypeList
Definition bdlb_variant.h:946
bslmf::TypeListTypeOf< 13, TYPES >::TypeOrDefault Type13
Definition bdlb_variant.h:960
bslmf::TypeListTypeOf< 11, TYPES >::TypeOrDefault Type11
Definition bdlb_variant.h:958
bslmf::TypeListTypeOf< 5, TYPES >::TypeOrDefault Type5
Definition bdlb_variant.h:952
VariantImp_NoAllocatorBase(int type, bslma::Allocator *)
Definition bdlb_variant.h:6520
Definition bdlb_variant.h:1225
void reset()
Definition bdlb_variant.h:7592
STREAM & bdexStreamIn(STREAM &stream, int version)
DEPRECATED: Do not use.
Definition bdlb_variant.h:7781
VariantImp(const VariantImp &original, bslma::Allocator *basicAllocator=0)
Definition bdlb_variant.h:7295
VariantImp & operator=(bslmf::MovableRef< TYPE > value)
RET_TYPE apply(VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:7457
BSLMF_NESTED_TRAIT_DECLARATION_IF(VariantImp, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw(const VISITOR &visitor) const
Definition bdlb_variant.h:2240
RET_TYPE applyRaw(VISITOR &visitor) const
Definition bdlb_variant.h:7705
VariantImp(const TYPE &value, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:7203
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(const VISITOR &visitor) const
Definition bdlb_variant.h:1969
bool is() const
Definition bdlb_variant.h:7725
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw(const VISITOR &visitor) const
Definition bdlb_variant.h:2197
VariantImp & operator=(const VariantImp &rhs)
Definition bdlb_variant.h:7375
~VariantImp()
Definition bdlb_variant.h:7336
int typeIndex() const
Definition bdlb_variant.h:7766
RET_TYPE apply(VISITOR &visitor) const
Definition bdlb_variant.h:7651
RET_TYPE applyRaw(VISITOR &visitor)
Definition bdlb_variant.h:7483
VariantImp()
Definition bdlb_variant.h:7178
const bsl::type_info & typeInfo() const
Definition bdlb_variant.h:7774
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(VISITOR &visitor) const
Definition bdlb_variant.h:1945
RET_TYPE applyRaw(const VISITOR &visitor)
Definition bdlb_variant.h:7493
RET_TYPE apply(VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:7678
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(VISITOR &visitor)
Definition bdlb_variant.h:1544
VariantImp(bslmf::MovableRef< TYPE > value)
Definition bdlb_variant.h:7229
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:1598
TYPE & createInPlace(ARGS &&... arguments)
Definition bdlb_variant.h:7574
VariantImp & assign(bslmf::MovableRef< TYPE > value)
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:1998
RET_TYPE applyRaw(const VISITOR &visitor) const
Definition bdlb_variant.h:7715
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(const VISITOR &visitor)
Definition bdlb_variant.h:1672
VariantImp(bslmf::MovableRef< VariantImp > original, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:7321
RET_TYPE apply(const VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:7691
VariantImp & operator=(const TYPE &value)
STREAM & bdexStreamOut(STREAM &stream, int version) const
DEPRECATED: Do not use.
Definition bdlb_variant.h:7819
RET_TYPE apply(VISITOR &visitor)
Definition bdlb_variant.h:7430
VariantImp(const TYPE_OR_ALLOCATOR &valueOrAllocator)
Definition bdlb_variant.h:7186
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:1700
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw(const VISITOR &visitor)
Definition bdlb_variant.h:1801
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw(VISITOR &visitor)
Definition bdlb_variant.h:1777
int maxSupportedBdexVersion() const
DEPRECATED: Do not use.
Definition bdlb_variant.h:7812
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw(VISITOR &visitor) const
Definition bdlb_variant.h:2220
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(const VISITOR &visitor) const
Definition bdlb_variant.h:2072
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(const VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:1626
BSLMF_NESTED_TRAIT_DECLARATION(VariantImp, HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION_IF(VariantImp, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
bool isUnset() const
Definition bdlb_variant.h:7732
TYPE & the()
Definition bdlb_variant.h:7637
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(VISITOR &visitor)
Definition bdlb_variant.h:1649
RET_TYPE apply(const VISITOR &visitor)
Definition bdlb_variant.h:7443
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:2100
const TYPE & the() const
Definition bdlb_variant.h:7754
VariantImp & assign(const TYPE &value)
void swap(VariantImp &other)
Definition bdlb_variant.h:7602
VariantImp(bslmf::MovableRef< TYPE > value, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:7267
VariantImp(bslmf::MovableRef< VariantImp > original)
Definition bdlb_variant.h:7307
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(const VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:2026
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw(VISITOR &visitor) const
Definition bdlb_variant.h:2174
VariantImp & assignTo(const SOURCE_TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(VariantImp, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
RET_TYPE apply(const VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:7469
RET_TYPE apply(const VISITOR &visitor) const
Definition bdlb_variant.h:7664
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw(VISITOR &visitor)
Definition bdlb_variant.h:1824
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw(const VISITOR &visitor)
Definition bdlb_variant.h:1844
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply(const VISITOR &visitor)
Definition bdlb_variant.h:1569
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(VISITOR &visitor) const
Definition bdlb_variant.h:2049
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlb_variant.h:7739
VariantImp & operator=(bslmf::MovableRef< VariantImp > rhs)
Definition bdlb_variant.h:7401
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(const VISITOR &visitor, const TYPE &defaultValue)
Definition bdlb_variant.h:1727
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply(const VISITOR &visitor, const TYPE &defaultValue) const
Definition bdlb_variant.h:2127
Definition bdlb_variant.h:1164
RESULT_TYPE operator()(ARGUMENT_TYPE &argument)
Definition bdlb_variant.h:6570
Variant_RawVisitorHelper(VISITOR *visitor)
Definition bdlb_variant.h:6559
Definition bdlb_variant.h:2389
Variant(bslmf::MovableRef< Variant > original, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:8158
Variant & operator=(const Variant &rhs)
Definition bdlb_variant.h:8223
BSLMF_NESTED_TRAIT_DECLARATION(Variant, HasPrintMethod)
Variant(const TYPE &value, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:8067
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
Variant(bslmf::MovableRef< TYPE > value, bslma::Allocator *basicAllocator)
Definition bdlb_variant.h:8118
Variant & operator=(bslmf::MovableRef< Variant > rhs)
Definition bdlb_variant.h:8241
Variant & operator=(const TYPE &value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
Variant()
Definition bdlb_variant.h:8043
Variant(const TYPE_OR_ALLOCATOR &valueOrAllocator)
Definition bdlb_variant.h:8054
Variant(bslmf::MovableRef< TYPE > value)
Definition bdlb_variant.h:8094
Variant(const Variant &original, bslma::Allocator *basicAllocator=0)
Definition bdlb_variant.h:8131
BSLMF_NESTED_TRAIT_DECLARATION_IF(Variant, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
Variant(bslmf::MovableRef< Variant > original)
Definition bdlb_variant.h:8146
Variant & operator=(bslmf::MovableRef< TYPE > value)
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:182
Definition bslma_allocator.h:545
Definition bslmf_movableref.h:752
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_ASSERT_INVOKE_NORETURN(X)
Definition bsls_assert.h:2101
#define BSLS_ASSERT_UNREACHABLE(X)
Definition bsls_assert.h:1996
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
void reset(TYPE *object)
Reset the value of the specified object to its default value.
Definition bdlb_algorithmworkaroundutil.h:74
bool operator!=(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
char Variant_ReturnValueHelper_YesType
Definition bdlb_variant.h:775
bsl::ostream & operator<<(bsl::ostream &stream, const BigEndianInt16 &integer)
void swap(NullableAllocatedValue< TYPE > &a, NullableAllocatedValue< TYPE > &b)
bool operator==(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
Definition bdlat_valuetypefunctions.h:939
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
STREAM & bdexStreamIn(STREAM &stream, VALUE_TYPE &variable)
Definition bslx_instreamfunctions.h:1263
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:1004
Definition bdlb_printmethods.h:306
Definition bdlb_variant.h:1042
bslmf::TypeListTypeOf< 14, TYPES >::TypeOrDefault Type14
Definition bdlb_variant.h:1058
bsl::conditional< k_VARIANT_USES_BSLMA_ALLOCATOR, VariantImp_AllocatorBase< TYPES >, VariantImp_NoAllocatorBase< TYPES > >::type BaseType
Determines what the base type is.
Definition bdlb_variant.h:1143
bslmf::TypeListTypeOf< 7, TYPES >::TypeOrDefault Type7
Definition bdlb_variant.h:1051
bslmf::TypeListTypeOf< 12, TYPES >::TypeOrDefault Type12
Definition bdlb_variant.h:1056
bslmf::TypeListTypeOf< 18, TYPES >::TypeOrDefault Type18
Definition bdlb_variant.h:1062
bslmf::TypeListTypeOf< 6, TYPES >::TypeOrDefault Type6
Definition bdlb_variant.h:1050
bslmf::TypeListTypeOf< 13, TYPES >::TypeOrDefault Type13
Definition bdlb_variant.h:1057
bslmf::TypeListTypeOf< 19, TYPES >::TypeOrDefault Type19
Definition bdlb_variant.h:1063
bslmf::TypeListTypeOf< 17, TYPES >::TypeOrDefault Type17
Definition bdlb_variant.h:1061
bslmf::TypeListTypeOf< 3, TYPES >::TypeOrDefault Type3
Definition bdlb_variant.h:1047
bslmf::TypeListTypeOf< 11, TYPES >::TypeOrDefault Type11
Definition bdlb_variant.h:1055
@ VARIANT_USES_BSLMA_ALLOCATOR
Definition bdlb_variant.h:1133
@ VARIANT_IS_BITWISE_COPYABLE
Definition bdlb_variant.h:1134
@ k_VARIANT_IS_BITWISE_MOVEABLE
Definition bdlb_variant.h:1111
@ VARIANT_IS_BITWISE_MOVEABLE
Definition bdlb_variant.h:1135
@ k_VARIANT_USES_BSLMA_ALLOCATOR
Definition bdlb_variant.h:1067
@ k_VARIANT_IS_BITWISE_COPYABLE
Definition bdlb_variant.h:1089
bslmf::TypeListTypeOf< 1, TYPES >::TypeOrDefault Type1
Definition bdlb_variant.h:1045
bslmf::TypeListTypeOf< 8, TYPES >::TypeOrDefault Type8
Definition bdlb_variant.h:1052
bslmf::TypeListTypeOf< 2, TYPES >::TypeOrDefault Type2
Definition bdlb_variant.h:1046
bslmf::TypeListTypeOf< 16, TYPES >::TypeOrDefault Type16
Definition bdlb_variant.h:1060
bslmf::TypeListTypeOf< 5, TYPES >::TypeOrDefault Type5
Definition bdlb_variant.h:1049
bslmf::TypeListTypeOf< 20, TYPES >::TypeOrDefault Type20
Definition bdlb_variant.h:1064
bslmf::TypeListTypeOf< 15, TYPES >::TypeOrDefault Type15
Definition bdlb_variant.h:1059
bslmf::TypeListTypeOf< 4, TYPES >::TypeOrDefault Type4
Definition bdlb_variant.h:1048
bslmf::TypeListTypeOf< 9, TYPES >::TypeOrDefault Type9
Definition bdlb_variant.h:1053
bslmf::TypeListTypeOf< 10, TYPES >::TypeOrDefault Type10
Definition bdlb_variant.h:1054
Definition bdlb_variant.h:6317
Variant_BdexStreamInVisitor(STREAM &stream, int version)
Definition bdlb_variant.h:6324
int d_version
Definition bdlb_variant.h:6321
STREAM & d_stream
Definition bdlb_variant.h:6320
void operator()(VALUETYPE &object) const
Definition bdlb_variant.h:6333
void operator()(bslmf::Nil) const
Definition bdlb_variant.h:6339
Definition bdlb_variant.h:6357
void operator()(bslmf::Nil) const
Definition bdlb_variant.h:6379
void operator()(const VALUETYPE &object) const
Definition bdlb_variant.h:6373
STREAM & d_stream
Definition bdlb_variant.h:6360
Variant_BdexStreamOutVisitor(STREAM &stream, int version)
Definition bdlb_variant.h:6364
int d_version
Definition bdlb_variant.h:6361
Definition bdlb_variant.h:6219
void operator()(const TYPE &value)
Definition bdlb_variant.h:6234
Variant_CopyAssignVisitor(void *buffer)
Definition bdlb_variant.h:6226
void * d_buffer_p
Definition bdlb_variant.h:6222
Definition bdlb_variant.h:6131
void * d_buffer_p
Definition bdlb_variant.h:6134
void operator()(const TYPE &value) const
Definition bdlb_variant.h:6147
Variant_CopyConstructVisitor(void *buffer, bslma::Allocator *allocator)
Definition bdlb_variant.h:6138
bslma::Allocator * d_allocator_p
Definition bdlb_variant.h:6135
Definition bdlb_variant.h:6101
Variant_DefaultConstructVisitor(bslma::Allocator *allocator)
Definition bdlb_variant.h:6108
void operator()(TYPE &value) const
Definition bdlb_variant.h:6115
bslma::Allocator * d_allocator_p
Definition bdlb_variant.h:6104
Definition bdlb_variant.h:6199
void operator()(TYPE &object) const
Definition bdlb_variant.h:6203
Definition bdlb_variant.h:6438
const void * d_buffer_p
Definition bdlb_variant.h:6442
void operator()(bslmf::Nil) const
Definition bdlb_variant.h:6460
void operator()(const TYPE &value) const
Definition bdlb_variant.h:6455
bool d_result
Definition bdlb_variant.h:6441
Variant_EqualityTestVisitor(const void *buffer)
Definition bdlb_variant.h:6446
Definition bdlb_variant.h:6250
void operator()(TYPE &value)
Definition bdlb_variant.h:6265
void * d_buffer_p
Definition bdlb_variant.h:6253
Variant_MoveAssignVisitor(void *buffer)
Definition bdlb_variant.h:6257
Definition bdlb_variant.h:6166
void operator()(TYPE &value) const
Definition bdlb_variant.h:6182
void * d_buffer_p
Definition bdlb_variant.h:6169
bslma::Allocator * d_allocator_p
Definition bdlb_variant.h:6170
Variant_MoveConstructVisitor(void *buffer, bslma::Allocator *allocator)
Definition bdlb_variant.h:6173
Definition bdlb_variant.h:6396
void operator()(bslmf::Nil) const
Definition bdlb_variant.h:6421
Variant_PrintVisitor(bsl::ostream *stream, int level, int spacesPerLevel)
Definition bdlb_variant.h:6404
bsl::ostream * d_stream_p
Definition bdlb_variant.h:6399
void operator()(const TYPE &value) const
Definition bdlb_variant.h:6416
int d_level
Definition bdlb_variant.h:6400
int d_spacesPerLevel
Definition bdlb_variant.h:6401
Definition bdlb_variant.h:787
static Variant_ReturnValueHelper_YesType match(typename bsl::remove_reference< typename T::ResultType >::type *)
static Variant_ReturnValueHelper_NoType match(...)
Definition bdlb_variant.h:776
Definition bdlb_variant.h:810
Definition bdlb_variant.h:6282
void * d_buffer_p
Definition bdlb_variant.h:6285
Variant_SwapVisitor(void *buffer)
Definition bdlb_variant.h:6289
void operator()(TYPE &value)
Definition bdlb_variant.h:6297
Definition bdlb_variant.h:6004
@ value
Definition bdlb_variant.h:6007
Definition bslmf_conditional.h:123
Definition bslmf_enableif.h:530
Definition bslmf_integralconstant.h:261
Definition bslmf_isconvertible.h:875
Definition bslmf_issame.h:146
Definition bslmf_removeconst.h:159
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removereference.h:156
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1244
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_movableref.h:795
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
Definition bslmf_nil.h:133
Definition bslmf_typelist.h:1872
Definition bslmf_typelist.h:1915
Definition bslmf_typelist.h:1961
Definition bslmf_typelist.h:2010
Definition bslmf_typelist.h:2062
Definition bslmf_typelist.h:2117
Definition bslmf_typelist.h:2175
Definition bslmf_typelist.h:2236
Definition bslmf_typelist.h:2300
Definition bslmf_typelist.h:2367
Definition bslmf_typelist.h:1701
Definition bslmf_typelist.h:1719
Definition bslmf_typelist.h:1736
Definition bslmf_typelist.h:1759
Definition bslmf_typelist.h:1784
Definition bslmf_typelist.h:1811
Definition bslmf_typelist.h:1840
Definition bslmf_typelist.h:1612
Definition bsls_objectbuffer.h:277