BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlb_variant_cpp03.h
Go to the documentation of this file.
1/// @file bdlb_variant_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlb_variant_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BDLB_VARIANT_CPP03
12#define INCLUDED_BDLB_VARIANT_CPP03
13
14/// @defgroup bdlb_variant_cpp03 bdlb_variant_cpp03
15/// @brief Provide C++03 implementation for bdlb_variant.h
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlb
19/// @{
20/// @addtogroup bdlb_variant_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlb_variant_cpp03-purpose"> Purpose</a>
25/// * <a href="#bdlb_variant_cpp03-classes"> Classes </a>
26/// * <a href="#bdlb_variant_cpp03-description"> Description </a>
27///
28/// # Purpose {#bdlb_variant_cpp03-purpose}
29/// Provide C++03 implementation for bdlb_variant.h
30///
31/// # Classes {#bdlb_variant_cpp03-classes}
32/// See bdlb_variant.h for list of classes
33///
34/// @see bdlb_variant
35///
36/// # Description {#bdlb_variant_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Mon Jan 12 21:03:10 2026
48/// Command line: sim_cpp11_features.pl bdlb_variant.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bdl
54 * @{
55 */
56/** @addtogroup bdlb
57 * @{
58 */
59/** @addtogroup bdlb_variant_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BDLB_VARIANT_H
64
65#if defined(BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES) \
66 && defined(BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES)
67///
68/// \note Note that this macro definition parallels that of a similar macro
69/// defined in `bslmf_typelist.h`.
70#define BDLB_VARIANT_USING_VARIADIC_TEMPLATES
71#endif
72
73
74namespace bdlb {
75
76struct Variant_CopyAssignVisitor;
77struct Variant_CopyConstructVisitor;
78struct Variant_DefaultConstructVisitor;
79struct Variant_DestructorVisitor;
80struct Variant_EqualityTestVisitor;
81struct Variant_MoveAssignVisitor;
82struct Variant_MoveConstructVisitor;
83struct Variant_PrintVisitor;
84
85template <class TYPES>
86class VariantImp;
87
88template <class TYPES, class TYPE>
89struct Variant_TypeIndex;
90
91 // ================================
92 // struct Variant_ReturnValueHelper
93 // ================================
94
95// These definitions are provided outside of 'Variant_ReturnValueHelper'
96// because of a bug in the IBM xlC compiler.
98typedef struct { char a[2]; } Variant_ReturnValueHelper_NoType;
99
101 != sizeof(Variant_ReturnValueHelper_NoType));
102
103/// This struct is a component-private struct. Do *not* use. This provides
104/// functions, the matching of which are used by Variant_ReturnValueHelper
105/// to determine whether the template parameter type `VISITOR` has the
106/// member `ResultType` defined.
107///
108/// See @ref bdlb_variant_cpp03
109struct Variant_ReturnValueHelper_Matcher {
110
111 /// Return `YesType` if `T::ResultType` exists, and `NoType` otherwise.
112 ///
113 /// \note Note that if `T::ResultType` exists, then the first function is a
114 /// better match than the ellipsis version.
115 template <class T>
118 template <class T>
119 static Variant_ReturnValueHelper_NoType match(...);
120};
121
122/// This struct is a component-private meta-function. Do *not* use. This
123/// meta-function checks whether the template parameter type `VISITOR` has
124/// the member `ResultType` defined using "SFINAE" (Substitution Failure Is
125/// Not An Error). A `value` of `true` indicates `VISITOR::ResultType`
126/// exists, and `false` otherwise.
127template <class VISITOR>
128struct Variant_ReturnValueHelper
130 bool,
131 sizeof(Variant_ReturnValueHelper_Matcher::match<VISITOR>(0)) ==
132 sizeof(Variant_ReturnValueHelper_YesType)> {
133};
134
135 // =====================================
136 // class VariantImp_AllocatorBase<TYPES>
137 // =====================================
138
139/// This class is component-private. Do not use. This class contains the
140/// `typedef`s and data members of the `Variant` class, and serves as the
141/// base class for the variant when any one of the types held by the variant
142/// has the `bslma::UsesBslmaAllocator` type trait.
143///
144/// See @ref bdlb_variant_cpp03
145template <class TYPES>
146class VariantImp_AllocatorBase {
147
148 public:
149 // TYPES
150
151 /// `TypeList` is an alias for the `bslmf::TypeList` type serving as the
152 /// template parameter to this variant implementation.
153 typedef TYPES TypeList;
154
174
175 /// `TypeN` is an alias for the `N`th type in the `TypeList` of this
176 /// variant implementation. If less than `N` template arguments were
177 /// given to the `Variant` type, then `TypeN` is `bslmf::Nil`.
179
180 private:
181 union Value {
202 };
203 // 'Value' is a union of 'bsls::ObjectBuffer' of all types contained by
204 // the variant. 'bsls::ObjectBuffer' is used to: 1) wrap non-POD types
205 // within the union, and 2) ensure proper alignment of the types.
206
207 // DATA
208 Value d_value; // value of the object, initialized by
209 // derived class
210
211 int d_type; // current type the variant is holding (0
212 // if unset)
213
214 bslma::Allocator *d_allocator_p; // pointer to allocator (held, not owned)
215
216 // FRIENDS
217 template <class VARIANT_TYPES>
218 friend class VariantImp;
219
220 template <class VARIANT_TYPES>
221 friend bool operator==(const VariantImp<VARIANT_TYPES>&,
222 const VariantImp<VARIANT_TYPES>&);
223
224 public:
225 // TRAITS
226 BSLMF_NESTED_TRAIT_DECLARATION(VariantImp_AllocatorBase,
228
229 // CREATORS
230 VariantImp_AllocatorBase(int type, bslma::Allocator *basicAllocator);
231
232 /// Create a `VariantImp_AllocatorBase` with the specified `type`
233 /// indicating the type of the object that the variant will initially
234 /// hold, and the specified `basicAllocator` to supply memory.
236 bslma::Allocator *basicAllocator,
238
239 template <class TYPE>
240 VariantImp_AllocatorBase(int type, const TYPE&, bsl::false_type);
241
242 // ACCESSORS
243
244 /// Return the allocator used by this object to supply memory.
246};
247
248 // =======================================
249 // class VariantImp_NoAllocatorBase<TYPES>
250 // =======================================
251
252/// This class is component-private. Do not use. This class contains the
253/// `typedef`s and data members of the `Variant` class, and serves as the
254/// base class for the variant when none of the types held by the variant
255/// has the `bslma::UsesBslmaAllocator` type trait. The goal is to optimize
256/// the size of the variant to avoid holding an unnecessary allocator
257/// pointer.
258///
259/// See @ref bdlb_variant_cpp03
260template <class TYPES>
261class VariantImp_NoAllocatorBase {
262
263 public:
264 // TYPES
265
266 /// `TypeList` is an alias for the `bslmf::TypeList` type serving as the
267 /// template parameter to this variant implementation.
268 typedef TYPES TypeList;
269
289
290 /// `TypeN` is an alias for the `N`th type in the `TypeList` of this
291 /// variant implementation. If less than `N` template arguments were
292 /// given to the `Variant` type, then `TypeN` is `bslmf::Nil`.
294
295 private:
296 union Value {
317 };
318 // 'Value' is a union of 'bsls::ObjectBuffer' of all types contained by
319 // the variant. 'bsls::ObjectBuffer' is used to: 1) wrap non-POD types
320 // within the union, and 2) ensure proper alignment of the types.
321
322 // DATA
323 Value d_value; // value of the object, initialized by derived class
324 int d_type; // current type the variant is holding (0 if unset)
325
326 // FRIENDS
327 template <class VARIANT_TYPES>
328 friend class VariantImp;
329
330 template <class VARIANT_TYPES>
331 friend bool operator==(const VariantImp<VARIANT_TYPES>&,
332 const VariantImp<VARIANT_TYPES>&);
333
334 public:
335 // CREATORS
337
338 /// Create a `VariantImp_NoAllocatorBase` with the specified `type`
339 /// indicating the type of the object that the variant will initially
340 /// hold.
342
343 template <class TYPE>
344 VariantImp_NoAllocatorBase(int type, const TYPE&, bsl::false_type);
345
346 // ACCESSORS
347
348 /// Return 0.
349 /// \note Note that this object does not hold an allocator pointer.
351};
352
353 // ========================
354 // struct VariantImp_Traits
355 // ========================
356
357/// This struct is component-private. Do not use. This meta-function
358/// selects `VariantImp_AllocatorBase` as a base class type if any one of
359/// the types held by a variant has the `bslma::UsesBslmaAllocator` trait,
360/// and `VariantImp_NoAllocatorBase` otherwise.
361///
362/// See @ref bdlb_variant_cpp03
363template <class TYPES>
364struct VariantImp_Traits {
365
366 // TYPES
387
388 enum {
410
432
454#ifndef BDE_OMIT_INTERNAL_DEPRECATED
458#endif // BDE_OMIT_INTERNAL_DEPRECATED
459 };
460
461 /// Determines what the base type is.
463 VariantImp_AllocatorBase<TYPES>,
464 VariantImp_NoAllocatorBase<TYPES> >::type
465 BaseType;
466};
467
468 // ==============================
469 // class Variant_RawVisitorHelper
470 // ==============================
471
472/// This `struct` provides a helper for implementing `Variant::applyRaw`
473/// that enables `applyRaw` to support visitor functors that do not provide
474/// an overload for `operator()(bslmf::Nil)`. Objects of this type are
475/// constructed using a functor of (template parameter) type `VISITOR`,
476/// whose `operator()` returns the (template parameter) type `RESULT_TYPE`.
477/// A `Variant_RawVisitorHelper` wraps a functor of type `VISITOR` and
478/// provides an implementation of `operator()(bslmf::Nil)` that performs a `BSLS_ASSERT_OPT(false)`.
479///
480/// \note Note that this overload is needed to enable
481/// compilation (specifically, to instantiate `doApply` and `doApplyR`), but
482/// is never invoked by any code path at runtime.
483///
484/// See @ref bdlb_variant_cpp03
485template <class RESULT_TYPE, class VISITOR>
486class Variant_RawVisitorHelper {
487
488 // DATA
489 VISITOR *d_visitor; // visitor to which this helper delegates
490
491 public:
492 // CREATORS
493
494 /// Create a `RawVisitorHelper` functor that delegates to the specified
495 /// `visitor`.
496 explicit
497 Variant_RawVisitorHelper(VISITOR *visitor);
498
499 // MANIPULATORS
500
501 /// Invoke the functor supplied at construction with the specified
502 /// `argument`, and return the result.
503 template <class ARGUMENT_TYPE>
504 RESULT_TYPE operator()(ARGUMENT_TYPE& argument);
505 template <class ARGUMENT_TYPE>
506 RESULT_TYPE operator()(const ARGUMENT_TYPE& argument);
507
508 // ACCESSORS
509
510 /// Invoke the functor supplied at construction with the specified
511 /// `argument`, and return the result.
512 template <class ARGUMENT_TYPE>
513 RESULT_TYPE operator()(ARGUMENT_TYPE& argument) const;
514 template <class ARGUMENT_TYPE>
515 RESULT_TYPE operator()(const ARGUMENT_TYPE& argument) const;
516
517 /// Do not call. The behavior of this method is undefined.
518 RESULT_TYPE operator()(bslmf::Nil) const;
519};
520
521 // =======================
522 // class VariantImp<TYPES>
523 // =======================
524
525/// This class provides the implementation of `Variant` (except for the
526/// creators) given a list of template parameter `TYPES`.
527///
528/// More generally, if each of the types in the list of `TYPES` is
529/// value semantic, then this class also supports a complete set of *value*
530/// *semantic* operations, including copy construction, assignment, equality
531/// comparison, and `ostream` printing. A precise operational definition of
532/// when two instances have the same value can be found in the description
533/// of `operator==` for the class. This class is *exception* *neutral* with
534/// no guarantee of rollback: if an exception is thrown during the
535/// invocation of a method on a pre-existing instance, the object is left in
536/// a valid state, but its value is undefined. In no event is memory
537/// leaked. Finally, *aliasing* (e.g., using all or part of an object as
538/// both source and destination) is supported in all cases.
539///
540/// If any of the types in the list of `TYPES` does not support
541/// `operator==`, or any of the value-semantic operations mentioned above,
542/// then this variant also does not support that operation and attempts to
543/// invoke it will trigger a compilation diagnostic.
544///
545/// See @ref bdlb_variant_cpp03
546template <class TYPES>
547class VariantImp : public VariantImp_Traits<TYPES>::BaseType {
548
549 // PRIVATE TYPES
550 typedef VariantImp_Traits<TYPES> Traits;
551 typedef typename Traits::BaseType Base;
552 typedef bslmf::MovableRefUtil MoveUtil;
553
554 /// `SelfType` is an alias to this class.
555 typedef VariantImp<TYPES> SelfType;
556
557 private:
558 // PRIVATE MANIPULATORS
559
560 /// Invoke `operator()` of the specified `visitor` on the current value
561 /// (of template parameter `TYPE`) held by this variant. `TYPE` must be
562 /// the same as one of the types that this variant can hold.
563 ///
564 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
565 ///
566 /// \note Note that the second argument is for resolving
567 /// overloading ambiguity and is not used.
568 template <class TYPE, class VISITOR_REF>
569 void applyImp(VISITOR_REF visitor, bsl::false_type);
570 template <class TYPE, class VISITOR_REF>
571 void applyImp(VISITOR_REF visitor, bsl::true_type);
572 template <class TYPE, class VISITOR_REF>
573 void applyImp(VISITOR_REF visitor);
574
575 /// Invoke `operator()` of the specified `visitor` on the current value
576 /// (of template parameter `TYPE`) held by this variant, and return the
577 /// value (of template parameter `RET_TYPE`) returned by the `visitor`.
578 /// `TYPE` must be the same as one of the types that this variant can hold.
579 ///
580 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
581 ///
582 /// \note Note that the second argument is for
583 /// resolving overloading ambiguity and is not used.
584 template <class TYPE, class VISITOR_REF, class RET_TYPE>
585 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::false_type);
586 template <class TYPE, class VISITOR_REF, class RET_TYPE>
587 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::true_type);
588 template <class TYPE, class VISITOR_REF, class RET_TYPE>
589 RET_TYPE applyImpR(VISITOR_REF visitor);
590
591 /// Assign to this variant the specified `value` of template parameter
592 /// `SOURCE_TYPE` converted to template parameter `TYPE`. `TYPE` must
593 /// be the same as one of the types that this variant can hold and
594 /// `SOURCE_TYPE` must be convertible to `TYPE`.
595 template <class TYPE, class SOURCE_TYPE>
596 void assignImp(const SOURCE_TYPE& value);
597
598 template <class TYPE>
599#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
600 void assignImp(TYPE&& value);
601#else
602 void assignImp(bslmf::MovableRef<TYPE> value);
603#endif
604 // Assign to this variant the specified 'value' of template parameter
605 // 'TYPE'. The contents of 'value' are moved to this object with
606 // 'value' left in a valid but unspecified state. 'TYPE' must be the
607 // same as one of the types that this variant can hold.
608
609 /// Construct this variant object to initially hold the specified
610 /// `value` of template parameter `TYPE`. `TYPE` must be the same as one of the types that this variant can hold.
611 ///
612 /// \note Note that the second
613 /// parameter is for resolving overloading ambiguity and is not used.
614 template <class TYPE>
615 void create(const TYPE& value, bsl::false_type);
616
617 /// Construct this variant object to be initially in the unset state.
618 void create(bslma::Allocator *, bsl::true_type);
619
620 /// Apply the specified `visitor` on the current value held by this
621 /// variant by invoking `applyImp` with the appropriate template
622 /// arguments, determined by the specified `type`.
623 ///
624 /// \pre The behavior is undefined unless `type != 0`.
625 template <class VISITOR_REF>
626 void doApply(VISITOR_REF visitor, int type);
627
628 /// Apply the specified `visitor` on the current value held by this
629 /// variant by invoking `applyImpR` with the appropriate template
630 /// arguments, determined by the specified `type`, and return the value
631 /// (of template parameter `RET_TYPE`) returned by the `visitor`.
632 ///
633 /// \pre The behavior is undefined unless `type != 0`.
634 template <class VISITOR_REF, class RET_TYPE>
635 RET_TYPE doApplyR(VISITOR_REF visitor, int type);
636
637 // PRIVATE ACCESSORS
638
639 /// Invoke `operator()` of the specified `visitor` on the current value
640 /// (of template parameter `TYPE`) held by this variant. `TYPE` must be
641 /// the same as one of the types that this variant can hold.
642 ///
643 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
644 ///
645 /// \note Note that the second argument is for resolving
646 /// overloading ambiguity and is not used.
647 template <class TYPE, class VISITOR_REF>
648 void applyImp(VISITOR_REF visitor, bsl::false_type) const;
649 template <class TYPE, class VISITOR_REF>
650 void applyImp(VISITOR_REF visitor, bsl::true_type) const;
651 template <class TYPE, class VISITOR_REF>
652 void applyImp(VISITOR_REF visitor) const;
653
654 /// Invoke `operator()` of the specified `visitor` on the current value
655 /// (of template parameter `TYPE`) held by this variant, and return the
656 /// value (of template parameter `RET_TYPE`) returned by the `visitor`.
657 /// `TYPE` must be the same as one of the types that this variant can hold.
658 ///
659 /// \pre The behavior is undefined unless this variant holds a value of template parameter `TYPE`.
660 ///
661 /// \note Note that the second argument is for
662 /// resolving overloading ambiguity and is not used.
663 template <class TYPE, class VISITOR_REF, class RET_TYPE>
664 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::false_type) const;
665 template <class TYPE, class VISITOR_REF, class RET_TYPE>
666 RET_TYPE applyImpR(VISITOR_REF visitor, bsl::true_type) const;
667 template <class TYPE, class VISITOR_REF, class RET_TYPE>
668 RET_TYPE applyImpR(VISITOR_REF visitor) const;
669
670 /// Apply the specified `visitor` on the current value held by this
671 /// variant by invoking `applyImp` with the appropriate template
672 /// arguments, determined by the specified `type`.
673 ///
674 /// \pre The behavior is undefined unless `type != 0`.
675 template <class VISITOR_REF>
676 void doApply(VISITOR_REF visitor, int type) const;
677
678 /// Apply the specified `visitor` on the current value held by this
679 /// variant by invoking `applyImpR` with the appropriate template
680 /// arguments, determined by the specified `type`, and return the value
681 /// (of template parameter `RET_TYPE`) returned by the `visitor`.
682 ///
683 /// \pre The behavior is undefined unless `type != 0`.
684 template <class VISITOR_REF, class RET_TYPE>
685 RET_TYPE doApplyR(VISITOR_REF visitor, int type) const;
686
687 public:
688 // TRAITS
691 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
694 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
697 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
699
700 // CREATORS
701
702 /// Create a variant object in the unset state that uses the currently
703 /// installed default allocator to supply memory.
704 VariantImp();
705
706 /// Create a variant object with the specified `valueOrAllocator` that
707 /// can be either a value of a type that the variant can hold or an
708 /// allocator to supply memory. If `valueOrAllocator` is not a
709 /// `bslma::Allocator *`, then the variant will hold the value and type
710 /// of `valueOrAllocator`, and use the currently installed default
711 /// allocator to supply memory. Otherwise, the variant will be unset
712 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
713 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
714 ///
715 /// \note Note that this
716 /// parameterized constructor is defined instead of two constructors
717 /// (one taking a `bslma::Allocator *` and the other not) because
718 /// template parameter arguments are always a better match than
719 /// derived-to-base conversion (a concrete allocator pointer converted
720 /// to `bslma::Allocator *`).
721 template <class TYPE_OR_ALLOCATOR>
722 explicit
723 VariantImp(const TYPE_OR_ALLOCATOR& valueOrAllocator);
724
725 /// Create a variant object having the specified `value` of template
726 /// parameter `TYPE` and that uses the specified `basicAllocator` to
727 /// supply memory. If `basicAllocator` is 0, the currently installed
728 /// default allocator is used. `TYPE` must be the same as one of the
729 /// types that this variant can hold.
730 template <class TYPE>
731 VariantImp(const TYPE& value, bslma::Allocator *basicAllocator);
732
733 template <class TYPE>
734 explicit
735#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
736 VariantImp(TYPE&& value,
737 typename bsl::enable_if<
739 SelfType,
740 typename bsl::remove_const<
741 typename bsl::remove_reference<TYPE>::type>::type>::value
742 &&
744 void>::type * = 0);
745#else
747#endif
748 // Create a variant object having the specified 'value' of template
749 // parameter 'TYPE' by moving the contents of 'value' to the
750 // newly-created object. Use the currently installed default allocator
751 // to supply memory. 'value' is left in a valid but unspecified state.
752 // 'TYPE' must be the same as one of the types that this variant can
753 // hold. Note that in C++11 mode, this method does not participate in
754 // overload resolution if it would lead to ambiguity with the move
755 // constructor that does not take an allocator (below) or with the
756 // constructor taking a 'valueOrAllocator' (above).
757
758 template <class TYPE>
759#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
760 VariantImp(TYPE&& value,
761 typename bsl::enable_if<
763 SelfType,
764 typename bsl::remove_const<
765 typename bsl::remove_reference<TYPE>::type>::type>::value,
766 bslma::Allocator>::type *basicAllocator);
767#else
769 bslma::Allocator *basicAllocator);
770#endif
771 // Create a variant object having the specified 'value' of template
772 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
773 // memory. If 'basicAllocator' is 0, the currently installed default
774 // allocator is used. The contents of 'value' are moved to the
775 // newly-created object with 'value' left in a valid but unspecified
776 // state. 'TYPE' must be the same as one of the types that this
777 // variant can hold. Note that in C++11 mode, this method does not
778 // participate in overload resolution if it would lead to ambiguity
779 // with the move constructor that takes an allocator (below).
780
781 /// Create a variant object having the type and value of the specified
782 /// `original` variant. Optionally specify a `basicAllocator` used to
783 /// supply memory. If `basicAllocator` is 0, the currently installed
784 /// default allocator is used.
785 VariantImp(const VariantImp& original,
786 bslma::Allocator *basicAllocator = 0);
787
788 /// Create a variant object having the type and value of the specified
789 /// `original` object by moving the contents of `original` to the
790 /// newly-created object. The allocator associated with `original` (if
791 /// any) is propagated for use in the newly-created object. `original`
792 /// is left in a valid but unspecified state.
794
795 /// Create a variant object having the type and value of the specified
796 /// `original` object that uses the specified `basicAllocator` to supply
797 /// memory. If `basicAllocator` is 0, the currently installed default
798 /// allocator is used. The contents of `original` are moved to the
799 /// newly-created object with `original` left in a valid but unspecified
800 /// state.
802 bslma::Allocator *basicAllocator);
803
804 /// Destroy this variant object, invoking the destructor of the type of
805 /// object contained (if any) on the value of that type.
806 ~VariantImp();
807
808 // MANIPULATORS
809
810 /// Assign to this object the specified `value` of template parameter
811 /// `TYPE`, and return a reference providing modifiable access to this
812 /// object. The value currently held by this variant (if any) is
813 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
814 /// must be the same as one of the types that this variant can hold.
815 template <class TYPE>
816 VariantImp& operator=(const TYPE& value);
817
818 template <class TYPE>
819#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
820 typename bsl::enable_if<
821 !bsl::is_same<SelfType,
822 typename bsl::remove_cvref<TYPE>::type>::value,
823 SelfType>::type&
824 operator=(TYPE&& value);
825#else
828#endif
829 // Assign to this object the specified 'value' of template parameter
830 // 'TYPE', and return a reference providing modifiable access to this
831 // object. The contents of 'value' are moved to this object with
832 // 'value' left in a valid but unspecified state. The value currently
833 // held by this variant (if any) is destroyed if that value's type is
834 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
835 // that this variant can hold. Note that in C++11 mode, this method
836 // does not participate in overload resolution if it would lead to
837 // ambiguity with the move-assignment operator (below).
838
839 /// Assign to this object the type and value currently held by the
840 /// specified `rhs` object, and return a reference providing modifiable
841 /// access to this object. The value currently held by this variant
842 /// (if any) is destroyed if that value's type is not the same as the
843 /// type held by the `rhs` object.
844 VariantImp& operator=(const VariantImp& rhs);
845
846 /// Assign to this object the type and value currently held by the
847 /// specified `rhs` object, and return a reference providing modifiable
848 /// access to this object. The contents of `rhs` are either
849 /// move-inserted into or move-assigned to this object with `rhs` left
850 /// in a valid but unspecified state.
852
853 /// Apply the specified `visitor` to this modifiable variant by passing
854 /// the value this variant currently holds to the `visitor` object's
855 /// `operator()`, and return the value returned by the `visitor`. If
856 /// this variant is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
857 ///
858 /// \note Note that this method is selected only if the
859 /// template parameter type `VISITOR` defines a `typedef` of
860 /// `ResultType` in its public interface. Also note that this method is
861 /// defined inline to work around a Windows compiler bug with SFINAE
862 /// functions.
863 template <class VISITOR>
865 typename VISITOR::ResultType>::type
866 apply(VISITOR& visitor) {
867
868 if (this->d_type) {
869 return doApplyR<VISITOR&,
870 typename VISITOR::ResultType>(visitor, this->d_type);
871 // RETURN
872 }
873
874 bslmf::Nil nil = bslmf::Nil();
875 return visitor(nil);
876 }
877
878 /// Apply the specified `visitor` to this modifiable variant by passing
879 /// the value this variant currently holds to the `visitor` object's
880 /// `operator()`, and return the value returned by the `visitor`. If
881 /// If this variant is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
882 ///
883 /// \note Note that this method is selected only if
884 /// the template parameter type `VISITOR` defines a `typedef` of
885 /// `ResultType` in its public interface. Also note that this method is
886 /// defined inline to work around a Windows compiler bug with SFINAE
887 /// functions.
888 template <class VISITOR>
890 typename VISITOR::ResultType>::type
891 apply(const VISITOR& visitor) {
892
893 if (this->d_type) {
894 return doApplyR<const VISITOR&,
895 typename VISITOR::ResultType>(visitor, this->d_type);
896 // RETURN
897 }
898
899 bslmf::Nil nil = bslmf::Nil();
900 return visitor(nil);
901 }
902
903 /// Apply the specified `visitor` to this modifiable variant by passing
904 /// the value (of template parameter `TYPE`) this variant currently
905 /// holds to the `visitor` object's `operator()`, and return the value
906 /// returned by the `visitor`. If this variant is unset, the specified
907 /// `defaultValue` of template parameter `TYPE` is passed to the
908 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
909 ///
910 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
911 ///
912 /// \note Note that this
913 /// method is selected only if the template parameter type `VISITOR`
914 /// defines a `typedef` of `ResultType` in its public interface. Also
915 /// note that this method is defined inline to work around a Windows
916 /// compiler bug with SFINAE functions.
917 template <class VISITOR, class TYPE>
919 typename VISITOR::ResultType>::type
920 apply(VISITOR& visitor, const TYPE& defaultValue) {
921
922 if (this->d_type) {
923 return doApplyR<VISITOR&,
924 typename VISITOR::ResultType>(visitor, this->d_type);
925 // RETURN
926 }
927
928 return visitor(defaultValue);
929 }
930
931 /// Apply the specified `visitor` to this modifiable variant by passing
932 /// the value (of template parameter `TYPE`) this variant currently
933 /// holds to the `visitor` object's `operator()`, and return the value
934 /// returned by the `visitor`. If this variant is unset, the specified
935 /// `defaultValue` of template parameter `TYPE` is passed to the
936 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
937 ///
938 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
939 ///
940 /// \note Note that this
941 /// method is selected only if the template parameter type `VISITOR`
942 /// defines a `typedef` of `ResultType` in its public interface. Also
943 /// note that this method is defined inline to work around a Windows
944 /// compiler bug with SFINAE functions.
945 template <class VISITOR, class TYPE>
947 typename VISITOR::ResultType>::type
948 apply(const VISITOR& visitor, const TYPE& defaultValue) {
949
950 if (this->d_type) {
951 return doApplyR<const VISITOR&,
952 typename VISITOR::ResultType>(visitor, this->d_type);
953 // RETURN
954 }
955
956 return visitor(defaultValue);
957 }
958
959 /// Apply the specified `visitor` to this modifiable variant by passing
960 /// the value this variant currently holds to the `visitor` object's
961 /// `operator()`. This method does not return a value. If this variant
962 /// is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
963 ///
964 /// \note Note that this method is selected only if the template
965 /// parameter type `VISITOR` does not define a `typedef` of `ResultType`
966 /// in its public interface. Also note that this method is defined
967 /// inline to work around a Windows compiler bug with SFINAE functions.
968 template <class VISITOR>
970 void>::type
971 apply(VISITOR& visitor) {
972
973 if (this->d_type) {
974 doApply<VISITOR&>(visitor, this->d_type);
975 return; // RETURN
976 }
977
978 bslmf::Nil nil = bslmf::Nil();
979 visitor(nil);
980 }
981
982 /// Apply the specified `visitor` to this modifiable variant by passing
983 /// the value this variant currently holds to the `visitor` object's
984 /// `operator()`. This method does not return a value. If this variant
985 /// is unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
986 ///
987 /// \note Note that this method is selected only if the template
988 /// parameter type `VISITOR` does not define a `typedef` of `ResultType`
989 /// in its public interface. Also note that this method is defined
990 /// inline to work around a Windows compiler bug with SFINAE functions.
991 template <class VISITOR>
993 void>::type
994 apply(const VISITOR& visitor) {
995
996 if (this->d_type) {
997 doApply<const VISITOR&>(visitor, this->d_type);
998 return; // RETURN
999 }
1000
1001 bslmf::Nil nil = bslmf::Nil();
1002 visitor(nil);
1003 }
1004
1005 /// Apply the specified `visitor` to this modifiable variant by passing
1006 /// the value (of template parameter `TYPE`) this variant currently
1007 /// holds to the `visitor` object's `operator()`. This method does not
1008 /// return a value. If this variant is unset, the specified
1009 /// `defaultValue` of template parameter `TYPE` is passed to the
1010 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1011 ///
1012 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1013 ///
1014 /// \note Note that this
1015 /// method is selected only if the template parameter type `VISITOR`
1016 /// does not define a `typedef` of `ResultType` in its public interface.
1017 /// Also note that this method is defined inline to work around a
1018 /// Windows compiler bug with SFINAE functions.
1019 template <class VISITOR, class TYPE>
1021 void>::type
1022 apply(VISITOR& visitor, const TYPE& defaultValue) {
1023
1024 if (this->d_type) {
1025 doApply<VISITOR&>(visitor, this->d_type);
1026 return; // RETURN
1027 }
1028
1029 visitor(defaultValue);
1030 }
1031
1032 /// Apply the specified `visitor` to this modifiable variant by passing
1033 /// the value (of template parameter `TYPE`) this variant currently
1034 /// holds to the `visitor` object's `operator()`. This method does not
1035 /// return a value. If this variant is unset, the specified
1036 /// `defaultValue` of template parameter `TYPE` is passed to the
1037 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1038 ///
1039 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1040 ///
1041 /// \note Note that this
1042 /// method is selected only if the template parameter type `VISITOR`
1043 /// does not define a `typedef` of `ResultType` in its public interface.
1044 /// Also note that this method is defined inline to work around a
1045 /// Windows compiler bug with SFINAE functions.
1046 template <class VISITOR, class TYPE>
1048 void>::type
1049 apply(const VISITOR& visitor, const TYPE& defaultValue) {
1050
1051 if (this->d_type) {
1052 doApply<const VISITOR&>(visitor, this->d_type);
1053 return; // RETURN
1054 }
1055
1056 visitor(defaultValue);
1057 }
1058
1059 /// Apply the specified `visitor` to this modifiable variant by passing
1060 /// the value (of template parameter `TYPE`) this variant currently
1061 /// holds to the `visitor` object's `operator()`, and return the value
1062 /// (of template parameter `RET_TYPE`) returned by the `visitor`. If
1063 /// this variant is unset, a default constructed `bslmf::Nil` is passed
1064 /// to the `visitor`.
1065 template <class RET_TYPE, class VISITOR>
1066 RET_TYPE apply(VISITOR& visitor);
1067 template <class RET_TYPE, class VISITOR>
1068 RET_TYPE apply(const VISITOR& visitor);
1069
1070 /// Apply the specified `visitor` to this modifiable variant by passing
1071 /// the value (of template parameter `TYPE`) this variant currently
1072 /// holds to the `visitor` object's `operator()`, and return the value
1073 /// (of template parameter `RET_TYPE`) returned by the `visitor`. If
1074 /// this variant is unset, the specified `defaultValue` of template
1075 /// parameter `TYPE` is passed to the `visitor`. `TYPE` must be the
1076 /// same as one of the types that this variant can hold.
1077 ///
1078 /// \pre The behavior is undefined unless this variant is unset or holds a value of
1079 /// template parameter `TYPE`.
1080 template <class RET_TYPE, class VISITOR, class TYPE>
1081 RET_TYPE apply(VISITOR& visitor, const TYPE& defaultValue);
1082 template <class RET_TYPE, class VISITOR, class TYPE>
1083 RET_TYPE apply(const VISITOR& visitor, const TYPE& defaultValue);
1084
1085 /// Apply the specified `visitor` to this modifiable variant by passing
1086 /// the value (of template parameter `TYPE`) this variant currently
1087 /// holds to the `visitor` object's `operator()`, and return the value returned by the `visitor`.
1088 ///
1089 /// \pre The behavior is undefined if this variant is unset.
1090 ///
1091 /// \note Note that this method is selected only if the
1092 /// template parameter type `VISITOR` defines a `typedef` of
1093 /// `ResultType` in its public interface. Also note that this method is
1094 /// defined inline to work around a Windows compiler bug with SFINAE
1095 /// functions.
1096 template <class VISITOR>
1098 typename VISITOR::ResultType>::type
1099 applyRaw(VISITOR& visitor) {
1100
1101 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1102 VISITOR> Helper;
1103
1104 return doApplyR<const Helper&,
1105 typename VISITOR::ResultType>(Helper(&visitor),
1106 this->d_type);
1107 }
1108
1109 /// Apply the specified `visitor` to this modifiable variant by passing
1110 /// the value (of template parameter `TYPE`) this variant currently
1111 /// holds to the `visitor` object's `operator()`, and return the value returned by the `visitor`.
1112 ///
1113 /// \pre The behavior is undefined if this variant is unset.
1114 ///
1115 /// \note Note that this method is selected only if the
1116 /// template parameter type `VISITOR` defines a `typedef` of
1117 /// `ResultType` in its public interface. Also note that this method is
1118 /// defined inline to work around a Windows compiler bug with SFINAE
1119 /// functions.
1120 template <class VISITOR>
1122 typename VISITOR::ResultType>::type
1123 applyRaw(const VISITOR& visitor) {
1124
1125 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1126 const VISITOR> Helper;
1127
1128 return doApplyR<const Helper&,
1129 typename VISITOR::ResultType>(Helper(&visitor),
1130 this->d_type);
1131 }
1132
1133 /// Apply the specified `visitor` to this modifiable variant by passing
1134 /// the value (of template parameter `TYPE`) this variant currently
1135 /// holds to the `visitor` object's `operator()`. This method does not return a value.
1136 ///
1137 /// \pre The behavior is undefined if this variant is unset.
1138 ///
1139 /// \note Note that this method is selected only if the template parameter
1140 /// type `VISITOR` does not define a `typedef` of `ResultType` in its
1141 /// public interface. Also note that this method is defined inline to
1142 /// work around a Windows compiler bug with SFINAE functions.
1143 template <class VISITOR>
1145 void>::type
1146 applyRaw(VISITOR& visitor) {
1147
1148 typedef Variant_RawVisitorHelper<void, VISITOR> Helper;
1149
1150 doApply<const Helper&>(Helper(&visitor), this->d_type);
1151 }
1152
1153 /// Apply the specified `visitor` to this modifiable variant by passing
1154 /// the value (of template parameter `TYPE`) this variant currently
1155 /// holds to the `visitor` object's `operator()`. This method does not return a value.
1156 ///
1157 /// \pre The behavior is undefined if this variant is unset.
1158 ///
1159 /// \note Note that this method is selected only if the template parameter
1160 /// type `VISITOR` does not define a `typedef` of `ResultType` in its
1161 /// public interface. Also note that this method is defined inline to
1162 /// work around a Windows compiler bug with SFINAE functions.
1163 template <class VISITOR>
1165 void>::type
1166 applyRaw(const VISITOR& visitor) {
1167
1168 typedef Variant_RawVisitorHelper<void, const VISITOR> Helper;
1169
1170 doApply<const Helper&>(Helper(&visitor), this->d_type);
1171 }
1172
1173 /// Apply the specified `visitor` to this modifiable variant by passing
1174 /// the value this variant currently holds to the `visitor` object's
1175 /// `operator()`, and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
1176 ///
1177 /// \pre The behavior is undefined if
1178 /// this variant is unset.
1179 template <class RET_TYPE, class VISITOR>
1180 RET_TYPE applyRaw(VISITOR& visitor);
1181 template <class RET_TYPE, class VISITOR>
1182 RET_TYPE applyRaw(const VISITOR& visitor);
1183
1184 /// Assign to this object the specified `value` of template parameter
1185 /// `TYPE`, and return a reference providing modifiable access to this
1186 /// object. The value currently held by this variant (if any) is
1187 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
1188 /// must be the same as one of the types that this variant can hold.
1189 template <class TYPE>
1190 VariantImp& assign(const TYPE& value);
1191
1192 template <class TYPE>
1193#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
1194 VariantImp& assign(TYPE&& value);
1195#else
1197#endif
1198 // Assign to this object the specified 'value' of template parameter
1199 // 'TYPE', and return a reference providing modifiable access to this
1200 // object. The contents of 'value' are moved to this object with
1201 // 'value' left in a valid but unspecified state. The value currently
1202 // held by this variant (if any) is destroyed if that value's type is
1203 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
1204 // that this variant can hold.
1205
1206 /// Assign to this object the specified `value` of template parameter
1207 /// `SOURCE_TYPE` converted to template parameter `TYPE`, and return a
1208 /// reference providing modifiable access to this object. The value
1209 /// currently held by this variant (if any) is destroyed if that value's
1210 /// type is not the same as `TYPE`. `TYPE` must be the same as one of
1211 /// the types that this variant can hold and `SOURCE_TYPE` must be
1212 /// convertible to `TYPE`.
1213 template <class TYPE, class SOURCE_TYPE>
1214 VariantImp& assignTo(const SOURCE_TYPE& value);
1215
1216#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1217// {{{ BEGIN GENERATED CODE
1218// Command line: sim_cpp11_features.pl bdlb_variant.h
1219#ifndef BDLB_VARIANT_VARIADIC_LIMIT
1220#define BDLB_VARIANT_VARIADIC_LIMIT 14
1221#endif
1222#ifndef BDLB_VARIANT_VARIADIC_LIMIT_A
1223#define BDLB_VARIANT_VARIADIC_LIMIT_A BDLB_VARIANT_VARIADIC_LIMIT
1224#endif
1225
1226#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 0
1227 template <class TYPE>
1228 TYPE& createInPlace();
1229#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 0
1230
1231#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 1
1232 template <class TYPE, class ARGS_01>
1233 TYPE& createInPlace(
1234 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01);
1235#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 1
1236
1237#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 2
1238 template <class TYPE, class ARGS_01,
1239 class ARGS_02>
1240 TYPE& createInPlace(
1241 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1242 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02);
1243#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 2
1244
1245#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 3
1246 template <class TYPE, class ARGS_01,
1247 class ARGS_02,
1248 class ARGS_03>
1249 TYPE& createInPlace(
1250 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1251 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1252 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03);
1253#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 3
1254
1255#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 4
1256 template <class TYPE, class ARGS_01,
1257 class ARGS_02,
1258 class ARGS_03,
1259 class ARGS_04>
1260 TYPE& createInPlace(
1261 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1262 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1263 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1264 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04);
1265#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 4
1266
1267#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 5
1268 template <class TYPE, class ARGS_01,
1269 class ARGS_02,
1270 class ARGS_03,
1271 class ARGS_04,
1272 class ARGS_05>
1273 TYPE& createInPlace(
1274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1275 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05);
1279#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 5
1280
1281#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 6
1282 template <class TYPE, class ARGS_01,
1283 class ARGS_02,
1284 class ARGS_03,
1285 class ARGS_04,
1286 class ARGS_05,
1287 class ARGS_06>
1288 TYPE& createInPlace(
1289 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1290 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1291 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1292 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1293 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1294 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06);
1295#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 6
1296
1297#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 7
1298 template <class TYPE, class ARGS_01,
1299 class ARGS_02,
1300 class ARGS_03,
1301 class ARGS_04,
1302 class ARGS_05,
1303 class ARGS_06,
1304 class ARGS_07>
1305 TYPE& createInPlace(
1306 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1309 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1310 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1311 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1312 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07);
1313#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 7
1314
1315#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 8
1316 template <class TYPE, class ARGS_01,
1317 class ARGS_02,
1318 class ARGS_03,
1319 class ARGS_04,
1320 class ARGS_05,
1321 class ARGS_06,
1322 class ARGS_07,
1323 class ARGS_08>
1324 TYPE& createInPlace(
1325 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1326 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1327 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1328 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1329 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1330 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1331 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1332 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08);
1333#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 8
1334
1335#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 9
1336 template <class TYPE, class ARGS_01,
1337 class ARGS_02,
1338 class ARGS_03,
1339 class ARGS_04,
1340 class ARGS_05,
1341 class ARGS_06,
1342 class ARGS_07,
1343 class ARGS_08,
1344 class ARGS_09>
1345 TYPE& createInPlace(
1346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1347 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1348 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1349 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1350 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1351 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09);
1355#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 9
1356
1357#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 10
1358 template <class TYPE, class ARGS_01,
1359 class ARGS_02,
1360 class ARGS_03,
1361 class ARGS_04,
1362 class ARGS_05,
1363 class ARGS_06,
1364 class ARGS_07,
1365 class ARGS_08,
1366 class ARGS_09,
1367 class ARGS_10>
1368 TYPE& createInPlace(
1369 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1370 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1371 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1374 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1375 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1376 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1377 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
1378 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10);
1379#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 10
1380
1381#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 11
1382 template <class TYPE, class ARGS_01,
1383 class ARGS_02,
1384 class ARGS_03,
1385 class ARGS_04,
1386 class ARGS_05,
1387 class ARGS_06,
1388 class ARGS_07,
1389 class ARGS_08,
1390 class ARGS_09,
1391 class ARGS_10,
1392 class ARGS_11>
1393 TYPE& createInPlace(
1394 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1395 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1396 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1397 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1398 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1401 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1402 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
1403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
1404 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11);
1405#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 11
1406
1407#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 12
1408 template <class TYPE, class ARGS_01,
1409 class ARGS_02,
1410 class ARGS_03,
1411 class ARGS_04,
1412 class ARGS_05,
1413 class ARGS_06,
1414 class ARGS_07,
1415 class ARGS_08,
1416 class ARGS_09,
1417 class ARGS_10,
1418 class ARGS_11,
1419 class ARGS_12>
1420 TYPE& createInPlace(
1421 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1422 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1423 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1424 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1425 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1426 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1427 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1428 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1429 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
1430 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
1431 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
1432 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12);
1433#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 12
1434
1435#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 13
1436 template <class TYPE, class ARGS_01,
1437 class ARGS_02,
1438 class ARGS_03,
1439 class ARGS_04,
1440 class ARGS_05,
1441 class ARGS_06,
1442 class ARGS_07,
1443 class ARGS_08,
1444 class ARGS_09,
1445 class ARGS_10,
1446 class ARGS_11,
1447 class ARGS_12,
1448 class ARGS_13>
1449 TYPE& createInPlace(
1450 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1451 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1452 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1453 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1454 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1455 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1456 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1457 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1458 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
1459 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
1460 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
1461 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12,
1462 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) arguments_13);
1463#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 13
1464
1465#if BDLB_VARIANT_VARIADIC_LIMIT_A >= 14
1466 template <class TYPE, class ARGS_01,
1467 class ARGS_02,
1468 class ARGS_03,
1469 class ARGS_04,
1470 class ARGS_05,
1471 class ARGS_06,
1472 class ARGS_07,
1473 class ARGS_08,
1474 class ARGS_09,
1475 class ARGS_10,
1476 class ARGS_11,
1477 class ARGS_12,
1478 class ARGS_13,
1479 class ARGS_14>
1480 TYPE& createInPlace(
1481 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
1482 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
1483 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
1484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
1485 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
1486 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
1487 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
1488 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
1489 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
1490 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
1491 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
1492 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12,
1493 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) arguments_13,
1494 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) arguments_14);
1495#endif // BDLB_VARIANT_VARIADIC_LIMIT_A >= 14
1496
1497#else
1498// The generated code below is a workaround for the absence of perfect
1499// forwarding in some compilers.
1500
1501 template <class TYPE, class... ARGS>
1502 TYPE& createInPlace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments);
1503// }}} END GENERATED CODE
1504#endif
1505
1506 /// Destroy the current value held by this variant (if any), and reset
1507 /// this variant to the unset state.
1508 void reset();
1509
1510 /// Swap the value of this object with the value of the specified
1511 /// `other` object. This method provides the no-throw guarantee if the
1512 /// `TYPE` template parameter has a no-throw `swap` and the two variant
1513 /// objects being swapped have the same type; otherwise this method
1514 /// provides the basic guarantee.
1515 void swap(VariantImp& other);
1516
1517 /// Return a reference providing modifiable access to the value of
1518 /// template parameter `TYPE` held by this variant object. `TYPE` must
1519 /// be the same as one of the types that this variant can hold.
1520 ///
1521 /// \pre The behavior is undefined unless `is<TYPE>()` returns `true` and `TYPE` is not `void`.
1522 ///
1523 /// \note Note that `TYPE` must be specified explicitly, e.g.,
1524 /// `myValue.the<int>()`.
1525 template <class TYPE>
1526 TYPE& the();
1527
1528 // ACCESSORS
1529
1530 /// Apply the specified `visitor` to this variant by passing the value
1531 /// this variant currently holds to the `visitor` object's `operator()`,
1532 /// and return the value returned by the `visitor`. If this variant is
1533 /// unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1534 ///
1535 /// \note Note that this method is selected only if the template
1536 /// parameter type `VISITOR` defines a `typedef` of `ResultType` in its
1537 /// public interface. Also note that this method is defined inline to
1538 /// work around a Windows compiler bug with SFINAE functions.
1539 template <class VISITOR>
1541 typename VISITOR::ResultType>::type
1542 apply(VISITOR& visitor) const {
1543
1544 if (this->d_type) {
1545 return doApplyR<VISITOR&,
1546 typename VISITOR::ResultType>(visitor, this->d_type);
1547 // RETURN
1548 }
1549
1550 bslmf::Nil nil = bslmf::Nil();
1551 return visitor(nil);
1552 }
1553
1554 /// Apply the specified `visitor` to this variant by passing the value
1555 /// this variant currently holds to the `visitor` object's `operator()`,
1556 /// and return the value returned by the 'visitor. If this variant is
1557 /// unset, a default constructed `bslmf::Nil` is passed to the `visitor`.
1558 ///
1559 /// \note Note that this method is selected only if the template
1560 /// parameter type `VISITOR` defines a `typedef` of `ResultType` in its
1561 /// public interface. Also note that this method is defined inline to
1562 /// work around a Windows compiler bug with SFINAE functions.
1563 template <class VISITOR>
1565 typename VISITOR::ResultType>::type
1566 apply(const VISITOR& visitor) const {
1567
1568 if (this->d_type) {
1569 return doApplyR<const VISITOR&,
1570 typename VISITOR::ResultType>(visitor, this->d_type);
1571 // RETURN
1572 }
1573
1574 bslmf::Nil nil = bslmf::Nil();
1575 return visitor(nil);
1576 }
1577
1578 /// Apply the specified `visitor` to this variant by passing the value
1579 /// (of template parameter `TYPE`) this variant currently holds to the
1580 /// `visitor` object's `operator()`, and return the value returned by
1581 /// the `visitor`. If this variant is unset, the specified
1582 /// `defaultValue` of template parameter `TYPE` is passed to the
1583 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1584 ///
1585 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1586 ///
1587 /// \note Note that this
1588 /// method is selected only if the template parameter type `VISITOR`
1589 /// defines a `typedef` of `ResultType` in its public interface. Also
1590 /// note that this method is defined inline to work around a Windows
1591 /// compiler bug with SFINAE functions.
1592 template <class VISITOR, class TYPE>
1594 typename VISITOR::ResultType>::type
1595 apply(VISITOR& visitor, const TYPE& defaultValue) const {
1596
1597 if (this->d_type) {
1598 return doApplyR<VISITOR&,
1599 typename VISITOR::ResultType>(visitor, this->d_type);
1600 // RETURN
1601 }
1602
1603 return visitor(defaultValue);
1604 }
1605
1606 /// Apply the specified `visitor` to this variant by passing the value
1607 /// (of template parameter `TYPE`) this variant currently holds to the
1608 /// `visitor` object's `operator()`, and return the value returned by
1609 /// the `visitor`. If this variant is unset, the specified
1610 /// `defaultValue` of template parameter `TYPE` is passed to the
1611 /// `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1612 ///
1613 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1614 ///
1615 /// \note Note that this
1616 /// method is selected only if the template parameter type `VISITOR`
1617 /// defines a `typedef` of `ResultType` in its public interface. Also
1618 /// note that this method is defined inline to work around a Windows
1619 /// compiler bug with SFINAE functions.
1620 template <class VISITOR, class TYPE>
1622 typename VISITOR::ResultType>::type
1623 apply(const VISITOR& visitor, const TYPE& defaultValue) const {
1624
1625 if (this->d_type) {
1626 return doApplyR<const VISITOR&,
1627 typename VISITOR::ResultType>(visitor, this->d_type);
1628 // RETURN
1629 }
1630
1631 return visitor(defaultValue);
1632 }
1633
1634 /// Apply the specified `visitor` to this variant by passing the value
1635 /// this variant currently holds to the `visitor` object's `operator()`.
1636 /// This method does not return a value. If this variant is unset, a
1637 /// default constructed `bslmf::Nil` is passed to the `visitor`.
1638 ///
1639 /// \note Note that this method is selected only if the template parameter type
1640 /// `VISITOR` does not define a `typedef` of `ResultType` in its public
1641 /// interface. Also note that this method is defined inline to work
1642 /// around a Windows compiler bug with SFINAE functions.
1643 template <class VISITOR>
1645 void>::type
1646 apply(VISITOR& visitor) const {
1647
1648 if (this->d_type) {
1649 doApply<VISITOR&>(visitor, this->d_type);
1650 return; // RETURN
1651 }
1652
1653 bslmf::Nil nil = bslmf::Nil();
1654 visitor(nil);
1655 }
1656
1657 /// Apply the specified `visitor` to this variant by passing the value
1658 /// this variant currently holds to the `visitor` object's `operator()`.
1659 /// This method does not return a value. If this variant is unset, a
1660 /// default constructed `bslmf::Nil` is passed to the `visitor`.
1661 ///
1662 /// \note Note that this method is selected only if the template parameter type
1663 /// `VISITOR` does not define a `typedef` of `ResultType` in its public
1664 /// interface. Also note that this method is defined inline to work
1665 /// around a Windows compiler bug with SFINAE functions.
1666 template <class VISITOR>
1668 void>::type
1669 apply(const VISITOR& visitor) const {
1670
1671 if (this->d_type) {
1672 doApply<const VISITOR&>(visitor, this->d_type);
1673 return; // RETURN
1674 }
1675
1676 bslmf::Nil nil = bslmf::Nil();
1677 visitor(nil);
1678 }
1679
1680 /// Apply the specified `visitor` to this variant by passing the value
1681 /// (of template parameter `TYPE`) this variant currently holds to the
1682 /// `visitor` object's `operator()`. This method does not return a
1683 /// value. If this variant is unset, the specified `defaultValue` of
1684 /// template parameter `TYPE` is passed to the `visitor`. `TYPE` must
1685 /// be the same as one of the types that this variant can hold.
1686 ///
1687 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1688 ///
1689 /// \note Note that this method is selected
1690 /// only if the template parameter type `VISITOR` does not define a
1691 /// `typedef` of `ResultType` in its public interface. Also note that
1692 /// this method is defined inline to work around a Windows compiler bug
1693 /// with SFINAE functions.
1694 template <class VISITOR, class TYPE>
1696 void>::type
1697 apply(VISITOR& visitor, const TYPE& defaultValue) const {
1698
1699 if (this->d_type) {
1700 doApply<VISITOR&>(visitor, this->d_type);
1701 return; // RETURN
1702 }
1703
1704 visitor(defaultValue);
1705 }
1706
1707 /// Apply the specified `visitor` to this variant by passing the value
1708 /// (of template parameter `TYPE`) this variant currently holds to the
1709 /// `visitor` object's `operator()`. This method does not return a
1710 /// value. If this variant is unset, the specified `defaultValue` of
1711 /// template parameter `TYPE` is passed to the `visitor`. `TYPE` must
1712 /// be the same as one of the types that this variant can hold.
1713 ///
1714 /// \pre The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`.
1715 ///
1716 /// \note Note that this method is selected
1717 /// only if the template parameter type `VISITOR` does not define a
1718 /// `typedef` of `ResultType` in its public interface. Also note that
1719 /// this method is defined inline to work around a Windows compiler bug
1720 /// with SFINAE functions.
1721 template <class VISITOR, class TYPE>
1723 void>::type
1724 apply(const VISITOR& visitor, const TYPE& defaultValue) const {
1725
1726 if (this->d_type) {
1727 doApply<const VISITOR&>(visitor, this->d_type);
1728 return; // RETURN
1729 }
1730
1731 visitor(defaultValue);
1732 }
1733
1734 /// Apply the specified `visitor` to this variant by passing the value
1735 /// this variant currently holds to the `visitor` object's `operator()`,
1736 /// and return the value (of template parameter `RET_TYPE`) returned by
1737 /// the `visitor`. If this variant is unset, a default constructed
1738 /// `bslmf::Nil` is passed to the `visitor`.
1739 template <class RET_TYPE, class VISITOR>
1740 RET_TYPE apply(VISITOR& visitor) const;
1741 template <class RET_TYPE, class VISITOR>
1742 RET_TYPE apply(const VISITOR& visitor) const;
1743
1744 /// Apply the specified `visitor` to this variant by passing the value
1745 /// (of template parameter `TYPE`) this variant currently holds to the
1746 /// `visitor` object's `operator()`, and return the value (of template
1747 /// parameter `RET_TYPE`) returned by the `visitor`. If this variant is
1748 /// unset, the specified `defaultValue` of template parameter `TYPE` is
1749 /// passed to the `visitor`. `TYPE` must be the same as one of the types that this variant can hold.
1750 ///
1751 /// \pre The behavior is undefined unless
1752 /// this variant is unset or holds a value of template parameter `TYPE`.
1753 template <class RET_TYPE, class VISITOR, class TYPE>
1754 RET_TYPE apply(VISITOR& visitor, const TYPE& defaultValue) const;
1755 template <class RET_TYPE, class VISITOR, class TYPE>
1756 RET_TYPE apply(const VISITOR& visitor, const TYPE& defaultValue) const;
1757
1758 /// Apply the specified `visitor` to this variant by passing the value
1759 /// this variant currently holds to the `visitor` object's `operator()`,
1760 /// and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
1761 ///
1762 /// \pre The behavior is undefined if this variant is unset.
1763 ///
1764 /// \note Note that this method is selected only if the template parameter
1765 /// type `VISITOR` defines a `typedef` of `ResultType` in its public
1766 /// interface. Also note that this method is defined inline to work
1767 /// around a Windows compiler bug with SFINAE functions.
1768 template <class VISITOR>
1770 typename VISITOR::ResultType>::type
1771 applyRaw(VISITOR& visitor) const {
1772
1773 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1774 VISITOR> Helper;
1775
1776 return doApplyR<const Helper&,
1777 typename VISITOR::ResultType>(Helper(&visitor),
1778 this->d_type);
1779 }
1780
1781 /// Apply the specified `visitor` to this variant by passing the value
1782 /// this variant currently holds to the `visitor` object's `operator()`,
1783 /// and return the value returned by the `visitor`.
1784 ///
1785 /// \pre The behavior is undefined if this variant is unset.
1786 /// \note Note that this method is
1787 /// selected only if the template parameter type `VISITOR` defines a
1788 /// `typedef` of `ResultType` in its public interface. Also note that
1789 /// this method is defined inline to work around a Windows compiler bug
1790 /// with SFINAE functions.
1791 template <class VISITOR>
1793 typename VISITOR::ResultType>::type
1794 applyRaw(const VISITOR& visitor) const {
1795
1796 typedef Variant_RawVisitorHelper<typename VISITOR::ResultType,
1797 const VISITOR> Helper;
1798
1799 return doApplyR<const Helper&,
1800 typename VISITOR::ResultType>(Helper(&visitor),
1801 this->d_type);
1802 }
1803
1804 /// Apply the specified `visitor` to this variant by passing the value
1805 /// this variant currently holds to the `visitor` object's `operator()`. This method does not return a value.
1806 ///
1807 /// \pre The behavior is undefined if this variant is unset.
1808 ///
1809 /// \note Note that this method is selected only if
1810 /// the template parameter type `VISITOR` does not define a `typedef` of
1811 /// `ResultType` in its public interface. Also note that this method is
1812 /// defined inline to work around a Windows compiler bug with SFINAE
1813 /// functions.
1814 template <class VISITOR>
1816 void>::type
1817 applyRaw(VISITOR& visitor) const {
1818
1819 typedef Variant_RawVisitorHelper<void, VISITOR> Helper;
1820
1821 return doApply<const Helper&>(Helper(&visitor), this->d_type);
1822 }
1823
1824 /// Apply the specified `visitor` to this variant by passing the value
1825 /// this variant currently holds to the `visitor` object's `operator()`. This method does not return a value.
1826 ///
1827 /// \pre The behavior is undefined if this variant is unset.
1828 ///
1829 /// \note Note that this method is selected only if
1830 /// the template parameter type `VISITOR` does not define a `typedef` of
1831 /// `ResultType` in its public interface. Also note that this method is
1832 /// defined inline to work around a Windows compiler bug with SFINAE
1833 /// functions.
1834 template <class VISITOR>
1836 void>::type
1837 applyRaw(const VISITOR& visitor) const {
1838
1839 typedef Variant_RawVisitorHelper<void, const VISITOR> Helper;
1840
1841 return doApply<const Helper&>(Helper(&visitor), this->d_type);
1842 }
1843
1844 /// Apply the specified `visitor` to this variant by passing the value
1845 /// this variant currently holds to the `visitor` object's `operator()`,
1846 /// and return the value (of template parameter `RET_TYPE`) returned by the `visitor`.
1847 ///
1848 /// \pre The behavior is undefined if this variant is unset.
1849 template <class RET_TYPE, class VISITOR>
1850 RET_TYPE applyRaw(VISITOR& visitor) const;
1851 template <class RET_TYPE, class VISITOR>
1852 RET_TYPE applyRaw(const VISITOR& visitor) const;
1853
1854 /// Return `true` if the value held by this variant object is of
1855 /// template parameter `TYPE`, and `false` otherwise. `TYPE` must be
1856 /// the same as one of the types that this variant can hold.
1857 ///
1858 /// \note Note that `TYPE` must be specified explicitly, e.g., `myValue.is<int>()`.
1859 template <class TYPE>
1860 bool is() const;
1861
1862 /// Return `true` if this variant is currently unset, and `false`
1863 /// otherwise. An unset variant does not hold a value or type.
1864 ///
1865 /// \note Note that this method should be preferred over checking the type index of
1866 /// the variant.
1867 bool isUnset() const;
1868
1869 /// Format this object to the specified output `stream` at the (absolute
1870 /// value of) the optionally specified indentation `level`, and return a
1871 /// reference to `stream`. If `level` is specified, optionally specify
1872 /// `spacesPerLevel`, the number of spaces per indentation level for
1873 /// this and all of its nested objects. If `level` is negative,
1874 /// suppress indentation of the first line. If `spacesPerLevel` is
1875 /// negative, format the entire output on one line, suppressing all but
1876 /// the initial indentation (as governed by `level`). If `stream` is
1877 /// not valid on entry, this operation has no effect. Nothing is
1878 /// printed if this variant is unset. Each type that may be contained
1879 /// by this variant shall be printable with `bdlb::PrintMethods`
1880 /// (typically meaning that they either declare the
1881 /// `bdlb::HasPrintMethod` trait or provide the `<<` output streaming
1882 /// operator). See @ref bdlb_printmethods . The compiler will emit an
1883 /// error if `bdlb::PrintMethods::print` cannot be instantiated for each
1884 /// type that may be contained by this variant.
1885 bsl::ostream& print(bsl::ostream& stream,
1886 int level = 0,
1887 int spacesPerLevel = 4) const;
1888
1889 /// Return a reference providing non-modifiable access to the value of
1890 /// template parameter `TYPE` held by this variant object. `TYPE` must
1891 /// be the same as one of the types that this variant can hold.
1892 ///
1893 /// \pre The behavior is undefined unless `is<TYPE>()` returns `true` and `TYPE` is not `void`.
1894 ///
1895 /// \note Note that `TYPE` must be specified explicitly, e.g.,
1896 /// `myValue.the<int>()`.
1897 template <class TYPE>
1898 const TYPE& the() const;
1899
1900 /// Return the index in the list of `TYPES` corresponding to the type of
1901 /// the value currently held by this variant object (starting at 1), or 0 if this object is unset.
1902 ///
1903 /// \note Note that instead of switching code on
1904 /// the type index, calling `apply` is the preferred method of
1905 /// manipulating different types stored inside a variant.
1906 int typeIndex() const;
1907
1908#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1909 /// Return `typeid(void)`.
1910 ///
1911 /// DEPRECATED: Do not use.
1912 const bsl::type_info& typeInfo() const;
1913
1914 /// DEPRECATED: Do not use.
1915 template <class STREAM>
1916 STREAM& bdexStreamIn(STREAM& stream, int version);
1917
1918 /// DEPRECATED: Do not use.
1919 int maxSupportedBdexVersion() const;
1920
1921 /// DEPRECATED: Do not use.
1922 template <class STREAM>
1923 STREAM& bdexStreamOut(STREAM& stream, int version) const;
1924
1925#endif // BDE_OMIT_INTERNAL_DEPRECATED
1926};
1927
1928// FREE OPERATORS
1929
1930/// Return `true` if the specified `lhs` variant object has the same value
1931/// as the specified `rhs` variant object, and `false` otherwise. Two
1932/// variant objects have the same value if they are both set and hold
1933/// objects of the same type and same value, or are both unset.
1934template <class TYPES>
1935bool operator==(const VariantImp<TYPES>& lhs,
1936 const VariantImp<TYPES>& rhs);
1937
1938/// Return `true` if the specified `lhs` variant object does not have the
1939/// same value as the specified `rhs` variant object, and `false` otherwise.
1940/// Two variant objects do not have the same value if one is set and the
1941/// other is unset, or if they are both set but hold objects that differ in
1942/// type or value.
1943template <class TYPES>
1944bool operator!=(const VariantImp<TYPES>& lhs,
1945 const VariantImp<TYPES>& rhs);
1946
1947/// Write the specified variant `object` to the specified output `stream` in
1948/// a single-line (human-readable) format, and return a reference to
1949/// `stream`.
1950template <class TYPES>
1951bsl::ostream& operator<<(bsl::ostream& stream,
1952 const VariantImp<TYPES>& object);
1953
1954// FREE FUNCTIONS
1955
1956/// Swap the values of the specified `a` and `b` objects. This method
1957/// provides the no-throw guarantee if the `TYPE` template parameter has a
1958/// no-throw `swap` and the two variant objects being swapped has the same
1959/// type; otherwise this method provides the basic guarantee.
1960template <class TYPES>
1961void swap(VariantImp<TYPES>& a, VariantImp<TYPES>& b);
1962
1963 // ==================
1964 // class Variant<...>
1965 // ==================
1966
1967#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
1968template <class ...TYPES>
1969class Variant : public VariantImp<typename bslmf::TypeList<TYPES...>::ListType>
1970 {
1971#else
1972template <class A1 = bslmf::Nil, class A2 = bslmf::Nil,
1973 class A3 = bslmf::Nil, class A4 = bslmf::Nil,
1974 class A5 = bslmf::Nil, class A6 = bslmf::Nil,
1975 class A7 = bslmf::Nil, class A8 = bslmf::Nil,
1976 class A9 = bslmf::Nil, class A10 = bslmf::Nil,
1977 class A11 = bslmf::Nil, class A12 = bslmf::Nil,
1978 class A13 = bslmf::Nil, class A14 = bslmf::Nil,
1979 class A15 = bslmf::Nil, class A16 = bslmf::Nil,
1980 class A17 = bslmf::Nil, class A18 = bslmf::Nil,
1981 class A19 = bslmf::Nil, class A20 = bslmf::Nil>
1982class Variant : public VariantImp<typename bslmf::TypeList<
1983 A1, A2, A3, A4, A5,
1984 A6, A7, A8, A9, A10,
1985 A11, A12, A13, A14, A15,
1986 A16, A17, A18, A19, A20>::ListType> {
1987#endif
1988 // This class provides a "variant" type, i.e., a type capable of storing
1989 // values from a list of template parameter types 'A1' to 'A20'. Note that
1990 // if the number 'N' of types is smaller than 20, 'AN+1' up to 'A20'
1991 // default to 'bslmf::Nil', but it is more economical to use 'VariantN',
1992 // which accepts exactly 'N' template arguments, as this leads to shorter
1993 // symbols and debug string information.
1994
1995 // PRIVATE TYPES
1996#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
1997 typedef VariantImp<typename bslmf::TypeList<TYPES...>::ListType> Imp;
1998
1999 /// `SelfType` is an alias to this class.
2000 typedef Variant<TYPES...> SelfType;
2001#else
2002 typedef VariantImp<typename bslmf::TypeList<A1, A2, A3, A4, A5, A6,
2003 A7, A8, A9, A10, A11, A12,
2004 A13, A14, A15, A16, A17, A18,
2005 A19, A20>::ListType> Imp;
2006
2007 typedef Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
2008 A11, A12, A13, A14, A15, A16, A17, A18, A19, A20> SelfType;
2009 // 'SelfType' is an alias to this class.
2010#endif
2011
2012 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2013 typedef bslmf::MovableRefUtil MoveUtil;
2014
2015 public:
2016 // TRAITS
2019 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2022 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2025 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2026 BSLMF_NESTED_TRAIT_DECLARATION(Variant, HasPrintMethod);
2027
2028 // CREATORS
2029
2030 /// Create a variant object in the unset state that uses the currently
2031 /// installed default allocator to supply memory.
2032 Variant();
2033
2034 /// Create a variant object with the specified `valueOrAllocator` that
2035 /// can be either a value of a type that the variant can hold or an
2036 /// allocator to supply memory. If `valueOrAllocator` is not a
2037 /// `bslma::Allocator *`, then the variant will hold the value and type
2038 /// of `valueOrAllocator`, and use the currently installed default
2039 /// allocator to supply memory. Otherwise, the variant will be unset
2040 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2041 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2042 ///
2043 /// \note Note that this
2044 /// parameterized constructor is defined instead of two constructors
2045 /// (one taking a `bslma::Allocator *` and the other not) because
2046 /// template parameter arguments are always a better match than
2047 /// derived-to-base conversion (a concrete allocator pointer converted
2048 /// to `bslma::Allocator *`).
2049 template <class TYPE_OR_ALLOCATOR>
2050 explicit
2051 Variant(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2052
2053 /// Create a variant object having the specified `value` of template
2054 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2055 /// supply memory. If `basicAllocator` is 0, the currently installed
2056 /// default allocator is used. `TYPE` must be the same as one of the
2057 /// types that this variant can hold.
2058 template <class TYPE>
2059 Variant(const TYPE& value, bslma::Allocator *basicAllocator);
2060
2061 template <class TYPE>
2062 explicit
2063#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2064 Variant(TYPE&& value,
2065 typename bsl::enable_if<
2066 !bsl::is_same<
2067 SelfType,
2068 typename bsl::remove_const<
2069 typename bsl::remove_reference<TYPE>::type>::type>::value
2070 &&
2072 void>::type * = 0);
2073#else
2075#endif
2076 // Create a variant object having the specified 'value' of template
2077 // parameter 'TYPE' by moving the contents of 'value' to the
2078 // newly-created object. Use the currently installed default allocator
2079 // to supply memory. 'value' is left in a valid but unspecified state.
2080 // 'TYPE' must be the same as one of the types that this variant can
2081 // hold. Note that in C++11 mode, this method does not participate in
2082 // overload resolution if it would lead to ambiguity with the move
2083 // constructor that does not take an allocator (below) or with the
2084 // constructor taking a 'valueOrAllocator' (above).
2085
2086 template <class TYPE>
2087#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2088 Variant(TYPE&& value,
2089 typename bsl::enable_if<
2090 !bsl::is_same<
2091 SelfType,
2092 typename bsl::remove_const<
2093 typename bsl::remove_reference<TYPE>::type>::type>::value,
2094 bslma::Allocator>::type *basicAllocator);
2095#else
2097 bslma::Allocator *basicAllocator);
2098#endif
2099 // Create a variant object having the specified 'value' of template
2100 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2101 // memory. If 'basicAllocator' is 0, the currently installed default
2102 // allocator is used. The contents of 'value' are moved to the
2103 // newly-created object with 'value' left in a valid but unspecified
2104 // state. 'TYPE' must be the same as one of the types that this
2105 // variant can hold. Note that in C++11 mode, this method does not
2106 // participate in overload resolution if it would lead to ambiguity
2107 // with the move constructor that takes an allocator (below).
2108
2109 /// Create a variant object having the type and value of the specified
2110 /// `original` variant. Optionally specify a `basicAllocator` used to
2111 /// supply memory. If `basicAllocator` is 0, the currently installed
2112 /// default allocator is used.
2113 Variant(const Variant& original, bslma::Allocator *basicAllocator = 0);
2114
2115 /// Create a variant object having the type and value of the specified
2116 /// `original` object by moving the contents of `original` to the
2117 /// newly-created object. The allocator associated with `original` (if
2118 /// any) is propagated for use in the newly-created object. `original`
2119 /// is left in a valid but unspecified state.
2121
2122 /// Create a variant object having the type and value of the specified
2123 /// `original` object that uses the specified `basicAllocator` to supply
2124 /// memory. If `basicAllocator` is 0, the currently installed default
2125 /// allocator is used. The contents of `original` are moved to the
2126 /// newly-created object with `original` left in a valid but unspecified
2127 /// state.
2129 bslma::Allocator *basicAllocator);
2130
2131 // MANIPULATORS
2132
2133 /// Assign to this object the specified `value` of template parameter
2134 /// `TYPE`, and return a reference providing modifiable access to this
2135 /// object. The value currently held by this variant (if any) is
2136 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2137 /// must be the same as one of the types that this variant can hold.
2138 template <class TYPE>
2139 Variant& operator=(const TYPE& value);
2140
2141 template <class TYPE>
2142#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2143 typename bsl::enable_if<
2144 !bsl::is_same<SelfType,
2145 typename bsl::remove_cvref<TYPE>::type>::value,
2146 SelfType>::type&
2147 operator=(TYPE&& value);
2148#else
2149 Variant&
2151#endif
2152 // Assign to this object the specified 'value' of template parameter
2153 // 'TYPE', and return a reference providing modifiable access to this
2154 // object. The contents of 'value' are moved to this object with
2155 // 'value' left in a valid but unspecified state. The value currently
2156 // held by this variant (if any) is destroyed if that value's type is
2157 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2158 // that this variant can hold. Note that in C++11 mode, this method
2159 // does not participate in overload resolution if it would lead to
2160 // ambiguity with the move-assignment operator (below).
2161
2162 /// Assign to this object the type and value currently held by the
2163 /// specified `rhs` object, and return a reference providing modifiable
2164 /// access to this object. The value currently held by this variant
2165 /// (if any) is destroyed if that value's type is not the same as the
2166 /// type held by the `rhs` object.
2167 Variant& operator=(const Variant& rhs);
2168
2169 /// Assign to this object the type and value currently held by the
2170 /// specified `rhs` object, and return a reference providing modifiable
2171 /// access to this object. The value currently held by this variant
2172 /// (if any) is destroyed if that value's type is not the same as the
2173 /// type held by the `rhs` object. The contents of `rhs` are either
2174 /// move-inserted into or move-assigned to this object with `rhs` left
2175 /// in a valid but unspecified state.
2177};
2178
2179 // ===================
2180 // class Variant2<...>
2181 // ===================
2182
2183/// This class is a "specialization" of `Variant` for a fixed number (2) of
2184/// types. Its 2 template arguments *must* all be specified (none are
2185/// defaulted to `bslmf::Nil`). It provides the same functionality as
2186/// `Variant<A1, A2>`.
2187template <class A1, class A2>
2188class Variant2 : public VariantImp<typename bslmf::TypeList2<
2189 A1, A2>::ListType> {
2190
2191 // PRIVATE TYPES
2192 typedef VariantImp<typename bslmf::TypeList2<A1, A2>::ListType> Imp;
2193
2194 /// `SelfType` is an alias to this class.
2195 typedef Variant2<A1, A2> SelfType;
2196
2197 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2198 typedef bslmf::MovableRefUtil MoveUtil;
2199
2200 public:
2201 // TRAITS
2204 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2207 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2210 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2211 BSLMF_NESTED_TRAIT_DECLARATION(Variant2, HasPrintMethod);
2212
2213 // CREATORS
2214
2215 /// Create a variant object in the unset state that uses the currently
2216 /// installed default allocator to supply memory.
2217 Variant2();
2218
2219 /// Create a variant object with the specified `valueOrAllocator` that
2220 /// can be either a value of a type that the variant can hold or an
2221 /// allocator to supply memory. If `valueOrAllocator` is not a
2222 /// `bslma::Allocator *`, then the variant will hold the value and type
2223 /// of `valueOrAllocator`, and use the currently installed default
2224 /// allocator to supply memory. Otherwise, the variant will be unset
2225 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2226 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2227 ///
2228 /// \note Note that this
2229 /// parameterized constructor is defined instead of two constructors
2230 /// (one taking a `bslma::Allocator *` and the other not) because
2231 /// template parameter arguments are always a better match than
2232 /// derived-to-base conversion (a concrete allocator pointer converted
2233 /// to `bslma::Allocator *`).
2234 template <class TYPE_OR_ALLOCATOR>
2235 explicit
2236 Variant2(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2237
2238 /// Create a variant object having the specified `value` of template
2239 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2240 /// supply memory. If `basicAllocator` is 0, the currently installed
2241 /// default allocator is used. `TYPE` must be the same as one of the
2242 /// types that this variant can hold.
2243 template <class TYPE>
2244 Variant2(const TYPE& value, bslma::Allocator *basicAllocator);
2245
2246 template <class TYPE>
2247 explicit
2248#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2249 Variant2(TYPE&& value,
2250 typename bsl::enable_if<
2251 !bsl::is_same<
2252 SelfType,
2253 typename bsl::remove_const<
2254 typename bsl::remove_reference<TYPE>::type>::type>::value
2255 &&
2257 void>::type * = 0);
2258#else
2259 Variant2(bslmf::MovableRef<TYPE> value);
2260#endif
2261 // Create a variant object having the specified 'value' of template
2262 // parameter 'TYPE' by moving the contents of 'value' to the
2263 // newly-created object. Use the currently installed default allocator
2264 // to supply memory. 'value' is left in a valid but unspecified state.
2265 // 'TYPE' must be the same as one of the types that this variant can
2266 // hold. Note that in C++11 mode, this method does not participate in
2267 // overload resolution if it would lead to ambiguity with the move
2268 // constructor that does not take an allocator (below) or with the
2269 // constructor taking a 'valueOrAllocator' (above).
2270
2271 template <class TYPE>
2272#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2273 Variant2(TYPE&& value,
2274 typename bsl::enable_if<
2275 !bsl::is_same<
2276 SelfType,
2277 typename bsl::remove_const<
2278 typename bsl::remove_reference<TYPE>::type>::type>::value,
2279 bslma::Allocator>::type *basicAllocator);
2280#else
2281 Variant2(bslmf::MovableRef<TYPE> value,
2282 bslma::Allocator *basicAllocator);
2283#endif
2284 // Create a variant object having the specified 'value' of template
2285 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2286 // memory. If 'basicAllocator' is 0, the currently installed default
2287 // allocator is used. The contents of 'value' are moved to the
2288 // newly-created object with 'value' left in a valid but unspecified
2289 // state. 'TYPE' must be the same as one of the types that this
2290 // variant can hold. Note that in C++11 mode, this method does not
2291 // participate in overload resolution if it would lead to ambiguity
2292 // with the move constructor that takes an allocator (below).
2293
2294 /// Create a variant object having the type and value of the specified
2295 /// `original` variant. Optionally specify a `basicAllocator` used to
2296 /// supply memory. If `basicAllocator` is 0, the currently installed
2297 /// default allocator is used.
2298 Variant2(const Variant2& original, bslma::Allocator *basicAllocator = 0);
2299
2300 /// Create a variant object having the type and value of the specified
2301 /// `original` object by moving the contents of `original` to the
2302 /// newly-created object. The allocator associated with `original` (if
2303 /// any) is propagated for use in the newly-created object. `original`
2304 /// is left in a valid but unspecified state.
2305 Variant2(bslmf::MovableRef<Variant2> original);
2306
2307 /// Create a variant object having the type and value of the specified
2308 /// `original` object that uses the specified `basicAllocator` to supply
2309 /// memory. If `basicAllocator` is 0, the currently installed default
2310 /// allocator is used. The contents of `original` are moved to the
2311 /// newly-created object with `original` left in a valid but unspecified
2312 /// state.
2313 Variant2(bslmf::MovableRef<Variant2> original,
2314 bslma::Allocator *basicAllocator);
2315
2316 // MANIPULATORS
2317
2318 /// Assign to this object the specified `value` of template parameter
2319 /// `TYPE`, and return a reference providing modifiable access to this
2320 /// object. The value currently held by this variant (if any) is
2321 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2322 /// must be the same as one of the types that this variant can hold.
2323 template <class TYPE>
2324 Variant2& operator=(const TYPE& value);
2325
2326 template <class TYPE>
2327#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2328 typename bsl::enable_if<
2329 !bsl::is_same<SelfType,
2330 typename bsl::remove_cvref<TYPE>::type>::value,
2331 SelfType>::type&
2332 operator=(TYPE&& value);
2333#else
2334 Variant2&
2335 operator=(bslmf::MovableRef<TYPE> value);
2336#endif
2337 // Assign to this object the specified 'value' of template parameter
2338 // 'TYPE', and return a reference providing modifiable access to this
2339 // object. The contents of 'value' are moved to this object with
2340 // 'value' left in a valid but unspecified state. The value currently
2341 // held by this variant (if any) is destroyed if that value's type is
2342 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2343 // that this variant can hold. Note that in C++11 mode, this method
2344 // does not participate in overload resolution if it would lead to
2345 // ambiguity with the move-assignment operator (below).
2346
2347 /// Assign to this object the type and value currently held by the
2348 /// specified `rhs` object, and return a reference providing modifiable
2349 /// access to this object. The value currently held by this variant
2350 /// (if any) is destroyed if that value's type is not the same as the
2351 /// type held by the `rhs` object.
2352 Variant2& operator=(const Variant2& rhs);
2353
2354 /// Assign to this object the type and value currently held by the
2355 /// specified `rhs` object, and return a reference providing modifiable
2356 /// access to this object. The value currently held by this variant
2357 /// (if any) is destroyed if that value's type is not the same as the
2358 /// type held by the `rhs` object. The contents of `rhs` are either
2359 /// move-inserted into or move-assigned to this object with `rhs` left
2360 /// in a valid but unspecified state.
2361 Variant2& operator=(bslmf::MovableRef<Variant2> rhs);
2362};
2363
2364 // ===================
2365 // class Variant3<...>
2366 // ===================
2367
2368/// This class is a "specialization" of `Variant` for a fixed number (3) of
2369/// types. Its 3 template arguments *must* all be specified (none are
2370/// defaulted to `bslmf::Nil`). It provides the same functionality as
2371/// `Variant<A1, A2, A3>`.
2372template <class A1, class A2, class A3>
2373class Variant3 : public VariantImp<typename bslmf::TypeList3<
2374 A1, A2, A3>::ListType> {
2375
2376 // PRIVATE TYPES
2377 typedef VariantImp<typename bslmf::TypeList3<A1, A2,
2378 A3>::ListType> Imp;
2379
2380 /// `SelfType` is an alias to this class.
2381 typedef Variant3<A1, A2, A3> SelfType;
2382
2383 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2384 typedef bslmf::MovableRefUtil MoveUtil;
2385
2386 public:
2387 // TRAITS
2390 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2393 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2396 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2397 BSLMF_NESTED_TRAIT_DECLARATION(Variant3, HasPrintMethod);
2398
2399 // CREATORS
2400
2401 /// Create a variant object in the unset state that uses the currently
2402 /// installed default allocator to supply memory.
2403 Variant3();
2404
2405 /// Create a variant object with the specified `valueOrAllocator` that
2406 /// can be either a value of a type that the variant can hold or an
2407 /// allocator to supply memory. If `valueOrAllocator` is not a
2408 /// `bslma::Allocator *`, then the variant will hold the value and type
2409 /// of `valueOrAllocator`, and use the currently installed default
2410 /// allocator to supply memory. Otherwise, the variant will be unset
2411 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2412 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2413 ///
2414 /// \note Note that this
2415 /// parameterized constructor is defined instead of two constructors
2416 /// (one taking a `bslma::Allocator *` and the other not) because
2417 /// template parameter arguments are always a better match than
2418 /// derived-to-base conversion (a concrete allocator pointer converted
2419 /// to `bslma::Allocator *`).
2420 template <class TYPE_OR_ALLOCATOR>
2421 explicit
2422 Variant3(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2423
2424 /// Create a variant object having the specified `value` of template
2425 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2426 /// supply memory. If `basicAllocator` is 0, the currently installed
2427 /// default allocator is used. `TYPE` must be the same as one of the
2428 /// types that this variant can hold.
2429 template <class TYPE>
2430 Variant3(const TYPE& value, bslma::Allocator *basicAllocator);
2431
2432 template <class TYPE>
2433 explicit
2434#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2435 Variant3(TYPE&& value,
2436 typename bsl::enable_if<
2437 !bsl::is_same<
2438 SelfType,
2439 typename bsl::remove_const<
2440 typename bsl::remove_reference<TYPE>::type>::type>::value
2441 &&
2443 void>::type * = 0);
2444#else
2445 Variant3(bslmf::MovableRef<TYPE> value);
2446#endif
2447 // Create a variant object having the specified 'value' of template
2448 // parameter 'TYPE' by moving the contents of 'value' to the
2449 // newly-created object. Use the currently installed default allocator
2450 // to supply memory. 'value' is left in a valid but unspecified state.
2451 // 'TYPE' must be the same as one of the types that this variant can
2452 // hold. Note that in C++11 mode, this method does not participate in
2453 // overload resolution if it would lead to ambiguity with the move
2454 // constructor that does not take an allocator (below) or with the
2455 // constructor taking a 'valueOrAllocator' (above).
2456
2457 template <class TYPE>
2458#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2459 Variant3(TYPE&& value,
2460 typename bsl::enable_if<
2461 !bsl::is_same<
2462 SelfType,
2463 typename bsl::remove_const<
2464 typename bsl::remove_reference<TYPE>::type>::type>::value,
2465 bslma::Allocator>::type *basicAllocator);
2466#else
2467 Variant3(bslmf::MovableRef<TYPE> value,
2468 bslma::Allocator *basicAllocator);
2469#endif
2470 // Create a variant object having the specified 'value' of template
2471 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2472 // memory. If 'basicAllocator' is 0, the currently installed default
2473 // allocator is used. The contents of 'value' are moved to the
2474 // newly-created object with 'value' left in a valid but unspecified
2475 // state. 'TYPE' must be the same as one of the types that this
2476 // variant can hold. Note that in C++11 mode, this method does not
2477 // participate in overload resolution if it would lead to ambiguity
2478 // with the move constructor that takes an allocator (below).
2479
2480 /// Create a variant object having the type and value of the specified
2481 /// `original` variant. Optionally specify a `basicAllocator` used to
2482 /// supply memory. If `basicAllocator` is 0, the currently installed
2483 /// default allocator is used.
2484 Variant3(const Variant3& original, bslma::Allocator *basicAllocator = 0);
2485
2486 /// Create a variant object having the type and value of the specified
2487 /// `original` object by moving the contents of `original` to the
2488 /// newly-created object. The allocator associated with `original` (if
2489 /// any) is propagated for use in the newly-created object. `original`
2490 /// is left in a valid but unspecified state.
2491 Variant3(bslmf::MovableRef<Variant3> original);
2492
2493 /// Create a variant object having the type and value of the specified
2494 /// `original` object that uses the specified `basicAllocator` to supply
2495 /// memory. If `basicAllocator` is 0, the currently installed default
2496 /// allocator is used. The contents of `original` are moved to the
2497 /// newly-created object with `original` left in a valid but unspecified
2498 /// state.
2499 Variant3(bslmf::MovableRef<Variant3> original,
2500 bslma::Allocator *basicAllocator);
2501
2502 // MANIPULATORS
2503
2504 /// Assign to this object the specified `value` of template parameter
2505 /// `TYPE`, and return a reference providing modifiable access to this
2506 /// object. The value currently held by this variant (if any) is
2507 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2508 /// must be the same as one of the types that this variant can hold.
2509 template <class TYPE>
2510 Variant3& operator=(const TYPE& value);
2511
2512 template <class TYPE>
2513#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2514 typename bsl::enable_if<
2515 !bsl::is_same<SelfType,
2516 typename bsl::remove_cvref<TYPE>::type>::value,
2517 SelfType>::type&
2518 operator=(TYPE&& value);
2519#else
2520 Variant3&
2521 operator=(bslmf::MovableRef<TYPE> value);
2522#endif
2523 // Assign to this object the specified 'value' of template parameter
2524 // 'TYPE', and return a reference providing modifiable access to this
2525 // object. The contents of 'value' are moved to this object with
2526 // 'value' left in a valid but unspecified state. The value currently
2527 // held by this variant (if any) is destroyed if that value's type is
2528 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2529 // that this variant can hold. Note that in C++11 mode, this method
2530 // does not participate in overload resolution if it would lead to
2531 // ambiguity with the move-assignment operator (below).
2532
2533 /// Assign to this object the type and value currently held by the
2534 /// specified `rhs` object, and return a reference providing modifiable
2535 /// access to this object. The value currently held by this variant
2536 /// (if any) is destroyed if that value's type is not the same as the
2537 /// type held by the `rhs` object.
2538 Variant3& operator=(const Variant3& rhs);
2539
2540 /// Assign to this object the type and value currently held by the
2541 /// specified `rhs` object, and return a reference providing modifiable
2542 /// access to this object. The value currently held by this variant
2543 /// (if any) is destroyed if that value's type is not the same as the
2544 /// type held by the `rhs` object. The contents of `rhs` are either
2545 /// move-inserted into or move-assigned to this object with `rhs` left
2546 /// in a valid but unspecified state.
2547 Variant3& operator=(bslmf::MovableRef<Variant3> rhs);
2548};
2549
2550 // ===================
2551 // class Variant4<...>
2552 // ===================
2553
2554/// This class is a "specialization" of `Variant` for a fixed number (4) of
2555/// types. Its 4 template arguments *must* all be specified (none are
2556/// defaulted to `bslmf::Nil`). It provides the same functionality as
2557/// `Variant<A1, A2, ..., A4>`.
2558template <class A1, class A2, class A3, class A4>
2559class Variant4 : public VariantImp<typename bslmf::TypeList4<
2560 A1, A2, A3, A4>::ListType> {
2561
2562 // PRIVATE TYPES
2563 typedef VariantImp<typename bslmf::TypeList4<A1, A2, A3,
2564 A4>::ListType> Imp;
2565
2566 /// `SelfType` is an alias to this class.
2567 typedef Variant4<A1, A2, A3, A4> SelfType;
2568
2569 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2570 typedef bslmf::MovableRefUtil MoveUtil;
2571
2572 public:
2573 // TRAITS
2576 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2579 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2582 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2583 BSLMF_NESTED_TRAIT_DECLARATION(Variant4, HasPrintMethod);
2584
2585 // CREATORS
2586
2587 /// Create a variant object in the unset state that uses the currently
2588 /// installed default allocator to supply memory.
2589 Variant4();
2590
2591 /// Create a variant object with the specified `valueOrAllocator` that
2592 /// can be either a value of a type that the variant can hold or an
2593 /// allocator to supply memory. If `valueOrAllocator` is not a
2594 /// `bslma::Allocator *`, then the variant will hold the value and type
2595 /// of `valueOrAllocator`, and use the currently installed default
2596 /// allocator to supply memory. Otherwise, the variant will be unset
2597 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2598 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2599 ///
2600 /// \note Note that this
2601 /// parameterized constructor is defined instead of two constructors
2602 /// (one taking a `bslma::Allocator *` and the other not) because
2603 /// template parameter arguments are always a better match than
2604 /// derived-to-base conversion (a concrete allocator pointer converted
2605 /// to `bslma::Allocator *`).
2606 template <class TYPE_OR_ALLOCATOR>
2607 explicit
2608 Variant4(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2609
2610 /// Create a variant object having the specified `value` of template
2611 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2612 /// supply memory. If `basicAllocator` is 0, the currently installed
2613 /// default allocator is used. `TYPE` must be the same as one of the
2614 /// types that this variant can hold.
2615 template <class TYPE>
2616 Variant4(const TYPE& value, bslma::Allocator *basicAllocator);
2617
2618 template <class TYPE>
2619 explicit
2620#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2621 Variant4(TYPE&& value,
2622 typename bsl::enable_if<
2623 !bsl::is_same<
2624 SelfType,
2625 typename bsl::remove_const<
2626 typename bsl::remove_reference<TYPE>::type>::type>::value
2627 &&
2629 void>::type * = 0);
2630#else
2631 Variant4(bslmf::MovableRef<TYPE> value);
2632#endif
2633 // Create a variant object having the specified 'value' of template
2634 // parameter 'TYPE' by moving the contents of 'value' to the
2635 // newly-created object. Use the currently installed default allocator
2636 // to supply memory. 'value' is left in a valid but unspecified state.
2637 // 'TYPE' must be the same as one of the types that this variant can
2638 // hold. Note that in C++11 mode, this method does not participate in
2639 // overload resolution if it would lead to ambiguity with the move
2640 // constructor that does not take an allocator (below) or with the
2641 // constructor taking a 'valueOrAllocator' (above).
2642
2643 template <class TYPE>
2644#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2645 Variant4(TYPE&& value,
2646 typename bsl::enable_if<
2647 !bsl::is_same<
2648 SelfType,
2649 typename bsl::remove_const<
2650 typename bsl::remove_reference<TYPE>::type>::type>::value,
2651 bslma::Allocator>::type *basicAllocator);
2652#else
2653 Variant4(bslmf::MovableRef<TYPE> value,
2654 bslma::Allocator *basicAllocator);
2655#endif
2656 // Create a variant object having the specified 'value' of template
2657 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2658 // memory. If 'basicAllocator' is 0, the currently installed default
2659 // allocator is used. The contents of 'value' are moved to the
2660 // newly-created object with 'value' left in a valid but unspecified
2661 // state. 'TYPE' must be the same as one of the types that this
2662 // variant can hold. Note that in C++11 mode, this method does not
2663 // participate in overload resolution if it would lead to ambiguity
2664 // with the move constructor that takes an allocator (below).
2665
2666 /// Create a variant object having the type and value of the specified
2667 /// `original` variant. Optionally specify a `basicAllocator` used to
2668 /// supply memory. If `basicAllocator` is 0, the currently installed
2669 /// default allocator is used.
2670 Variant4(const Variant4& original, bslma::Allocator *basicAllocator = 0);
2671
2672 /// Create a variant object having the type and value of the specified
2673 /// `original` object by moving the contents of `original` to the
2674 /// newly-created object. The allocator associated with `original` (if
2675 /// any) is propagated for use in the newly-created object. `original`
2676 /// is left in a valid but unspecified state.
2677 Variant4(bslmf::MovableRef<Variant4> original);
2678
2679 /// Create a variant object having the type and value of the specified
2680 /// `original` object that uses the specified `basicAllocator` to supply
2681 /// memory. If `basicAllocator` is 0, the currently installed default
2682 /// allocator is used. The contents of `original` are moved to the
2683 /// newly-created object with `original` left in a valid but unspecified
2684 /// state.
2685 Variant4(bslmf::MovableRef<Variant4> original,
2686 bslma::Allocator *basicAllocator);
2687
2688 // MANIPULATORS
2689
2690 /// Assign to this object the specified `value` of template parameter
2691 /// `TYPE`, and return a reference providing modifiable access to this
2692 /// object. The value currently held by this variant (if any) is
2693 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2694 /// must be the same as one of the types that this variant can hold.
2695 template <class TYPE>
2696 Variant4& operator=(const TYPE& value);
2697
2698 template <class TYPE>
2699#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2700 typename bsl::enable_if<
2701 !bsl::is_same<SelfType,
2702 typename bsl::remove_cvref<TYPE>::type>::value,
2703 SelfType>::type&
2704 operator=(TYPE&& value);
2705#else
2706 Variant4&
2707 operator=(bslmf::MovableRef<TYPE> value);
2708#endif
2709 // Assign to this object the specified 'value' of template parameter
2710 // 'TYPE', and return a reference providing modifiable access to this
2711 // object. The contents of 'value' are moved to this object with
2712 // 'value' left in a valid but unspecified state. The value currently
2713 // held by this variant (if any) is destroyed if that value's type is
2714 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2715 // that this variant can hold. Note that in C++11 mode, this method
2716 // does not participate in overload resolution if it would lead to
2717 // ambiguity with the move-assignment operator (below).
2718
2719 /// Assign to this object the type and value currently held by the
2720 /// specified `rhs` object, and return a reference providing modifiable
2721 /// access to this object. The value currently held by this variant
2722 /// (if any) is destroyed if that value's type is not the same as the
2723 /// type held by the `rhs` object.
2724 Variant4& operator=(const Variant4& rhs);
2725
2726 /// Assign to this object the type and value currently held by the
2727 /// specified `rhs` object, and return a reference providing modifiable
2728 /// access to this object. The value currently held by this variant
2729 /// (if any) is destroyed if that value's type is not the same as the
2730 /// type held by the `rhs` object. The contents of `rhs` are either
2731 /// move-inserted into or move-assigned to this object with `rhs` left
2732 /// in a valid but unspecified state.
2733 Variant4& operator=(bslmf::MovableRef<Variant4> rhs);
2734};
2735
2736 // ===================
2737 // class Variant5<...>
2738 // ===================
2739
2740/// This class is a "specialization" of `Variant` for a fixed number (5) of
2741/// types. Its 5 template arguments *must* all be specified (none are
2742/// defaulted to `bslmf::Nil`). It provides the same functionality as
2743/// `Variant<A1, A2, ..., A5>`.
2744template <class A1, class A2, class A3, class A4, class A5>
2745class Variant5 : public VariantImp<typename bslmf::TypeList5<
2746 A1, A2, A3, A4, A5>::ListType> {
2747
2748 // PRIVATE TYPES
2749 typedef VariantImp<typename bslmf::TypeList5<A1, A2, A3, A4,
2750 A5>::ListType> Imp;
2751
2752 /// `SelfType` is an alias to this class.
2753 typedef Variant5<A1, A2, A3, A4, A5> SelfType;
2754
2755 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2756 typedef bslmf::MovableRefUtil MoveUtil;
2757
2758 public:
2759 // TRAITS
2762 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2765 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2768 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2769 BSLMF_NESTED_TRAIT_DECLARATION(Variant5, HasPrintMethod);
2770
2771 // CREATORS
2772
2773 /// Create a variant object in the unset state that uses the currently
2774 /// installed default allocator to supply memory.
2775 Variant5();
2776
2777 /// Create a variant object with the specified `valueOrAllocator` that
2778 /// can be either a value of a type that the variant can hold or an
2779 /// allocator to supply memory. If `valueOrAllocator` is not a
2780 /// `bslma::Allocator *`, then the variant will hold the value and type
2781 /// of `valueOrAllocator`, and use the currently installed default
2782 /// allocator to supply memory. Otherwise, the variant will be unset
2783 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2784 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2785 ///
2786 /// \note Note that this
2787 /// parameterized constructor is defined instead of two constructors
2788 /// (one taking a `bslma::Allocator *` and the other not) because
2789 /// template parameter arguments are always a better match than
2790 /// derived-to-base conversion (a concrete allocator pointer converted
2791 /// to `bslma::Allocator *`).
2792 template <class TYPE_OR_ALLOCATOR>
2793 explicit
2794 Variant5(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2795
2796 /// Create a variant object having the specified `value` of template
2797 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2798 /// supply memory. If `basicAllocator` is 0, the currently installed
2799 /// default allocator is used. `TYPE` must be the same as one of the
2800 /// types that this variant can hold.
2801 template <class TYPE>
2802 Variant5(const TYPE& value, bslma::Allocator *basicAllocator);
2803
2804 template <class TYPE>
2805 explicit
2806#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2807 Variant5(TYPE&& value,
2808 typename bsl::enable_if<
2809 !bsl::is_same<
2810 SelfType,
2811 typename bsl::remove_const<
2812 typename bsl::remove_reference<TYPE>::type>::type>::value
2813 &&
2815 void>::type * = 0);
2816#else
2817 Variant5(bslmf::MovableRef<TYPE> value);
2818#endif
2819 // Create a variant object having the specified 'value' of template
2820 // parameter 'TYPE' by moving the contents of 'value' to the
2821 // newly-created object. Use the currently installed default allocator
2822 // to supply memory. 'value' is left in a valid but unspecified state.
2823 // 'TYPE' must be the same as one of the types that this variant can
2824 // hold. Note that in C++11 mode, this method does not participate in
2825 // overload resolution if it would lead to ambiguity with the move
2826 // constructor that does not take an allocator (below) or with the
2827 // constructor taking a 'valueOrAllocator' (above).
2828
2829 template <class TYPE>
2830#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2831 Variant5(TYPE&& value,
2832 typename bsl::enable_if<
2833 !bsl::is_same<
2834 SelfType,
2835 typename bsl::remove_const<
2836 typename bsl::remove_reference<TYPE>::type>::type>::value,
2837 bslma::Allocator>::type *basicAllocator);
2838#else
2839 Variant5(bslmf::MovableRef<TYPE> value,
2840 bslma::Allocator *basicAllocator);
2841#endif
2842 // Create a variant object having the specified 'value' of template
2843 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
2844 // memory. If 'basicAllocator' is 0, the currently installed default
2845 // allocator is used. The contents of 'value' are moved to the
2846 // newly-created object with 'value' left in a valid but unspecified
2847 // state. 'TYPE' must be the same as one of the types that this
2848 // variant can hold. Note that in C++11 mode, this method does not
2849 // participate in overload resolution if it would lead to ambiguity
2850 // with the move constructor that takes an allocator (below).
2851
2852 /// Create a variant object having the type and value of the specified
2853 /// `original` variant. Optionally specify a `basicAllocator` used to
2854 /// supply memory. If `basicAllocator` is 0, the currently installed
2855 /// default allocator is used.
2856 Variant5(const Variant5& original, bslma::Allocator *basicAllocator = 0);
2857
2858 /// Create a variant object having the type and value of the specified
2859 /// `original` object by moving the contents of `original` to the
2860 /// newly-created object. The allocator associated with `original` (if
2861 /// any) is propagated for use in the newly-created object. `original`
2862 /// is left in a valid but unspecified state.
2863 Variant5(bslmf::MovableRef<Variant5> original);
2864
2865 /// Create a variant object having the type and value of the specified
2866 /// `original` object that uses the specified `basicAllocator` to supply
2867 /// memory. If `basicAllocator` is 0, the currently installed default
2868 /// allocator is used. The contents of `original` are moved to the
2869 /// newly-created object with `original` left in a valid but unspecified
2870 /// state.
2871 Variant5(bslmf::MovableRef<Variant5> original,
2872 bslma::Allocator *basicAllocator);
2873
2874 // MANIPULATORS
2875
2876 /// Assign to this object the specified `value` of template parameter
2877 /// `TYPE`, and return a reference providing modifiable access to this
2878 /// object. The value currently held by this variant (if any) is
2879 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
2880 /// must be the same as one of the types that this variant can hold.
2881 template <class TYPE>
2882 Variant5& operator=(const TYPE& value);
2883
2884 template <class TYPE>
2885#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2886 typename bsl::enable_if<
2887 !bsl::is_same<SelfType,
2888 typename bsl::remove_cvref<TYPE>::type>::value,
2889 SelfType>::type&
2890 operator=(TYPE&& value);
2891#else
2892 Variant5&
2893 operator=(bslmf::MovableRef<TYPE> value);
2894#endif
2895 // Assign to this object the specified 'value' of template parameter
2896 // 'TYPE', and return a reference providing modifiable access to this
2897 // object. The contents of 'value' are moved to this object with
2898 // 'value' left in a valid but unspecified state. The value currently
2899 // held by this variant (if any) is destroyed if that value's type is
2900 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
2901 // that this variant can hold. Note that in C++11 mode, this method
2902 // does not participate in overload resolution if it would lead to
2903 // ambiguity with the move-assignment operator (below).
2904
2905 /// Assign to this object the type and value currently held by the
2906 /// specified `rhs` object, and return a reference providing modifiable
2907 /// access to this object. The value currently held by this variant
2908 /// (if any) is destroyed if that value's type is not the same as the
2909 /// type held by the `rhs` object.
2910 Variant5& operator=(const Variant5& rhs);
2911
2912 /// Assign to this object the type and value currently held by the
2913 /// specified `rhs` object, and return a reference providing modifiable
2914 /// access to this object. The value currently held by this variant
2915 /// (if any) is destroyed if that value's type is not the same as the
2916 /// type held by the `rhs` object. The contents of `rhs` are either
2917 /// move-inserted into or move-assigned to this object with `rhs` left
2918 /// in a valid but unspecified state.
2919 Variant5& operator=(bslmf::MovableRef<Variant5> rhs);
2920};
2921
2922 // ===================
2923 // class Variant6<...>
2924 // ===================
2925
2926/// This class is a "specialization" of `Variant` for a fixed number (6) of
2927/// types. Its 6 template arguments *must* all be specified (none are
2928/// defaulted to `bslmf::Nil`). It provides the same functionality as
2929/// `Variant<A1, A2, ..., A6>`.
2930template <class A1, class A2, class A3, class A4, class A5, class A6>
2931class Variant6 : public VariantImp<typename bslmf::TypeList6<
2932 A1, A2, A3, A4, A5, A6>::ListType> {
2933
2934 // PRIVATE TYPES
2935 typedef VariantImp<typename bslmf::TypeList6<A1, A2, A3, A4, A5,
2936 A6>::ListType> Imp;
2937
2938 /// `SelfType` is an alias to this class.
2939 typedef Variant6<A1, A2, A3, A4, A5, A6> SelfType;
2940
2941 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
2942 typedef bslmf::MovableRefUtil MoveUtil;
2943
2944 public:
2945 // TRAITS
2948 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
2951 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
2954 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
2955 BSLMF_NESTED_TRAIT_DECLARATION(Variant6, HasPrintMethod);
2956
2957 // CREATORS
2958
2959 /// Create a variant object in the unset state that uses the currently
2960 /// installed default allocator to supply memory.
2961 Variant6();
2962
2963 /// Create a variant object with the specified `valueOrAllocator` that
2964 /// can be either a value of a type that the variant can hold or an
2965 /// allocator to supply memory. If `valueOrAllocator` is not a
2966 /// `bslma::Allocator *`, then the variant will hold the value and type
2967 /// of `valueOrAllocator`, and use the currently installed default
2968 /// allocator to supply memory. Otherwise, the variant will be unset
2969 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
2970 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
2971 ///
2972 /// \note Note that this
2973 /// parameterized constructor is defined instead of two constructors
2974 /// (one taking a `bslma::Allocator *` and the other not) because
2975 /// template parameter arguments are always a better match than
2976 /// derived-to-base conversion (a concrete allocator pointer converted
2977 /// to `bslma::Allocator *`).
2978 template <class TYPE_OR_ALLOCATOR>
2979 explicit
2980 Variant6(const TYPE_OR_ALLOCATOR& valueOrAllocator);
2981
2982 /// Create a variant object having the specified `value` of template
2983 /// parameter `TYPE` and that uses the specified `basicAllocator` to
2984 /// supply memory. If `basicAllocator` is 0, the currently installed
2985 /// default allocator is used. `TYPE` must be the same as one of the
2986 /// types that this variant can hold.
2987 template <class TYPE>
2988 Variant6(const TYPE& value, bslma::Allocator *basicAllocator);
2989
2990 template <class TYPE>
2991 explicit
2992#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
2993 Variant6(TYPE&& value,
2994 typename bsl::enable_if<
2995 !bsl::is_same<
2996 SelfType,
2997 typename bsl::remove_const<
2998 typename bsl::remove_reference<TYPE>::type>::type>::value
2999 &&
3001 void>::type * = 0);
3002#else
3003 Variant6(bslmf::MovableRef<TYPE> value);
3004#endif
3005 // Create a variant object having the specified 'value' of template
3006 // parameter 'TYPE' by moving the contents of 'value' to the
3007 // newly-created object. Use the currently installed default allocator
3008 // to supply memory. 'value' is left in a valid but unspecified state.
3009 // 'TYPE' must be the same as one of the types that this variant can
3010 // hold. Note that in C++11 mode, this method does not participate in
3011 // overload resolution if it would lead to ambiguity with the move
3012 // constructor that does not take an allocator (below) or with the
3013 // constructor taking a 'valueOrAllocator' (above).
3014
3015 template <class TYPE>
3016#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3017 Variant6(TYPE&& value,
3018 typename bsl::enable_if<
3019 !bsl::is_same<
3020 SelfType,
3021 typename bsl::remove_const<
3022 typename bsl::remove_reference<TYPE>::type>::type>::value,
3023 bslma::Allocator>::type *basicAllocator);
3024#else
3025 Variant6(bslmf::MovableRef<TYPE> value,
3026 bslma::Allocator *basicAllocator);
3027#endif
3028 // Create a variant object having the specified 'value' of template
3029 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3030 // memory. If 'basicAllocator' is 0, the currently installed default
3031 // allocator is used. The contents of 'value' are moved to the
3032 // newly-created object with 'value' left in a valid but unspecified
3033 // state. 'TYPE' must be the same as one of the types that this
3034 // variant can hold. Note that in C++11 mode, this method does not
3035 // participate in overload resolution if it would lead to ambiguity
3036 // with the move constructor that takes an allocator (below).
3037
3038 /// Create a variant object having the type and value of the specified
3039 /// `original` variant. Optionally specify a `basicAllocator` used to
3040 /// supply memory. If `basicAllocator` is 0, the currently installed
3041 /// default allocator is used.
3042 Variant6(const Variant6& original, bslma::Allocator *basicAllocator = 0);
3043
3044 /// Create a variant object having the type and value of the specified
3045 /// `original` object by moving the contents of `original` to the
3046 /// newly-created object. The allocator associated with `original` (if
3047 /// any) is propagated for use in the newly-created object. `original`
3048 /// is left in a valid but unspecified state.
3049 Variant6(bslmf::MovableRef<Variant6> original);
3050
3051 /// Create a variant object having the type and value of the specified
3052 /// `original` object that uses the specified `basicAllocator` to supply
3053 /// memory. If `basicAllocator` is 0, the currently installed default
3054 /// allocator is used. The contents of `original` are moved to the
3055 /// newly-created object with `original` left in a valid but unspecified
3056 /// state.
3057 Variant6(bslmf::MovableRef<Variant6> original,
3058 bslma::Allocator *basicAllocator);
3059
3060 // MANIPULATORS
3061
3062 /// Assign to this object the specified `value` of template parameter
3063 /// `TYPE`, and return a reference providing modifiable access to this
3064 /// object. The value currently held by this variant (if any) is
3065 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3066 /// must be the same as one of the types that this variant can hold.
3067 template <class TYPE>
3068 Variant6& operator=(const TYPE& value);
3069
3070 template <class TYPE>
3071#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3072 typename bsl::enable_if<
3073 !bsl::is_same<SelfType,
3074 typename bsl::remove_cvref<TYPE>::type>::value,
3075 SelfType>::type&
3076 operator=(TYPE&& value);
3077#else
3078 Variant6&
3079 operator=(bslmf::MovableRef<TYPE> value);
3080#endif
3081 // Assign to this object the specified 'value' of template parameter
3082 // 'TYPE', and return a reference providing modifiable access to this
3083 // object. The contents of 'value' are moved to this object with
3084 // 'value' left in a valid but unspecified state. The value currently
3085 // held by this variant (if any) is destroyed if that value's type is
3086 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3087 // that this variant can hold. Note that in C++11 mode, this method
3088 // does not participate in overload resolution if it would lead to
3089 // ambiguity with the move-assignment operator (below).
3090
3091 /// Assign to this object the type and value currently held by the
3092 /// specified `rhs` object, and return a reference providing modifiable
3093 /// access to this object. The value currently held by this variant
3094 /// (if any) is destroyed if that value's type is not the same as the
3095 /// type held by the `rhs` object.
3096 Variant6& operator=(const Variant6& rhs);
3097
3098 /// Assign to this object the type and value currently held by the
3099 /// specified `rhs` object, and return a reference providing modifiable
3100 /// access to this object. The value currently held by this variant
3101 /// (if any) is destroyed if that value's type is not the same as the
3102 /// type held by the `rhs` object. The contents of `rhs` are either
3103 /// move-inserted into or move-assigned to this object with `rhs` left
3104 /// in a valid but unspecified state.
3105 Variant6& operator=(bslmf::MovableRef<Variant6> rhs);
3106};
3107
3108 // ===================
3109 // class Variant7<...>
3110 // ===================
3111
3112/// This class is a "specialization" of `Variant` for a fixed number (7) of
3113/// types. Its 7 template arguments *must* all be specified (none are
3114/// defaulted to `bslmf::Nil`). It provides the same functionality as
3115/// `Variant<A1, A2, ..., A7>`.
3116template <class A1, class A2, class A3, class A4, class A5, class A6,
3117 class A7>
3118class Variant7 : public VariantImp<typename bslmf::TypeList7<
3119 A1, A2, A3, A4, A5, A6, A7>::ListType> {
3120
3121 // PRIVATE TYPES
3122 typedef VariantImp<typename bslmf::TypeList7<A1, A2, A3, A4, A5, A6,
3123 A7>::ListType> Imp;
3124
3125 /// `SelfType` is an alias to this class.
3126 typedef Variant7<A1, A2, A3, A4, A5, A6, A7> SelfType;
3127
3128 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
3129 typedef bslmf::MovableRefUtil MoveUtil;
3130
3131 public:
3132 // TRAITS
3135 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3138 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3141 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3142 BSLMF_NESTED_TRAIT_DECLARATION(Variant7, HasPrintMethod);
3143
3144 // CREATORS
3145
3146 /// Create a variant object in the unset state that uses the currently
3147 /// installed default allocator to supply memory.
3148 Variant7();
3149
3150 /// Create a variant object with the specified `valueOrAllocator` that
3151 /// can be either a value of a type that the variant can hold or an
3152 /// allocator to supply memory. If `valueOrAllocator` is not a
3153 /// `bslma::Allocator *`, then the variant will hold the value and type
3154 /// of `valueOrAllocator`, and use the currently installed default
3155 /// allocator to supply memory. Otherwise, the variant will be unset
3156 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3157 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3158 ///
3159 /// \note Note that this
3160 /// parameterized constructor is defined instead of two constructors
3161 /// (one taking a `bslma::Allocator *` and the other not) because
3162 /// template parameter arguments are always a better match than
3163 /// derived-to-base conversion (a concrete allocator pointer converted
3164 /// to `bslma::Allocator *`).
3165 template <class TYPE_OR_ALLOCATOR>
3166 explicit
3167 Variant7(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3168
3169 /// Create a variant object having the specified `value` of template
3170 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3171 /// supply memory. If `basicAllocator` is 0, the currently installed
3172 /// default allocator is used. `TYPE` must be the same as one of the
3173 /// types that this variant can hold.
3174 template <class TYPE>
3175 Variant7(const TYPE& value, bslma::Allocator *basicAllocator);
3176
3177 template <class TYPE>
3178 explicit
3179#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3180 Variant7(TYPE&& value,
3181 typename bsl::enable_if<
3182 !bsl::is_same<
3183 SelfType,
3184 typename bsl::remove_const<
3185 typename bsl::remove_reference<TYPE>::type>::type>::value
3186 &&
3188 void>::type * = 0);
3189#else
3190 Variant7(bslmf::MovableRef<TYPE> value);
3191#endif
3192 // Create a variant object having the specified 'value' of template
3193 // parameter 'TYPE' by moving the contents of 'value' to the
3194 // newly-created object. Use the currently installed default allocator
3195 // to supply memory. 'value' is left in a valid but unspecified state.
3196 // 'TYPE' must be the same as one of the types that this variant can
3197 // hold. Note that in C++11 mode, this method does not participate in
3198 // overload resolution if it would lead to ambiguity with the move
3199 // constructor that does not take an allocator (below) or with the
3200 // constructor taking a 'valueOrAllocator' (above).
3201
3202 template <class TYPE>
3203#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3204 Variant7(TYPE&& value,
3205 typename bsl::enable_if<
3206 !bsl::is_same<
3207 SelfType,
3208 typename bsl::remove_const<
3209 typename bsl::remove_reference<TYPE>::type>::type>::value,
3210 bslma::Allocator>::type *basicAllocator);
3211#else
3212 Variant7(bslmf::MovableRef<TYPE> value,
3213 bslma::Allocator *basicAllocator);
3214#endif
3215 // Create a variant object having the specified 'value' of template
3216 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3217 // memory. If 'basicAllocator' is 0, the currently installed default
3218 // allocator is used. The contents of 'value' are moved to the
3219 // newly-created object with 'value' left in a valid but unspecified
3220 // state. 'TYPE' must be the same as one of the types that this
3221 // variant can hold. Note that in C++11 mode, this method does not
3222 // participate in overload resolution if it would lead to ambiguity
3223 // with the move constructor that takes an allocator (below).
3224
3225 /// Create a variant object having the type and value of the specified
3226 /// `original` variant. Optionally specify a `basicAllocator` used to
3227 /// supply memory. If `basicAllocator` is 0, the currently installed
3228 /// default allocator is used.
3229 Variant7(const Variant7& original, bslma::Allocator *basicAllocator = 0);
3230
3231 /// Create a variant object having the type and value of the specified
3232 /// `original` object by moving the contents of `original` to the
3233 /// newly-created object. The allocator associated with `original` (if
3234 /// any) is propagated for use in the newly-created object. `original`
3235 /// is left in a valid but unspecified state.
3236 Variant7(bslmf::MovableRef<Variant7> original);
3237
3238 /// Create a variant object having the type and value of the specified
3239 /// `original` object that uses the specified `basicAllocator` to supply
3240 /// memory. If `basicAllocator` is 0, the currently installed default
3241 /// allocator is used. The contents of `original` are moved to the
3242 /// newly-created object with `original` left in a valid but unspecified
3243 /// state.
3244 Variant7(bslmf::MovableRef<Variant7> original,
3245 bslma::Allocator *basicAllocator);
3246
3247 // MANIPULATORS
3248
3249 /// Assign to this object the specified `value` of template parameter
3250 /// `TYPE`, and return a reference providing modifiable access to this
3251 /// object. The value currently held by this variant (if any) is
3252 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3253 /// must be the same as one of the types that this variant can hold.
3254 template <class TYPE>
3255 Variant7& operator=(const TYPE& value);
3256
3257 template <class TYPE>
3258#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3259 typename bsl::enable_if<
3260 !bsl::is_same<SelfType,
3261 typename bsl::remove_cvref<TYPE>::type>::value,
3262 SelfType>::type&
3263 operator=(TYPE&& value);
3264#else
3265 Variant7&
3266 operator=(bslmf::MovableRef<TYPE> value);
3267#endif
3268 // Assign to this object the specified 'value' of template parameter
3269 // 'TYPE', and return a reference providing modifiable access to this
3270 // object. The contents of 'value' are moved to this object with
3271 // 'value' left in a valid but unspecified state. The value currently
3272 // held by this variant (if any) is destroyed if that value's type is
3273 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3274 // that this variant can hold. Note that in C++11 mode, this method
3275 // does not participate in overload resolution if it would lead to
3276 // ambiguity with the move-assignment operator (below).
3277
3278 /// Assign to this object the type and value currently held by the
3279 /// specified `rhs` object, and return a reference providing modifiable
3280 /// access to this object. The value currently held by this variant
3281 /// (if any) is destroyed if that value's type is not the same as the
3282 /// type held by the `rhs` object.
3283 Variant7& operator=(const Variant7& rhs);
3284
3285 /// Assign to this object the type and value currently held by the
3286 /// specified `rhs` object, and return a reference providing modifiable
3287 /// access to this object. The value currently held by this variant
3288 /// (if any) is destroyed if that value's type is not the same as the
3289 /// type held by the `rhs` object. The contents of `rhs` are either
3290 /// move-inserted into or move-assigned to this object with `rhs` left
3291 /// in a valid but unspecified state.
3292 Variant7& operator=(bslmf::MovableRef<Variant7> rhs);
3293};
3294
3295 // ===================
3296 // class Variant8<...>
3297 // ===================
3298
3299/// This class is a "specialization" of `Variant` for a fixed number (8) of
3300/// types. Its 8 template arguments *must* all be specified (none are
3301/// defaulted to `bslmf::Nil`). It provides the same functionality as
3302/// `Variant<A1, A2, ..., A8>`.
3303template <class A1, class A2, class A3, class A4, class A5, class A6,
3304 class A7, class A8>
3305class Variant8 : public VariantImp<typename bslmf::TypeList8<
3306 A1, A2, A3, A4, A5, A6, A7, A8>::ListType> {
3307
3308 // PRIVATE TYPES
3309 typedef VariantImp<typename bslmf::TypeList8<A1, A2, A3, A4, A5, A6, A7,
3310 A8>::ListType> Imp;
3311
3312 /// `SelfType` is an alias to this class.
3313 typedef Variant8<A1, A2, A3, A4, A5, A6, A7, A8> SelfType;
3314
3315 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
3316 typedef bslmf::MovableRefUtil MoveUtil;
3317
3318 public:
3319 // TRAITS
3322 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3325 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3328 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3329 BSLMF_NESTED_TRAIT_DECLARATION(Variant8, HasPrintMethod);
3330
3331 // CREATORS
3332
3333 /// Create a variant object in the unset state that uses the currently
3334 /// installed default allocator to supply memory.
3335 Variant8();
3336
3337 /// Create a variant object with the specified `valueOrAllocator` that
3338 /// can be either a value of a type that the variant can hold or an
3339 /// allocator to supply memory. If `valueOrAllocator` is not a
3340 /// `bslma::Allocator *`, then the variant will hold the value and type
3341 /// of `valueOrAllocator`, and use the currently installed default
3342 /// allocator to supply memory. Otherwise, the variant will be unset
3343 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3344 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3345 ///
3346 /// \note Note that this
3347 /// parameterized constructor is defined instead of two constructors
3348 /// (one taking a `bslma::Allocator *` and the other not) because
3349 /// template parameter arguments are always a better match than
3350 /// derived-to-base conversion (a concrete allocator pointer converted
3351 /// to `bslma::Allocator *`).
3352 template <class TYPE_OR_ALLOCATOR>
3353 explicit
3354 Variant8(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3355
3356 /// Create a variant object having the specified `value` of template
3357 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3358 /// supply memory. If `basicAllocator` is 0, the currently installed
3359 /// default allocator is used. `TYPE` must be the same as one of the
3360 /// types that this variant can hold.
3361 template <class TYPE>
3362 Variant8(const TYPE& value, bslma::Allocator *basicAllocator);
3363
3364 template <class TYPE>
3365 explicit
3366#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3367 Variant8(TYPE&& value,
3368 typename bsl::enable_if<
3369 !bsl::is_same<
3370 SelfType,
3371 typename bsl::remove_const<
3372 typename bsl::remove_reference<TYPE>::type>::type>::value
3373 &&
3375 void>::type * = 0);
3376#else
3377 Variant8(bslmf::MovableRef<TYPE> value);
3378#endif
3379 // Create a variant object having the specified 'value' of template
3380 // parameter 'TYPE' by moving the contents of 'value' to the
3381 // newly-created object. Use the currently installed default allocator
3382 // to supply memory. 'value' is left in a valid but unspecified state.
3383 // 'TYPE' must be the same as one of the types that this variant can
3384 // hold. Note that in C++11 mode, this method does not participate in
3385 // overload resolution if it would lead to ambiguity with the move
3386 // constructor that does not take an allocator (below) or with the
3387 // constructor taking a 'valueOrAllocator' (above).
3388
3389 template <class TYPE>
3390#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3391 Variant8(TYPE&& value,
3392 typename bsl::enable_if<
3393 !bsl::is_same<
3394 SelfType,
3395 typename bsl::remove_const<
3396 typename bsl::remove_reference<TYPE>::type>::type>::value,
3397 bslma::Allocator>::type *basicAllocator);
3398#else
3399 Variant8(bslmf::MovableRef<TYPE> value,
3400 bslma::Allocator *basicAllocator);
3401#endif
3402 // Create a variant object having the specified 'value' of template
3403 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3404 // memory. If 'basicAllocator' is 0, the currently installed default
3405 // allocator is used. The contents of 'value' are moved to the
3406 // newly-created object with 'value' left in a valid but unspecified
3407 // state. 'TYPE' must be the same as one of the types that this
3408 // variant can hold. Note that in C++11 mode, this method does not
3409 // participate in overload resolution if it would lead to ambiguity
3410 // with the move constructor that takes an allocator (below).
3411
3412 /// Create a variant object having the type and value of the specified
3413 /// `original` variant. Optionally specify a `basicAllocator` used to
3414 /// supply memory. If `basicAllocator` is 0, the currently installed
3415 /// default allocator is used.
3416 Variant8(const Variant8& original, bslma::Allocator *basicAllocator = 0);
3417
3418 /// Create a variant object having the type and value of the specified
3419 /// `original` object by moving the contents of `original` to the
3420 /// newly-created object. The allocator associated with `original` (if
3421 /// any) is propagated for use in the newly-created object. `original`
3422 /// is left in a valid but unspecified state.
3423 Variant8(bslmf::MovableRef<Variant8> original);
3424
3425 /// Create a variant object having the type and value of the specified
3426 /// `original` object that uses the specified `basicAllocator` to supply
3427 /// memory. If `basicAllocator` is 0, the currently installed default
3428 /// allocator is used. The contents of `original` are moved to the
3429 /// newly-created object with `original` left in a valid but unspecified
3430 /// state.
3431 Variant8(bslmf::MovableRef<Variant8> original,
3432 bslma::Allocator *basicAllocator);
3433
3434 // MANIPULATORS
3435
3436 /// Assign to this object the specified `value` of template parameter
3437 /// `TYPE`, and return a reference providing modifiable access to this
3438 /// object. The value currently held by this variant (if any) is
3439 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3440 /// must be the same as one of the types that this variant can hold.
3441 template <class TYPE>
3442 Variant8& operator=(const TYPE& value);
3443
3444 template <class TYPE>
3445#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3446 typename bsl::enable_if<
3447 !bsl::is_same<SelfType,
3448 typename bsl::remove_cvref<TYPE>::type>::value,
3449 SelfType>::type&
3450 operator=(TYPE&& value);
3451#else
3452 Variant8&
3453 operator=(bslmf::MovableRef<TYPE> value);
3454#endif
3455 // Assign to this object the specified 'value' of template parameter
3456 // 'TYPE', and return a reference providing modifiable access to this
3457 // object. The contents of 'value' are moved to this object with
3458 // 'value' left in a valid but unspecified state. The value currently
3459 // held by this variant (if any) is destroyed if that value's type is
3460 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3461 // that this variant can hold. Note that in C++11 mode, this method
3462 // does not participate in overload resolution if it would lead to
3463 // ambiguity with the move-assignment operator (below).
3464
3465 /// Assign to this object the type and value currently held by the
3466 /// specified `rhs` object, and return a reference providing modifiable
3467 /// access to this object. The value currently held by this variant
3468 /// (if any) is destroyed if that value's type is not the same as the
3469 /// type held by the `rhs` object.
3470 Variant8& operator=(const Variant8& rhs);
3471
3472 /// Assign to this object the type and value currently held by the
3473 /// specified `rhs` object, and return a reference providing modifiable
3474 /// access to this object. The value currently held by this variant
3475 /// (if any) is destroyed if that value's type is not the same as the
3476 /// type held by the `rhs` object. The contents of `rhs` are either
3477 /// move-inserted into or move-assigned to this object with `rhs` left
3478 /// in a valid but unspecified state.
3479 Variant8& operator=(bslmf::MovableRef<Variant8> rhs);
3480};
3481
3482 // ===================
3483 // class Variant9<...>
3484 // ===================
3485
3486/// This class is a "specialization" of `Variant` for a fixed number (9) of
3487/// types. Its 9 template arguments *must* all be specified (none are
3488/// defaulted to `bslmf::Nil`). It provides the same functionality as
3489/// `Variant<A1, A2, ..., A9>`.
3490template <class A1, class A2, class A3, class A4, class A5, class A6,
3491 class A7, class A8, class A9>
3492class Variant9 : public VariantImp<typename bslmf::TypeList9<
3493 A1, A2, A3, A4, A5, A6, A7, A8, A9>::ListType> {
3494
3495 // PRIVATE TYPES
3496 typedef VariantImp<typename bslmf::TypeList9<A1, A2, A3, A4, A5, A6, A7,
3497 A8, A9>::ListType> Imp;
3498
3499 /// `SelfType` is an alias to this class.
3500 typedef Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9> SelfType;
3501
3502 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
3503 typedef bslmf::MovableRefUtil MoveUtil;
3504
3505 public:
3506 // TRAITS
3509 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3512 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3515 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3516 BSLMF_NESTED_TRAIT_DECLARATION(Variant9, HasPrintMethod);
3517
3518 // CREATORS
3519
3520 /// Create a variant object in the unset state that uses the currently
3521 /// installed default allocator to supply memory.
3522 Variant9();
3523
3524 /// Create a variant object with the specified `valueOrAllocator` that
3525 /// can be either a value of a type that the variant can hold or an
3526 /// allocator to supply memory. If `valueOrAllocator` is not a
3527 /// `bslma::Allocator *`, then the variant will hold the value and type
3528 /// of `valueOrAllocator`, and use the currently installed default
3529 /// allocator to supply memory. Otherwise, the variant will be unset
3530 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3531 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3532 ///
3533 /// \note Note that this
3534 /// parameterized constructor is defined instead of two constructors
3535 /// (one taking a `bslma::Allocator *` and the other not) because
3536 /// template parameter arguments are always a better match than
3537 /// derived-to-base conversion (a concrete allocator pointer converted
3538 /// to `bslma::Allocator *`).
3539 template <class TYPE_OR_ALLOCATOR>
3540 explicit
3541 Variant9(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3542
3543 /// Create a variant object having the specified `value` of template
3544 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3545 /// supply memory. If `basicAllocator` is 0, the currently installed
3546 /// default allocator is used. `TYPE` must be the same as one of the
3547 /// types that this variant can hold.
3548 template <class TYPE>
3549 Variant9(const TYPE& value, bslma::Allocator *basicAllocator);
3550
3551 template <class TYPE>
3552 explicit
3553#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3554 Variant9(TYPE&& value,
3555 typename bsl::enable_if<
3556 !bsl::is_same<
3557 SelfType,
3558 typename bsl::remove_const<
3559 typename bsl::remove_reference<TYPE>::type>::type>::value
3560 &&
3562 void>::type * = 0);
3563#else
3564 Variant9(bslmf::MovableRef<TYPE> value);
3565#endif
3566 // Create a variant object having the specified 'value' of template
3567 // parameter 'TYPE' by moving the contents of 'value' to the
3568 // newly-created object. Use the currently installed default allocator
3569 // to supply memory. 'value' is left in a valid but unspecified state.
3570 // 'TYPE' must be the same as one of the types that this variant can
3571 // hold. Note that in C++11 mode, this method does not participate in
3572 // overload resolution if it would lead to ambiguity with the move
3573 // constructor that does not take an allocator (below) or with the
3574 // constructor taking a 'valueOrAllocator' (above).
3575
3576 template <class TYPE>
3577#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3578 Variant9(TYPE&& value,
3579 typename bsl::enable_if<
3580 !bsl::is_same<
3581 SelfType,
3582 typename bsl::remove_const<
3583 typename bsl::remove_reference<TYPE>::type>::type>::value,
3584 bslma::Allocator>::type *basicAllocator);
3585#else
3586 Variant9(bslmf::MovableRef<TYPE> value,
3587 bslma::Allocator *basicAllocator);
3588#endif
3589 // Create a variant object having the specified 'value' of template
3590 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3591 // memory. If 'basicAllocator' is 0, the currently installed default
3592 // allocator is used. The contents of 'value' are moved to the
3593 // newly-created object with 'value' left in a valid but unspecified
3594 // state. 'TYPE' must be the same as one of the types that this
3595 // variant can hold. Note that in C++11 mode, this method does not
3596 // participate in overload resolution if it would lead to ambiguity
3597 // with the move constructor that takes an allocator (below).
3598
3599 /// Create a variant object having the type and value of the specified
3600 /// `original` variant. Optionally specify a `basicAllocator` used to
3601 /// supply memory. If `basicAllocator` is 0, the currently installed
3602 /// default allocator is used.
3603 Variant9(const Variant9& original, bslma::Allocator *basicAllocator = 0);
3604
3605 /// Create a variant object having the type and value of the specified
3606 /// `original` object by moving the contents of `original` to the
3607 /// newly-created object. The allocator associated with `original` (if
3608 /// any) is propagated for use in the newly-created object. `original`
3609 /// is left in a valid but unspecified state.
3610 Variant9(bslmf::MovableRef<Variant9> original);
3611
3612 /// Create a variant object having the type and value of the specified
3613 /// `original` object that uses the specified `basicAllocator` to supply
3614 /// memory. If `basicAllocator` is 0, the currently installed default
3615 /// allocator is used. The contents of `original` are moved to the
3616 /// newly-created object with `original` left in a valid but unspecified
3617 /// state.
3618 Variant9(bslmf::MovableRef<Variant9> original,
3619 bslma::Allocator *basicAllocator);
3620
3621 // MANIPULATORS
3622
3623 /// Assign to this object the specified `value` of template parameter
3624 /// `TYPE`, and return a reference providing modifiable access to this
3625 /// object. The value currently held by this variant (if any) is
3626 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3627 /// must be the same as one of the types that this variant can hold.
3628 template <class TYPE>
3629 Variant9& operator=(const TYPE& value);
3630
3631 template <class TYPE>
3632#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3633 typename bsl::enable_if<
3634 !bsl::is_same<SelfType,
3635 typename bsl::remove_cvref<TYPE>::type>::value,
3636 SelfType>::type&
3637 operator=(TYPE&& value);
3638#else
3639 Variant9&
3640 operator=(bslmf::MovableRef<TYPE> value);
3641#endif
3642 // Assign to this object the specified 'value' of template parameter
3643 // 'TYPE', and return a reference providing modifiable access to this
3644 // object. The contents of 'value' are moved to this object with
3645 // 'value' left in a valid but unspecified state. The value currently
3646 // held by this variant (if any) is destroyed if that value's type is
3647 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3648 // that this variant can hold. Note that in C++11 mode, this method
3649 // does not participate in overload resolution if it would lead to
3650 // ambiguity with the move-assignment operator (below).
3651
3652 /// Assign to this object the type and value currently held by the
3653 /// specified `rhs` object, and return a reference providing modifiable
3654 /// access to this object. The value currently held by this variant
3655 /// (if any) is destroyed if that value's type is not the same as the
3656 /// type held by the `rhs` object.
3657 Variant9& operator=(const Variant9& rhs);
3658
3659 /// Assign to this object the type and value currently held by the
3660 /// specified `rhs` object, and return a reference providing modifiable
3661 /// access to this object. The value currently held by this variant
3662 /// (if any) is destroyed if that value's type is not the same as the
3663 /// type held by the `rhs` object. The contents of `rhs` are either
3664 /// move-inserted into or move-assigned to this object with `rhs` left
3665 /// in a valid but unspecified state.
3666 Variant9& operator=(bslmf::MovableRef<Variant9> rhs);
3667};
3668
3669 // ====================
3670 // class Variant10<...>
3671 // ====================
3672
3673/// This class is a "specialization" of `Variant` for a fixed number (10) of
3674/// types. Its 10 template arguments *must* all be specified (none are
3675/// defaulted to `bslmf::Nil`). It provides the same functionality as
3676/// `Variant<A1, A2, ..., A10>`.
3677template <class A1, class A2, class A3, class A4, class A5, class A6,
3678 class A7, class A8, class A9, class A10>
3679class Variant10 : public VariantImp<typename bslmf::TypeList10<
3680 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::ListType> {
3681
3682 // PRIVATE TYPES
3683 typedef VariantImp<typename bslmf::TypeList10<A1, A2, A3, A4, A5, A6, A7,
3684 A8, A9,
3685 A10>::ListType> Imp;
3686
3687 /// `SelfType` is an alias to this class.
3688 typedef Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> SelfType;
3689
3690 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
3691 typedef bslmf::MovableRefUtil MoveUtil;
3692
3693 public:
3694 // TRAITS
3697 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3700 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3703 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3704 BSLMF_NESTED_TRAIT_DECLARATION(Variant10, HasPrintMethod);
3705
3706 // CREATORS
3707
3708 /// Create a variant object in the unset state that uses the currently
3709 /// installed default allocator to supply memory.
3710 Variant10();
3711
3712 /// Create a variant object with the specified `valueOrAllocator` that
3713 /// can be either a value of a type that the variant can hold or an
3714 /// allocator to supply memory. If `valueOrAllocator` is not a
3715 /// `bslma::Allocator *`, then the variant will hold the value and type
3716 /// of `valueOrAllocator`, and use the currently installed default
3717 /// allocator to supply memory. Otherwise, the variant will be unset
3718 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3719 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3720 ///
3721 /// \note Note that this
3722 /// parameterized constructor is defined instead of two constructors
3723 /// (one taking a `bslma::Allocator *` and the other not) because
3724 /// template parameter arguments are always a better match than
3725 /// derived-to-base conversion (a concrete allocator pointer converted
3726 /// to `bslma::Allocator *`).
3727 template <class TYPE_OR_ALLOCATOR>
3728 explicit
3729 Variant10(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3730
3731 /// Create a variant object having the specified `value` of template
3732 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3733 /// supply memory. If `basicAllocator` is 0, the currently installed
3734 /// default allocator is used. `TYPE` must be the same as one of the
3735 /// types that this variant can hold.
3736 template <class TYPE>
3737 Variant10(const TYPE& value, bslma::Allocator *basicAllocator);
3738
3739 template <class TYPE>
3740 explicit
3741#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3742 Variant10(TYPE&& value,
3743 typename bsl::enable_if<
3744 !bsl::is_same<
3745 SelfType,
3746 typename bsl::remove_const<
3747 typename bsl::remove_reference<TYPE>::type>::type>::value
3748 &&
3750 void>::type * = 0);
3751#else
3752 Variant10(bslmf::MovableRef<TYPE> value);
3753#endif
3754 // Create a variant object having the specified 'value' of template
3755 // parameter 'TYPE' by moving the contents of 'value' to the
3756 // newly-created object. Use the currently installed default allocator
3757 // to supply memory. 'value' is left in a valid but unspecified state.
3758 // 'TYPE' must be the same as one of the types that this variant can
3759 // hold. Note that in C++11 mode, this method does not participate in
3760 // overload resolution if it would lead to ambiguity with the move
3761 // constructor that does not take an allocator (below) or with the
3762 // constructor taking a 'valueOrAllocator' (above).
3763
3764 template <class TYPE>
3765#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3766 Variant10(TYPE&& value,
3767 typename bsl::enable_if<
3768 !bsl::is_same<
3769 SelfType,
3770 typename bsl::remove_const<
3771 typename bsl::remove_reference<TYPE>::type>::type>::value,
3772 bslma::Allocator>::type *basicAllocator);
3773#else
3774 Variant10(bslmf::MovableRef<TYPE> value,
3775 bslma::Allocator *basicAllocator);
3776#endif
3777 // Create a variant object having the specified 'value' of template
3778 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3779 // memory. If 'basicAllocator' is 0, the currently installed default
3780 // allocator is used. The contents of 'value' are moved to the
3781 // newly-created object with 'value' left in a valid but unspecified
3782 // state. 'TYPE' must be the same as one of the types that this
3783 // variant can hold. Note that in C++11 mode, this method does not
3784 // participate in overload resolution if it would lead to ambiguity
3785 // with the move constructor that takes an allocator (below).
3786
3787 /// Create a variant object having the type and value of the specified
3788 /// `original` variant. Optionally specify a `basicAllocator` used to
3789 /// supply memory. If `basicAllocator` is 0, the currently installed
3790 /// default allocator is used.
3791 Variant10(const Variant10& original, bslma::Allocator *basicAllocator = 0);
3792
3793 /// Create a variant object having the type and value of the specified
3794 /// `original` object by moving the contents of `original` to the
3795 /// newly-created object. The allocator associated with `original` (if
3796 /// any) is propagated for use in the newly-created object. `original`
3797 /// is left in a valid but unspecified state.
3798 Variant10(bslmf::MovableRef<Variant10> original);
3799
3800 /// Create a variant object having the type and value of the specified
3801 /// `original` object that uses the specified `basicAllocator` to supply
3802 /// memory. If `basicAllocator` is 0, the currently installed default
3803 /// allocator is used. The contents of `original` are moved to the
3804 /// newly-created object with `original` left in a valid but unspecified
3805 /// state.
3806 Variant10(bslmf::MovableRef<Variant10> original,
3807 bslma::Allocator *basicAllocator);
3808
3809 // MANIPULATORS
3810
3811 /// Assign to this object the specified `value` of template parameter
3812 /// `TYPE`, and return a reference providing modifiable access to this
3813 /// object. The value currently held by this variant (if any) is
3814 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
3815 /// must be the same as one of the types that this variant can hold.
3816 template <class TYPE>
3817 Variant10& operator=(const TYPE& value);
3818
3819 template <class TYPE>
3820#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3821 typename bsl::enable_if<
3822 !bsl::is_same<SelfType,
3823 typename bsl::remove_cvref<TYPE>::type>::value,
3824 SelfType>::type&
3825 operator=(TYPE&& value);
3826#else
3827 Variant10&
3828 operator=(bslmf::MovableRef<TYPE> value);
3829#endif
3830 // Assign to this object the specified 'value' of template parameter
3831 // 'TYPE', and return a reference providing modifiable access to this
3832 // object. The contents of 'value' are moved to this object with
3833 // 'value' left in a valid but unspecified state. The value currently
3834 // held by this variant (if any) is destroyed if that value's type is
3835 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
3836 // that this variant can hold. Note that in C++11 mode, this method
3837 // does not participate in overload resolution if it would lead to
3838 // ambiguity with the move-assignment operator (below).
3839
3840 /// Assign to this object the type and value currently held by the
3841 /// specified `rhs` object, and return a reference providing modifiable
3842 /// access to this object. The value currently held by this variant
3843 /// (if any) is destroyed if that value's type is not the same as the
3844 /// type held by the `rhs` object.
3845 Variant10& operator=(const Variant10& rhs);
3846
3847 /// Assign to this object the type and value currently held by the
3848 /// specified `rhs` object, and return a reference providing modifiable
3849 /// access to this object. The value currently held by this variant
3850 /// (if any) is destroyed if that value's type is not the same as the
3851 /// type held by the `rhs` object. The contents of `rhs` are either
3852 /// move-inserted into or move-assigned to this object with `rhs` left
3853 /// in a valid but unspecified state.
3854 Variant10& operator=(bslmf::MovableRef<Variant10> rhs);
3855};
3856
3857 // ====================
3858 // class Variant11<...>
3859 // ====================
3860
3861/// This class is a "specialization" of `Variant` for a fixed number (11) of
3862/// types. Its 11 template arguments *must* all be specified (none are
3863/// defaulted to `bslmf::Nil`). It provides the same functionality as
3864/// `Variant<A1, A2, ..., A11>`.
3865template <class A1, class A2, class A3, class A4, class A5, class A6,
3866 class A7, class A8, class A9, class A10, class A11>
3867class Variant11 : public VariantImp<typename bslmf::TypeList11<
3868 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::ListType> {
3869
3870 // PRIVATE TYPES
3871 typedef VariantImp<typename bslmf::TypeList11<A1, A2, A3, A4, A5, A6, A7,
3872 A8, A9, A10,
3873 A11>::ListType> Imp;
3874
3875 /// `SelfType` is an alias to this class.
3876 typedef Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
3877 A11> SelfType;
3878
3879 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
3880 typedef bslmf::MovableRefUtil MoveUtil;
3881
3882 public:
3883 // TRAITS
3886 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
3889 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
3892 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
3893 BSLMF_NESTED_TRAIT_DECLARATION(Variant11, HasPrintMethod);
3894
3895 // CREATORS
3896
3897 /// Create a variant object in the unset state that uses the currently
3898 /// installed default allocator to supply memory.
3899 Variant11();
3900
3901 /// Create a variant object with the specified `valueOrAllocator` that
3902 /// can be either a value of a type that the variant can hold or an
3903 /// allocator to supply memory. If `valueOrAllocator` is not a
3904 /// `bslma::Allocator *`, then the variant will hold the value and type
3905 /// of `valueOrAllocator`, and use the currently installed default
3906 /// allocator to supply memory. Otherwise, the variant will be unset
3907 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
3908 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
3909 ///
3910 /// \note Note that this
3911 /// parameterized constructor is defined instead of two constructors
3912 /// (one taking a `bslma::Allocator *` and the other not) because
3913 /// template parameter arguments are always a better match than
3914 /// derived-to-base conversion (a concrete allocator pointer converted
3915 /// to `bslma::Allocator *`).
3916 template <class TYPE_OR_ALLOCATOR>
3917 explicit
3918 Variant11(const TYPE_OR_ALLOCATOR& valueOrAllocator);
3919
3920 /// Create a variant object having the specified `value` of template
3921 /// parameter `TYPE` and that uses the specified `basicAllocator` to
3922 /// supply memory. If `basicAllocator` is 0, the currently installed
3923 /// default allocator is used. `TYPE` must be the same as one of the
3924 /// types that this variant can hold.
3925 template <class TYPE>
3926 Variant11(const TYPE& value, bslma::Allocator *basicAllocator);
3927
3928 template <class TYPE>
3929 explicit
3930#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3931 Variant11(TYPE&& value,
3932 typename bsl::enable_if<
3933 !bsl::is_same<
3934 SelfType,
3935 typename bsl::remove_const<
3936 typename bsl::remove_reference<TYPE>::type>::type>::value
3937 &&
3939 void>::type * = 0);
3940#else
3941 Variant11(bslmf::MovableRef<TYPE> value);
3942#endif
3943 // Create a variant object having the specified 'value' of template
3944 // parameter 'TYPE' by moving the contents of 'value' to the
3945 // newly-created object. Use the currently installed default allocator
3946 // to supply memory. 'value' is left in a valid but unspecified state.
3947 // 'TYPE' must be the same as one of the types that this variant can
3948 // hold. Note that in C++11 mode, this method does not participate in
3949 // overload resolution if it would lead to ambiguity with the move
3950 // constructor that does not take an allocator (below) or with the
3951 // constructor taking a 'valueOrAllocator' (above).
3952
3953 template <class TYPE>
3954#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3955 Variant11(TYPE&& value,
3956 typename bsl::enable_if<
3957 !bsl::is_same<
3958 SelfType,
3959 typename bsl::remove_const<
3960 typename bsl::remove_reference<TYPE>::type>::type>::value,
3961 bslma::Allocator>::type *basicAllocator);
3962#else
3963 Variant11(bslmf::MovableRef<TYPE> value,
3964 bslma::Allocator *basicAllocator);
3965#endif
3966 // Create a variant object having the specified 'value' of template
3967 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
3968 // memory. If 'basicAllocator' is 0, the currently installed default
3969 // allocator is used. The contents of 'value' are moved to the
3970 // newly-created object with 'value' left in a valid but unspecified
3971 // state. 'TYPE' must be the same as one of the types that this
3972 // variant can hold. Note that in C++11 mode, this method does not
3973 // participate in overload resolution if it would lead to ambiguity
3974 // with the move constructor that takes an allocator (below).
3975
3976 /// Create a variant object having the type and value of the specified
3977 /// `original` variant. Optionally specify a `basicAllocator` used to
3978 /// supply memory. If `basicAllocator` is 0, the currently installed
3979 /// default allocator is used.
3980 Variant11(const Variant11& original, bslma::Allocator *basicAllocator = 0);
3981
3982 /// Create a variant object having the type and value of the specified
3983 /// `original` object by moving the contents of `original` to the
3984 /// newly-created object. The allocator associated with `original` (if
3985 /// any) is propagated for use in the newly-created object. `original`
3986 /// is left in a valid but unspecified state.
3987 Variant11(bslmf::MovableRef<Variant11> original);
3988
3989 /// Create a variant object having the type and value of the specified
3990 /// `original` object that uses the specified `basicAllocator` to supply
3991 /// memory. If `basicAllocator` is 0, the currently installed default
3992 /// allocator is used. The contents of `original` are moved to the
3993 /// newly-created object with `original` left in a valid but unspecified
3994 /// state.
3995 Variant11(bslmf::MovableRef<Variant11> original,
3996 bslma::Allocator *basicAllocator);
3997
3998 // MANIPULATORS
3999
4000 /// Assign to this object the specified `value` of template parameter
4001 /// `TYPE`, and return a reference providing modifiable access to this
4002 /// object. The value currently held by this variant (if any) is
4003 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4004 /// must be the same as one of the types that this variant can hold.
4005 template <class TYPE>
4006 Variant11& operator=(const TYPE& value);
4007
4008 template <class TYPE>
4009#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4010 typename bsl::enable_if<
4011 !bsl::is_same<SelfType,
4012 typename bsl::remove_cvref<TYPE>::type>::value,
4013 SelfType>::type&
4014 operator=(TYPE&& value);
4015#else
4016 Variant11&
4017 operator=(bslmf::MovableRef<TYPE> value);
4018#endif
4019 // Assign to this object the specified 'value' of template parameter
4020 // 'TYPE', and return a reference providing modifiable access to this
4021 // object. The contents of 'value' are moved to this object with
4022 // 'value' left in a valid but unspecified state. The value currently
4023 // held by this variant (if any) is destroyed if that value's type is
4024 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4025 // that this variant can hold. Note that in C++11 mode, this method
4026 // does not participate in overload resolution if it would lead to
4027 // ambiguity with the move-assignment operator (below).
4028
4029 /// Assign to this object the type and value currently held by the
4030 /// specified `rhs` object, and return a reference providing modifiable
4031 /// access to this object. The value currently held by this variant
4032 /// (if any) is destroyed if that value's type is not the same as the
4033 /// type held by the `rhs` object.
4034 Variant11& operator=(const Variant11& rhs);
4035
4036 /// Assign to this object the type and value currently held by the
4037 /// specified `rhs` object, and return a reference providing modifiable
4038 /// access to this object. The value currently held by this variant
4039 /// (if any) is destroyed if that value's type is not the same as the
4040 /// type held by the `rhs` object. The contents of `rhs` are either
4041 /// move-inserted into or move-assigned to this object with `rhs` left
4042 /// in a valid but unspecified state.
4043 Variant11& operator=(bslmf::MovableRef<Variant11> rhs);
4044};
4045
4046 // ====================
4047 // class Variant12<...>
4048 // ====================
4049
4050/// This class is a "specialization" of `Variant` for a fixed number (12) of
4051/// types. Its 12 template arguments *must* all be specified (none are
4052/// defaulted to `bslmf::Nil`). It provides the same functionality as
4053/// `Variant<A1, A2, ..., A12>`.
4054template <class A1, class A2, class A3, class A4, class A5, class A6,
4055 class A7, class A8, class A9, class A10, class A11, class A12>
4056class Variant12 : public VariantImp<typename bslmf::TypeList12<
4057 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::ListType> {
4058
4059 // PRIVATE TYPES
4060 typedef VariantImp<typename bslmf::TypeList12<A1, A2, A3, A4, A5, A6,
4061 A7, A8, A9, A10, A11,
4062 A12>::ListType> Imp;
4063
4064 /// `SelfType` is an alias to this class.
4065 typedef Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
4066 A11, A12> SelfType;
4067
4068 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
4069 typedef bslmf::MovableRefUtil MoveUtil;
4070
4071 public:
4072 // TRAITS
4075 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4078 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4081 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4082 BSLMF_NESTED_TRAIT_DECLARATION(Variant12, HasPrintMethod);
4083
4084 // CREATORS
4085
4086 /// Create a variant object in the unset state that uses the currently
4087 /// installed default allocator to supply memory.
4088 Variant12();
4089
4090 /// Create a variant object with the specified `valueOrAllocator` that
4091 /// can be either a value of a type that the variant can hold or an
4092 /// allocator to supply memory. If `valueOrAllocator` is not a
4093 /// `bslma::Allocator *`, then the variant will hold the value and type
4094 /// of `valueOrAllocator`, and use the currently installed default
4095 /// allocator to supply memory. Otherwise, the variant will be unset
4096 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4097 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4098 ///
4099 /// \note Note that this
4100 /// parameterized constructor is defined instead of two constructors
4101 /// (one taking a `bslma::Allocator *` and the other not) because
4102 /// template parameter arguments are always a better match than
4103 /// derived-to-base conversion (a concrete allocator pointer converted
4104 /// to `bslma::Allocator *`).
4105 template <class TYPE_OR_ALLOCATOR>
4106 explicit
4107 Variant12(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4108
4109 /// Create a variant object having the specified `value` of template
4110 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4111 /// supply memory. If `basicAllocator` is 0, the currently installed
4112 /// default allocator is used. `TYPE` must be the same as one of the
4113 /// types that this variant can hold.
4114 template <class TYPE>
4115 Variant12(const TYPE& value, bslma::Allocator *basicAllocator);
4116
4117 template <class TYPE>
4118 explicit
4119#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4120 Variant12(TYPE&& value,
4121 typename bsl::enable_if<
4122 !bsl::is_same<
4123 SelfType,
4124 typename bsl::remove_const<
4125 typename bsl::remove_reference<TYPE>::type>::type>::value
4126 &&
4128 void>::type * = 0);
4129#else
4130 Variant12(bslmf::MovableRef<TYPE> value);
4131#endif
4132 // Create a variant object having the specified 'value' of template
4133 // parameter 'TYPE' by moving the contents of 'value' to the
4134 // newly-created object. Use the currently installed default allocator
4135 // to supply memory. 'value' is left in a valid but unspecified state.
4136 // 'TYPE' must be the same as one of the types that this variant can
4137 // hold. Note that in C++11 mode, this method does not participate in
4138 // overload resolution if it would lead to ambiguity with the move
4139 // constructor that does not take an allocator (below) or with the
4140 // constructor taking a 'valueOrAllocator' (above).
4141
4142 template <class TYPE>
4143#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4144 Variant12(TYPE&& value,
4145 typename bsl::enable_if<
4146 !bsl::is_same<
4147 SelfType,
4148 typename bsl::remove_const<
4149 typename bsl::remove_reference<TYPE>::type>::type>::value,
4150 bslma::Allocator>::type *basicAllocator);
4151#else
4152 Variant12(bslmf::MovableRef<TYPE> value,
4153 bslma::Allocator *basicAllocator);
4154#endif
4155 // Create a variant object having the specified 'value' of template
4156 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4157 // memory. If 'basicAllocator' is 0, the currently installed default
4158 // allocator is used. The contents of 'value' are moved to the
4159 // newly-created object with 'value' left in a valid but unspecified
4160 // state. 'TYPE' must be the same as one of the types that this
4161 // variant can hold. Note that in C++11 mode, this method does not
4162 // participate in overload resolution if it would lead to ambiguity
4163 // with the move constructor that takes an allocator (below).
4164
4165 /// Create a variant object having the type and value of the specified
4166 /// `original` variant. Optionally specify a `basicAllocator` used to
4167 /// supply memory. If `basicAllocator` is 0, the currently installed
4168 /// default allocator is used.
4169 Variant12(const Variant12& original, bslma::Allocator *basicAllocator = 0);
4170
4171 /// Create a variant object having the type and value of the specified
4172 /// `original` object by moving the contents of `original` to the
4173 /// newly-created object. The allocator associated with `original` (if
4174 /// any) is propagated for use in the newly-created object. `original`
4175 /// is left in a valid but unspecified state.
4176 Variant12(bslmf::MovableRef<Variant12> original);
4177
4178 /// Create a variant object having the type and value of the specified
4179 /// `original` object that uses the specified `basicAllocator` to supply
4180 /// memory. If `basicAllocator` is 0, the currently installed default
4181 /// allocator is used. The contents of `original` are moved to the
4182 /// newly-created object with `original` left in a valid but unspecified
4183 /// state.
4184 Variant12(bslmf::MovableRef<Variant12> original,
4185 bslma::Allocator *basicAllocator);
4186
4187 // MANIPULATORS
4188
4189 /// Assign to this object the specified `value` of template parameter
4190 /// `TYPE`, and return a reference providing modifiable access to this
4191 /// object. The value currently held by this variant (if any) is
4192 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4193 /// must be the same as one of the types that this variant can hold.
4194 template <class TYPE>
4195 Variant12& operator=(const TYPE& value);
4196
4197 template <class TYPE>
4198#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4199 typename bsl::enable_if<
4200 !bsl::is_same<SelfType,
4201 typename bsl::remove_cvref<TYPE>::type>::value,
4202 SelfType>::type&
4203 operator=(TYPE&& value);
4204#else
4205 Variant12&
4206 operator=(bslmf::MovableRef<TYPE> value);
4207#endif
4208 // Assign to this object the specified 'value' of template parameter
4209 // 'TYPE', and return a reference providing modifiable access to this
4210 // object. The contents of 'value' are moved to this object with
4211 // 'value' left in a valid but unspecified state. The value currently
4212 // held by this variant (if any) is destroyed if that value's type is
4213 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4214 // that this variant can hold. Note that in C++11 mode, this method
4215 // does not participate in overload resolution if it would lead to
4216 // ambiguity with the move-assignment operator (below).
4217
4218 /// Assign to this object the type and value currently held by the
4219 /// specified `rhs` object, and return a reference providing modifiable
4220 /// access to this object. The value currently held by this variant
4221 /// (if any) is destroyed if that value's type is not the same as the
4222 /// type held by the `rhs` object.
4223 Variant12& operator=(const Variant12& rhs);
4224
4225 /// Assign to this object the type and value currently held by the
4226 /// specified `rhs` object, and return a reference providing modifiable
4227 /// access to this object. The value currently held by this variant
4228 /// (if any) is destroyed if that value's type is not the same as the
4229 /// type held by the `rhs` object. The contents of `rhs` are either
4230 /// move-inserted into or move-assigned to this object with `rhs` left
4231 /// in a valid but unspecified state.
4232 Variant12& operator=(bslmf::MovableRef<Variant12> rhs);
4233};
4234
4235 // ====================
4236 // class Variant13<...>
4237 // ====================
4238
4239/// This class is a "specialization" of `Variant` for a fixed number (13) of
4240/// types. Its 13 template arguments *must* all be specified (none are
4241/// defaulted to `bslmf::Nil`). It provides the same functionality as
4242/// `Variant<A1, A2, ..., A13>`.
4243template <class A1, class A2, class A3, class A4, class A5, class A6,
4244 class A7, class A8, class A9, class A10, class A11, class A12,
4245 class A13>
4246class Variant13 : public VariantImp<typename bslmf::TypeList13<
4247 A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::ListType> {
4248
4249 // PRIVATE TYPES
4250 typedef VariantImp<typename bslmf::TypeList13<A1, A2, A3, A4, A5, A6,
4251 A7, A8, A9, A10, A11, A12,
4252 A13>::ListType> Imp;
4253
4254 /// `SelfType` is an alias to this class.
4255 typedef Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4256 A10, A11, A12, A13> SelfType;
4257
4258 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
4259 typedef bslmf::MovableRefUtil MoveUtil;
4260
4261 public:
4262 // TRAITS
4265 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4268 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4271 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4272 BSLMF_NESTED_TRAIT_DECLARATION(Variant13, HasPrintMethod);
4273
4274 // CREATORS
4275
4276 /// Create a variant object in the unset state that uses the currently
4277 /// installed default allocator to supply memory.
4278 Variant13();
4279
4280 /// Create a variant object with the specified `valueOrAllocator` that
4281 /// can be either a value of a type that the variant can hold or an
4282 /// allocator to supply memory. If `valueOrAllocator` is not a
4283 /// `bslma::Allocator *`, then the variant will hold the value and type
4284 /// of `valueOrAllocator`, and use the currently installed default
4285 /// allocator to supply memory. Otherwise, the variant will be unset
4286 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4287 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4288 ///
4289 /// \note Note that this
4290 /// parameterized constructor is defined instead of two constructors
4291 /// (one taking a `bslma::Allocator *` and the other not) because
4292 /// template parameter arguments are always a better match than
4293 /// derived-to-base conversion (a concrete allocator pointer converted
4294 /// to `bslma::Allocator *`).
4295 template <class TYPE_OR_ALLOCATOR>
4296 explicit
4297 Variant13(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4298
4299 /// Create a variant object having the specified `value` of template
4300 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4301 /// supply memory. If `basicAllocator` is 0, the currently installed
4302 /// default allocator is used. `TYPE` must be the same as one of the
4303 /// types that this variant can hold.
4304 template <class TYPE>
4305 Variant13(const TYPE& value, bslma::Allocator *basicAllocator);
4306
4307 template <class TYPE>
4308 explicit
4309#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4310 Variant13(TYPE&& value,
4311 typename bsl::enable_if<
4312 !bsl::is_same<
4313 SelfType,
4314 typename bsl::remove_const<
4315 typename bsl::remove_reference<TYPE>::type>::type>::value
4316 &&
4318 void>::type * = 0);
4319#else
4320 Variant13(bslmf::MovableRef<TYPE> value);
4321#endif
4322 // Create a variant object having the specified 'value' of template
4323 // parameter 'TYPE' by moving the contents of 'value' to the
4324 // newly-created object. Use the currently installed default allocator
4325 // to supply memory. 'value' is left in a valid but unspecified state.
4326 // 'TYPE' must be the same as one of the types that this variant can
4327 // hold. Note that in C++11 mode, this method does not participate in
4328 // overload resolution if it would lead to ambiguity with the move
4329 // constructor that does not take an allocator (below) or with the
4330 // constructor taking a 'valueOrAllocator' (above).
4331
4332 template <class TYPE>
4333#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4334 Variant13(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 bslma::Allocator>::type *basicAllocator);
4341#else
4342 Variant13(bslmf::MovableRef<TYPE> value,
4343 bslma::Allocator *basicAllocator);
4344#endif
4345 // Create a variant object having the specified 'value' of template
4346 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4347 // memory. If 'basicAllocator' is 0, the currently installed default
4348 // allocator is used. The contents of 'value' are moved to the
4349 // newly-created object with 'value' left in a valid but unspecified
4350 // state. 'TYPE' must be the same as one of the types that this
4351 // variant can hold. Note that in C++11 mode, this method does not
4352 // participate in overload resolution if it would lead to ambiguity
4353 // with the move constructor that takes an allocator (below).
4354
4355 /// Create a variant object having the type and value of the specified
4356 /// `original` variant. Optionally specify a `basicAllocator` used to
4357 /// supply memory. If `basicAllocator` is 0, the currently installed
4358 /// default allocator is used.
4359 Variant13(const Variant13& original, bslma::Allocator *basicAllocator = 0);
4360
4361 /// Create a variant object having the type and value of the specified
4362 /// `original` object by moving the contents of `original` to the
4363 /// newly-created object. The allocator associated with `original` (if
4364 /// any) is propagated for use in the newly-created object. `original`
4365 /// is left in a valid but unspecified state.
4366 Variant13(bslmf::MovableRef<Variant13> original);
4367
4368 /// Create a variant object having the type and value of the specified
4369 /// `original` object that uses the specified `basicAllocator` to supply
4370 /// memory. If `basicAllocator` is 0, the currently installed default
4371 /// allocator is used. The contents of `original` are moved to the
4372 /// newly-created object with `original` left in a valid but unspecified
4373 /// state.
4374 Variant13(bslmf::MovableRef<Variant13> original,
4375 bslma::Allocator *basicAllocator);
4376
4377 // MANIPULATORS
4378
4379 /// Assign to this object the specified `value` of template parameter
4380 /// `TYPE`, and return a reference providing modifiable access to this
4381 /// object. The value currently held by this variant (if any) is
4382 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4383 /// must be the same as one of the types that this variant can hold.
4384 template <class TYPE>
4385 Variant13& operator=(const TYPE& value);
4386
4387 template <class TYPE>
4388#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4389 typename bsl::enable_if<
4390 !bsl::is_same<SelfType,
4391 typename bsl::remove_cvref<TYPE>::type>::value,
4392 SelfType>::type&
4393 operator=(TYPE&& value);
4394#else
4395 Variant13&
4396 operator=(bslmf::MovableRef<TYPE> value);
4397#endif
4398 // Assign to this object the specified 'value' of template parameter
4399 // 'TYPE', and return a reference providing modifiable access to this
4400 // object. The contents of 'value' are moved to this object with
4401 // 'value' left in a valid but unspecified state. The value currently
4402 // held by this variant (if any) is destroyed if that value's type is
4403 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4404 // that this variant can hold. Note that in C++11 mode, this method
4405 // does not participate in overload resolution if it would lead to
4406 // ambiguity with the move-assignment operator (below).
4407
4408 /// Assign to this object the type and value currently held by the
4409 /// specified `rhs` object, and return a reference providing modifiable
4410 /// access to this object. The value currently held by this variant
4411 /// (if any) is destroyed if that value's type is not the same as the
4412 /// type held by the `rhs` object.
4413 Variant13& operator=(const Variant13& rhs);
4414
4415 /// Assign to this object the type and value currently held by the
4416 /// specified `rhs` object, and return a reference providing modifiable
4417 /// access to this object. The value currently held by this variant
4418 /// (if any) is destroyed if that value's type is not the same as the
4419 /// type held by the `rhs` object. The contents of `rhs` are either
4420 /// move-inserted into or move-assigned to this object with `rhs` left
4421 /// in a valid but unspecified state.
4422 Variant13& operator=(bslmf::MovableRef<Variant13> rhs);
4423};
4424
4425 // ====================
4426 // class Variant14<...>
4427 // ====================
4428
4429/// This class is a "specialization" of `Variant` for a fixed number (14) of
4430/// types. Its 14 template arguments *must* all be specified (none are
4431/// defaulted to `bslmf::Nil`). It provides the same functionality as
4432/// `Variant<A1, A2, ..., A14>`.
4433template <class A1, class A2, class A3, class A4, class A5, class A6,
4434 class A7, class A8, class A9, class A10, class A11, class A12,
4435 class A13, class A14>
4436class Variant14 : public VariantImp<typename bslmf::TypeList14<
4437 A1, A2, A3, A4, A5,
4438 A6, A7, A8, A9, A10,
4439 A11, A12, A13, A14>::ListType> {
4440
4441 // PRIVATE TYPES
4442 typedef VariantImp<typename bslmf::TypeList14<A1, A2, A3, A4, A5, A6,
4443 A7, A8, A9, A10, A11, A12,
4444 A13,
4445 A14>::ListType> Imp;
4446
4447 /// `SelfType` is an alias to this class.
4448 typedef Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4449 A10, A11, A12, A13, A14> SelfType;
4450
4451 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
4452 typedef bslmf::MovableRefUtil MoveUtil;
4453
4454 public:
4455 // TRAITS
4458 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4461 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4464 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4465 BSLMF_NESTED_TRAIT_DECLARATION(Variant14, HasPrintMethod);
4466
4467 // CREATORS
4468
4469 /// Create a variant object in the unset state that uses the currently
4470 /// installed default allocator to supply memory.
4471 Variant14();
4472
4473 /// Create a variant object with the specified `valueOrAllocator` that
4474 /// can be either a value of a type that the variant can hold or an
4475 /// allocator to supply memory. If `valueOrAllocator` is not a
4476 /// `bslma::Allocator *`, then the variant will hold the value and type
4477 /// of `valueOrAllocator`, and use the currently installed default
4478 /// allocator to supply memory. Otherwise, the variant will be unset
4479 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4480 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4481 ///
4482 /// \note Note that this
4483 /// parameterized constructor is defined instead of two constructors
4484 /// (one taking a `bslma::Allocator *` and the other not) because
4485 /// template parameter arguments are always a better match than
4486 /// derived-to-base conversion (a concrete allocator pointer converted
4487 /// to `bslma::Allocator *`).
4488 template <class TYPE_OR_ALLOCATOR>
4489 explicit
4490 Variant14(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4491
4492 /// Create a variant object having the specified `value` of template
4493 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4494 /// supply memory. If `basicAllocator` is 0, the currently installed
4495 /// default allocator is used. `TYPE` must be the same as one of the
4496 /// types that this variant can hold.
4497 template <class TYPE>
4498 Variant14(const TYPE& value, bslma::Allocator *basicAllocator);
4499
4500 template <class TYPE>
4501 explicit
4502#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4503 Variant14(TYPE&& value,
4504 typename bsl::enable_if<
4505 !bsl::is_same<
4506 SelfType,
4507 typename bsl::remove_const<
4508 typename bsl::remove_reference<TYPE>::type>::type>::value
4509 &&
4511 void>::type * = 0);
4512#else
4513 Variant14(bslmf::MovableRef<TYPE> value);
4514#endif
4515 // Create a variant object having the specified 'value' of template
4516 // parameter 'TYPE' by moving the contents of 'value' to the
4517 // newly-created object. Use the currently installed default allocator
4518 // to supply memory. 'value' is left in a valid but unspecified state.
4519 // 'TYPE' must be the same as one of the types that this variant can
4520 // hold. Note that in C++11 mode, this method does not participate in
4521 // overload resolution if it would lead to ambiguity with the move
4522 // constructor that does not take an allocator (below) or with the
4523 // constructor taking a 'valueOrAllocator' (above).
4524
4525 template <class TYPE>
4526#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4527 Variant14(TYPE&& value,
4528 typename bsl::enable_if<
4529 !bsl::is_same<
4530 SelfType,
4531 typename bsl::remove_const<
4532 typename bsl::remove_reference<TYPE>::type>::type>::value,
4533 bslma::Allocator>::type *basicAllocator);
4534#else
4535 Variant14(bslmf::MovableRef<TYPE> value,
4536 bslma::Allocator *basicAllocator);
4537#endif
4538 // Create a variant object having the specified 'value' of template
4539 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4540 // memory. If 'basicAllocator' is 0, the currently installed default
4541 // allocator is used. The contents of 'value' are moved to the
4542 // newly-created object with 'value' left in a valid but unspecified
4543 // state. 'TYPE' must be the same as one of the types that this
4544 // variant can hold. Note that in C++11 mode, this method does not
4545 // participate in overload resolution if it would lead to ambiguity
4546 // with the move constructor that takes an allocator (below).
4547
4548 /// Create a variant object having the type and value of the specified
4549 /// `original` variant. Optionally specify a `basicAllocator` used to
4550 /// supply memory. If `basicAllocator` is 0, the currently installed
4551 /// default allocator is used.
4552 Variant14(const Variant14& original, bslma::Allocator *basicAllocator = 0);
4553
4554 /// Create a variant object having the type and value of the specified
4555 /// `original` object by moving the contents of `original` to the
4556 /// newly-created object. The allocator associated with `original` (if
4557 /// any) is propagated for use in the newly-created object. `original`
4558 /// is left in a valid but unspecified state.
4559 Variant14(bslmf::MovableRef<Variant14> original);
4560
4561 /// Create a variant object having the type and value of the specified
4562 /// `original` object that uses the specified `basicAllocator` to supply
4563 /// memory. If `basicAllocator` is 0, the currently installed default
4564 /// allocator is used. The contents of `original` are moved to the
4565 /// newly-created object with `original` left in a valid but unspecified
4566 /// state.
4567 Variant14(bslmf::MovableRef<Variant14> original,
4568 bslma::Allocator *basicAllocator);
4569
4570 // MANIPULATORS
4571
4572 /// Assign to this object the specified `value` of template parameter
4573 /// `TYPE`, and return a reference providing modifiable access to this
4574 /// object. The value currently held by this variant (if any) is
4575 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4576 /// must be the same as one of the types that this variant can hold.
4577 template <class TYPE>
4578 Variant14& operator=(const TYPE& value);
4579
4580 template <class TYPE>
4581#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4582 typename bsl::enable_if<
4583 !bsl::is_same<SelfType,
4584 typename bsl::remove_cvref<TYPE>::type>::value,
4585 SelfType>::type&
4586 operator=(TYPE&& value);
4587#else
4588 Variant14&
4589 operator=(bslmf::MovableRef<TYPE> value);
4590#endif
4591 // Assign to this object the specified 'value' of template parameter
4592 // 'TYPE', and return a reference providing modifiable access to this
4593 // object. The contents of 'value' are moved to this object with
4594 // 'value' left in a valid but unspecified state. The value currently
4595 // held by this variant (if any) is destroyed if that value's type is
4596 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4597 // that this variant can hold. Note that in C++11 mode, this method
4598 // does not participate in overload resolution if it would lead to
4599 // ambiguity with the move-assignment operator (below).
4600
4601 /// Assign to this object the type and value currently held by the
4602 /// specified `rhs` object, and return a reference providing modifiable
4603 /// access to this object. The value currently held by this variant
4604 /// (if any) is destroyed if that value's type is not the same as the
4605 /// type held by the `rhs` object.
4606 Variant14& operator=(const Variant14& rhs);
4607
4608 /// Assign to this object the type and value currently held by the
4609 /// specified `rhs` object, and return a reference providing modifiable
4610 /// access to this object. The value currently held by this variant
4611 /// (if any) is destroyed if that value's type is not the same as the
4612 /// type held by the `rhs` object. The contents of `rhs` are either
4613 /// move-inserted into or move-assigned to this object with `rhs` left
4614 /// in a valid but unspecified state.
4615 Variant14& operator=(bslmf::MovableRef<Variant14> rhs);
4616};
4617
4618 // ====================
4619 // class Variant15<...>
4620 // ====================
4621
4622/// This class is a "specialization" of `Variant` for a fixed number (15) of
4623/// types. Its 15 template arguments *must* all be specified (none are
4624/// defaulted to `bslmf::Nil`). It provides the same functionality as
4625/// `Variant<A1, A2, ..., A15>`.
4626template <class A1, class A2, class A3, class A4, class A5, class A6,
4627 class A7, class A8, class A9, class A10, class A11, class A12,
4628 class A13, class A14, class A15>
4629class Variant15 : public VariantImp<typename bslmf::TypeList15<
4630 A1, A2, A3, A4, A5,
4631 A6, A7, A8, A9, A10,
4632 A11, A12, A13, A14, A15>::ListType> {
4633
4634 // PRIVATE TYPES
4635 typedef VariantImp<typename bslmf::TypeList15<A1, A2, A3, A4, A5, A6,
4636 A7, A8, A9, A10, A11, A12,
4637 A13, A14,
4638 A15>::ListType> Imp;
4639
4640 /// `SelfType` is an alias to this class.
4641 typedef Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4642 A10, A11, A12, A13, A14, A15> SelfType;
4643
4644 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
4645 typedef bslmf::MovableRefUtil MoveUtil;
4646
4647 public:
4648 // TRAITS
4651 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4654 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4657 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4658 BSLMF_NESTED_TRAIT_DECLARATION(Variant15, HasPrintMethod);
4659
4660 // CREATORS
4661
4662 /// Create a variant object in the unset state that uses the currently
4663 /// installed default allocator to supply memory.
4664 Variant15();
4665
4666 /// Create a variant object with the specified `valueOrAllocator` that
4667 /// can be either a value of a type that the variant can hold or an
4668 /// allocator to supply memory. If `valueOrAllocator` is not a
4669 /// `bslma::Allocator *`, then the variant will hold the value and type
4670 /// of `valueOrAllocator`, and use the currently installed default
4671 /// allocator to supply memory. Otherwise, the variant will be unset
4672 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4673 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4674 ///
4675 /// \note Note that this
4676 /// parameterized constructor is defined instead of two constructors
4677 /// (one taking a `bslma::Allocator *` and the other not) because
4678 /// template parameter arguments are always a better match than
4679 /// derived-to-base conversion (a concrete allocator pointer converted
4680 /// to `bslma::Allocator *`).
4681 template <class TYPE_OR_ALLOCATOR>
4682 explicit
4683 Variant15(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4684
4685 /// Create a variant object having the specified `value` of template
4686 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4687 /// supply memory. If `basicAllocator` is 0, the currently installed
4688 /// default allocator is used. `TYPE` must be the same as one of the
4689 /// types that this variant can hold.
4690 template <class TYPE>
4691 Variant15(const TYPE& value, bslma::Allocator *basicAllocator);
4692
4693 template <class TYPE>
4694 explicit
4695#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4696 Variant15(TYPE&& value,
4697 typename bsl::enable_if<
4698 !bsl::is_same<
4699 SelfType,
4700 typename bsl::remove_const<
4701 typename bsl::remove_reference<TYPE>::type>::type>::value
4702 &&
4704 void>::type * = 0);
4705#else
4706 Variant15(bslmf::MovableRef<TYPE> value);
4707#endif
4708 // Create a variant object having the specified 'value' of template
4709 // parameter 'TYPE' by moving the contents of 'value' to the
4710 // newly-created object. Use the currently installed default allocator
4711 // to supply memory. 'value' is left in a valid but unspecified state.
4712 // 'TYPE' must be the same as one of the types that this variant can
4713 // hold. Note that in C++11 mode, this method does not participate in
4714 // overload resolution if it would lead to ambiguity with the move
4715 // constructor that does not take an allocator (below) or with the
4716 // constructor taking a 'valueOrAllocator' (above).
4717
4718 template <class TYPE>
4719#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4720 Variant15(TYPE&& value,
4721 typename bsl::enable_if<
4722 !bsl::is_same<
4723 SelfType,
4724 typename bsl::remove_const<
4725 typename bsl::remove_reference<TYPE>::type>::type>::value,
4726 bslma::Allocator>::type *basicAllocator);
4727#else
4728 Variant15(bslmf::MovableRef<TYPE> value,
4729 bslma::Allocator *basicAllocator);
4730#endif
4731 // Create a variant object having the specified 'value' of template
4732 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4733 // memory. If 'basicAllocator' is 0, the currently installed default
4734 // allocator is used. The contents of 'value' are moved to the
4735 // newly-created object with 'value' left in a valid but unspecified
4736 // state. 'TYPE' must be the same as one of the types that this
4737 // variant can hold. Note that in C++11 mode, this method does not
4738 // participate in overload resolution if it would lead to ambiguity
4739 // with the move constructor that takes an allocator (below).
4740
4741 /// Create a variant object having the type and value of the specified
4742 /// `original` variant. Optionally specify a `basicAllocator` used to
4743 /// supply memory. If `basicAllocator` is 0, the currently installed
4744 /// default allocator is used.
4745 Variant15(const Variant15& original, bslma::Allocator *basicAllocator = 0);
4746
4747 /// Create a variant object having the type and value of the specified
4748 /// `original` object by moving the contents of `original` to the
4749 /// newly-created object. The allocator associated with `original` (if
4750 /// any) is propagated for use in the newly-created object. `original`
4751 /// is left in a valid but unspecified state.
4752 Variant15(bslmf::MovableRef<Variant15> original);
4753
4754 /// Create a variant object having the type and value of the specified
4755 /// `original` object that uses the specified `basicAllocator` to supply
4756 /// memory. If `basicAllocator` is 0, the currently installed default
4757 /// allocator is used. The contents of `original` are moved to the
4758 /// newly-created object with `original` left in a valid but unspecified
4759 /// state.
4760 Variant15(bslmf::MovableRef<Variant15> original,
4761 bslma::Allocator *basicAllocator);
4762
4763 // MANIPULATORS
4764
4765 /// Assign to this object the specified `value` of template parameter
4766 /// `TYPE`, and return a reference providing modifiable access to this
4767 /// object. The value currently held by this variant (if any) is
4768 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4769 /// must be the same as one of the types that this variant can hold.
4770 template <class TYPE>
4771 Variant15& operator=(const TYPE& value);
4772
4773 template <class TYPE>
4774#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4775 typename bsl::enable_if<
4776 !bsl::is_same<SelfType,
4777 typename bsl::remove_cvref<TYPE>::type>::value,
4778 SelfType>::type&
4779 operator=(TYPE&& value);
4780#else
4781 Variant15&
4782 operator=(bslmf::MovableRef<TYPE> value);
4783#endif
4784 // Assign to this object the specified 'value' of template parameter
4785 // 'TYPE', and return a reference providing modifiable access to this
4786 // object. The contents of 'value' are moved to this object with
4787 // 'value' left in a valid but unspecified state. The value currently
4788 // held by this variant (if any) is destroyed if that value's type is
4789 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4790 // that this variant can hold. Note that in C++11 mode, this method
4791 // does not participate in overload resolution if it would lead to
4792 // ambiguity with the move-assignment operator (below).
4793
4794 /// Assign to this object the type and value currently held by the
4795 /// specified `rhs` object, and return a reference providing modifiable
4796 /// access to this object. The value currently held by this variant
4797 /// (if any) is destroyed if that value's type is not the same as the
4798 /// type held by the `rhs` object.
4799 Variant15& operator=(const Variant15& rhs);
4800
4801 /// Assign to this object the type and value currently held by the
4802 /// specified `rhs` object, and return a reference providing modifiable
4803 /// access to this object. The value currently held by this variant
4804 /// (if any) is destroyed if that value's type is not the same as the
4805 /// type held by the `rhs` object. The contents of `rhs` are either
4806 /// move-inserted into or move-assigned to this object with `rhs` left
4807 /// in a valid but unspecified state.
4808 Variant15& operator=(bslmf::MovableRef<Variant15> rhs);
4809};
4810
4811 // ====================
4812 // class Variant16<...>
4813 // ====================
4814
4815/// This class is a "specialization" of `Variant` for a fixed number (16) of
4816/// types. Its 16 template arguments *must* all be specified (none are
4817/// defaulted to `bslmf::Nil`). It provides the same functionality as
4818/// `Variant<A1, A2, ..., A16>`.
4819template <class A1, class A2, class A3, class A4, class A5, class A6,
4820 class A7, class A8, class A9, class A10, class A11, class A12,
4821 class A13, class A14, class A15, class A16>
4822class Variant16 : public VariantImp<typename bslmf::TypeList16<
4823 A1, A2, A3, A4, A5,
4824 A6, A7, A8, A9, A10,
4825 A11, A12, A13, A14, A15,
4826 A16>::ListType> {
4827
4828 // PRIVATE TYPES
4829 typedef VariantImp<typename bslmf::TypeList16<A1, A2, A3, A4, A5, A6,
4830 A7, A8, A9, A10, A11, A12,
4831 A13, A14, A15,
4832 A16>::ListType> Imp;
4833
4834 /// `SelfType` is an alias to this class.
4835 typedef Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9,
4836 A10, A11, A12, A13, A14, A15, A16> SelfType;
4837
4838 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
4839 typedef bslmf::MovableRefUtil MoveUtil;
4840
4841 public:
4842 // TRAITS
4845 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
4848 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
4851 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
4852 BSLMF_NESTED_TRAIT_DECLARATION(Variant16, HasPrintMethod);
4853
4854 // CREATORS
4855
4856 /// Create a variant object in the unset state that uses the currently
4857 /// installed default allocator to supply memory.
4858 Variant16();
4859
4860 /// Create a variant object with the specified `valueOrAllocator` that
4861 /// can be either a value of a type that the variant can hold or an
4862 /// allocator to supply memory. If `valueOrAllocator` is not a
4863 /// `bslma::Allocator *`, then the variant will hold the value and type
4864 /// of `valueOrAllocator`, and use the currently installed default
4865 /// allocator to supply memory. Otherwise, the variant will be unset
4866 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
4867 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
4868 ///
4869 /// \note Note that this
4870 /// parameterized constructor is defined instead of two constructors
4871 /// (one taking a `bslma::Allocator *` and the other not) because
4872 /// template parameter arguments are always a better match than
4873 /// derived-to-base conversion (a concrete allocator pointer converted
4874 /// to `bslma::Allocator *`).
4875 template <class TYPE_OR_ALLOCATOR>
4876 explicit
4877 Variant16(const TYPE_OR_ALLOCATOR& valueOrAllocator);
4878
4879 /// Create a variant object having the specified `value` of template
4880 /// parameter `TYPE` and that uses the specified `basicAllocator` to
4881 /// supply memory. If `basicAllocator` is 0, the currently installed
4882 /// default allocator is used. `TYPE` must be the same as one of the
4883 /// types that this variant can hold.
4884 template <class TYPE>
4885 Variant16(const TYPE& value, bslma::Allocator *basicAllocator);
4886
4887 template <class TYPE>
4888 explicit
4889#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4890 Variant16(TYPE&& value,
4891 typename bsl::enable_if<
4892 !bsl::is_same<
4893 SelfType,
4894 typename bsl::remove_const<
4895 typename bsl::remove_reference<TYPE>::type>::type>::value
4896 &&
4898 void>::type * = 0);
4899#else
4900 Variant16(bslmf::MovableRef<TYPE> value);
4901#endif
4902 // Create a variant object having the specified 'value' of template
4903 // parameter 'TYPE' by moving the contents of 'value' to the
4904 // newly-created object. Use the currently installed default allocator
4905 // to supply memory. 'value' is left in a valid but unspecified state.
4906 // 'TYPE' must be the same as one of the types that this variant can
4907 // hold. Note that in C++11 mode, this method does not participate in
4908 // overload resolution if it would lead to ambiguity with the move
4909 // constructor that does not take an allocator (below) or with the
4910 // constructor taking a 'valueOrAllocator' (above).
4911
4912 template <class TYPE>
4913#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4914 Variant16(TYPE&& value,
4915 typename bsl::enable_if<
4916 !bsl::is_same<
4917 SelfType,
4918 typename bsl::remove_const<
4919 typename bsl::remove_reference<TYPE>::type>::type>::value,
4920 bslma::Allocator>::type *basicAllocator);
4921#else
4922 Variant16(bslmf::MovableRef<TYPE> value,
4923 bslma::Allocator *basicAllocator);
4924#endif
4925 // Create a variant object having the specified 'value' of template
4926 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
4927 // memory. If 'basicAllocator' is 0, the currently installed default
4928 // allocator is used. The contents of 'value' are moved to the
4929 // newly-created object with 'value' left in a valid but unspecified
4930 // state. 'TYPE' must be the same as one of the types that this
4931 // variant can hold. Note that in C++11 mode, this method does not
4932 // participate in overload resolution if it would lead to ambiguity
4933 // with the move constructor that takes an allocator (below).
4934
4935 /// Create a variant object having the type and value of the specified
4936 /// `original` variant. Optionally specify a `basicAllocator` used to
4937 /// supply memory. If `basicAllocator` is 0, the currently installed
4938 /// default allocator is used.
4939 Variant16(const Variant16& original, bslma::Allocator *basicAllocator = 0);
4940
4941 /// Create a variant object having the type and value of the specified
4942 /// `original` object by moving the contents of `original` to the
4943 /// newly-created object. The allocator associated with `original` (if
4944 /// any) is propagated for use in the newly-created object. `original`
4945 /// is left in a valid but unspecified state.
4946 Variant16(bslmf::MovableRef<Variant16> original);
4947
4948 /// Create a variant object having the type and value of the specified
4949 /// `original` object that uses the specified `basicAllocator` to supply
4950 /// memory. If `basicAllocator` is 0, the currently installed default
4951 /// allocator is used. The contents of `original` are moved to the
4952 /// newly-created object with `original` left in a valid but unspecified
4953 /// state.
4954 Variant16(bslmf::MovableRef<Variant16> original,
4955 bslma::Allocator *basicAllocator);
4956
4957 // MANIPULATORS
4958
4959 /// Assign to this object the specified `value` of template parameter
4960 /// `TYPE`, and return a reference providing modifiable access to this
4961 /// object. The value currently held by this variant (if any) is
4962 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
4963 /// must be the same as one of the types that this variant can hold.
4964 template <class TYPE>
4965 Variant16& operator=(const TYPE& value);
4966
4967 template <class TYPE>
4968#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4969 typename bsl::enable_if<
4970 !bsl::is_same<SelfType,
4971 typename bsl::remove_cvref<TYPE>::type>::value,
4972 SelfType>::type&
4973 operator=(TYPE&& value);
4974#else
4975 Variant16&
4976 operator=(bslmf::MovableRef<TYPE> value);
4977#endif
4978 // Assign to this object the specified 'value' of template parameter
4979 // 'TYPE', and return a reference providing modifiable access to this
4980 // object. The contents of 'value' are moved to this object with
4981 // 'value' left in a valid but unspecified state. The value currently
4982 // held by this variant (if any) is destroyed if that value's type is
4983 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
4984 // that this variant can hold. Note that in C++11 mode, this method
4985 // does not participate in overload resolution if it would lead to
4986 // ambiguity with the move-assignment operator (below).
4987
4988 /// Assign to this object the type and value currently held by the
4989 /// specified `rhs` object, and return a reference providing modifiable
4990 /// access to this object. The value currently held by this variant
4991 /// (if any) is destroyed if that value's type is not the same as the
4992 /// type held by the `rhs` object.
4993 Variant16& operator=(const Variant16& rhs);
4994
4995 /// Assign to this object the type and value currently held by the
4996 /// specified `rhs` object, and return a reference providing modifiable
4997 /// access to this object. The value currently held by this variant
4998 /// (if any) is destroyed if that value's type is not the same as the
4999 /// type held by the `rhs` object. The contents of `rhs` are either
5000 /// move-inserted into or move-assigned to this object with `rhs` left
5001 /// in a valid but unspecified state.
5002 Variant16& operator=(bslmf::MovableRef<Variant16> rhs);
5003};
5004
5005 // ====================
5006 // class Variant17<...>
5007 // ====================
5008
5009/// This class is a "specialization" of `Variant` for a fixed number (17) of
5010/// types. Its 17 template arguments *must* all be specified (none are
5011/// defaulted to `bslmf::Nil`). It provides the same functionality as
5012/// `Variant<A1, A2, ..., A17>`.
5013template <class A1, class A2, class A3, class A4, class A5, class A6,
5014 class A7, class A8, class A9, class A10, class A11, class A12,
5015 class A13, class A14, class A15, class A16, class A17>
5016class Variant17 : public VariantImp<typename bslmf::TypeList17<
5017 A1, A2, A3, A4, A5,
5018 A6, A7, A8, A9, A10,
5019 A11, A12, A13, A14, A15,
5020 A16, A17>::ListType> {
5021
5022 // PRIVATE TYPES
5023 typedef VariantImp<typename bslmf::TypeList17<A1, A2, A3, A4, A5, A6,
5024 A7, A8, A9, A10, A11, A12,
5025 A13, A14, A15, A16,
5026 A17>::ListType> Imp;
5027
5028 /// `SelfType` is an alias to this class.
5029 typedef Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5030 A10, A11, A12, A13, A14, A15, A16, A17> SelfType;
5031
5032 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
5033 typedef bslmf::MovableRefUtil MoveUtil;
5034
5035 public:
5036 // TRAITS
5039 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5042 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5045 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5046 BSLMF_NESTED_TRAIT_DECLARATION(Variant17, HasPrintMethod);
5047
5048 // CREATORS
5049
5050 /// Create a variant object in the unset state that uses the currently
5051 /// installed default allocator to supply memory.
5052 Variant17();
5053
5054 /// Create a variant object with the specified `valueOrAllocator` that
5055 /// can be either a value of a type that the variant can hold or an
5056 /// allocator to supply memory. If `valueOrAllocator` is not a
5057 /// `bslma::Allocator *`, then the variant will hold the value and type
5058 /// of `valueOrAllocator`, and use the currently installed default
5059 /// allocator to supply memory. Otherwise, the variant will be unset
5060 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5061 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5062 ///
5063 /// \note Note that this
5064 /// parameterized constructor is defined instead of two constructors
5065 /// (one taking a `bslma::Allocator *` and the other not) because
5066 /// template parameter arguments are always a better match than
5067 /// derived-to-base conversion (a concrete allocator pointer converted
5068 /// to `bslma::Allocator *`).
5069 template <class TYPE_OR_ALLOCATOR>
5070 explicit
5071 Variant17(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5072
5073 /// Create a variant object having the specified `value` of template
5074 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5075 /// supply memory. If `basicAllocator` is 0, the currently installed
5076 /// default allocator is used. `TYPE` must be the same as one of the
5077 /// types that this variant can hold.
5078 template <class TYPE>
5079 Variant17(const TYPE& value, bslma::Allocator *basicAllocator);
5080
5081 template <class TYPE>
5082 explicit
5083#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5084 Variant17(TYPE&& value,
5085 typename bsl::enable_if<
5086 !bsl::is_same<
5087 SelfType,
5088 typename bsl::remove_const<
5089 typename bsl::remove_reference<TYPE>::type>::type>::value
5090 &&
5092 void>::type * = 0);
5093#else
5094 Variant17(bslmf::MovableRef<TYPE> value);
5095#endif
5096 // Create a variant object having the specified 'value' of template
5097 // parameter 'TYPE' by moving the contents of 'value' to the
5098 // newly-created object. Use the currently installed default allocator
5099 // to supply memory. 'value' is left in a valid but unspecified state.
5100 // 'TYPE' must be the same as one of the types that this variant can
5101 // hold. Note that in C++11 mode, this method does not participate in
5102 // overload resolution if it would lead to ambiguity with the move
5103 // constructor that does not take an allocator (below) or with the
5104 // constructor taking a 'valueOrAllocator' (above).
5105
5106 template <class TYPE>
5107#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5108 Variant17(TYPE&& value,
5109 typename bsl::enable_if<
5110 !bsl::is_same<
5111 SelfType,
5112 typename bsl::remove_const<
5113 typename bsl::remove_reference<TYPE>::type>::type>::value,
5114 bslma::Allocator>::type *basicAllocator);
5115#else
5116 Variant17(bslmf::MovableRef<TYPE> value,
5117 bslma::Allocator *basicAllocator);
5118#endif
5119 // Create a variant object having the specified 'value' of template
5120 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5121 // memory. If 'basicAllocator' is 0, the currently installed default
5122 // allocator is used. The contents of 'value' are moved to the
5123 // newly-created object with 'value' left in a valid but unspecified
5124 // state. 'TYPE' must be the same as one of the types that this
5125 // variant can hold. Note that in C++11 mode, this method does not
5126 // participate in overload resolution if it would lead to ambiguity
5127 // with the move constructor that takes an allocator (below).
5128
5129 /// Create a variant object having the type and value of the specified
5130 /// `original` variant. Optionally specify a `basicAllocator` used to
5131 /// supply memory. If `basicAllocator` is 0, the currently installed
5132 /// default allocator is used.
5133 Variant17(const Variant17& original, bslma::Allocator *basicAllocator = 0);
5134
5135 /// Create a variant object having the type and value of the specified
5136 /// `original` object by moving the contents of `original` to the
5137 /// newly-created object. The allocator associated with `original` (if
5138 /// any) is propagated for use in the newly-created object. `original`
5139 /// is left in a valid but unspecified state.
5140 Variant17(bslmf::MovableRef<Variant17> original);
5141
5142 /// Create a variant object having the type and value of the specified
5143 /// `original` object that uses the specified `basicAllocator` to supply
5144 /// memory. If `basicAllocator` is 0, the currently installed default
5145 /// allocator is used. The contents of `original` are moved to the
5146 /// newly-created object with `original` left in a valid but unspecified
5147 /// state.
5148 Variant17(bslmf::MovableRef<Variant17> original,
5149 bslma::Allocator *basicAllocator);
5150
5151 // MANIPULATORS
5152
5153 /// Assign to this object the specified `value` of template parameter
5154 /// `TYPE`, and return a reference providing modifiable access to this
5155 /// object. The value currently held by this variant (if any) is
5156 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5157 /// must be the same as one of the types that this variant can hold.
5158 template <class TYPE>
5159 Variant17& operator=(const TYPE& value);
5160
5161 template <class TYPE>
5162#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5163 typename bsl::enable_if<
5164 !bsl::is_same<SelfType,
5165 typename bsl::remove_cvref<TYPE>::type>::value,
5166 SelfType>::type&
5167 operator=(TYPE&& value);
5168#else
5169 Variant17&
5170 operator=(bslmf::MovableRef<TYPE> value);
5171#endif
5172 // Assign to this object the specified 'value' of template parameter
5173 // 'TYPE', and return a reference providing modifiable access to this
5174 // object. The contents of 'value' are moved to this object with
5175 // 'value' left in a valid but unspecified state. The value currently
5176 // held by this variant (if any) is destroyed if that value's type is
5177 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5178 // that this variant can hold. Note that in C++11 mode, this method
5179 // does not participate in overload resolution if it would lead to
5180 // ambiguity with the move-assignment operator (below).
5181
5182 /// Assign to this object the type and value currently held by the
5183 /// specified `rhs` object, and return a reference providing modifiable
5184 /// access to this object. The value currently held by this variant
5185 /// (if any) is destroyed if that value's type is not the same as the
5186 /// type held by the `rhs` object.
5187 Variant17& operator=(const Variant17& rhs);
5188
5189 /// Assign to this object the type and value currently held by the
5190 /// specified `rhs` object, and return a reference providing modifiable
5191 /// access to this object. The value currently held by this variant
5192 /// (if any) is destroyed if that value's type is not the same as the
5193 /// type held by the `rhs` object. The contents of `rhs` are either
5194 /// move-inserted into or move-assigned to this object with `rhs` left
5195 /// in a valid but unspecified state.
5196 Variant17& operator=(bslmf::MovableRef<Variant17> rhs);
5197};
5198
5199 // ====================
5200 // class Variant18<...>
5201 // ====================
5202
5203/// This class is a "specialization" of `Variant` for a fixed number (18) of
5204/// types. Its 18 template arguments *must* all be specified (none are
5205/// defaulted to `bslmf::Nil`). It provides the same functionality as
5206/// `Variant<A1, A2, ..., A18>`.
5207template <class A1, class A2, class A3, class A4, class A5, class A6,
5208 class A7, class A8, class A9, class A10, class A11, class A12,
5209 class A13, class A14, class A15, class A16, class A17, class A18>
5210class Variant18 : public VariantImp<typename bslmf::TypeList18<
5211 A1, A2, A3, A4, A5,
5212 A6, A7, A8, A9, A10,
5213 A11, A12, A13, A14, A15,
5214 A16, A17, A18>::ListType> {
5215
5216 // PRIVATE TYPES
5217 typedef VariantImp<typename bslmf::TypeList18<A1, A2, A3, A4, A5, A6,
5218 A7, A8, A9, A10, A11, A12,
5219 A13, A14, A15, A16, A17,
5220 A18>::ListType> Imp;
5221
5222 /// `SelfType` is an alias to this class.
5223 typedef Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5224 A10, A11, A12, A13, A14, A15, A16, A17, A18> SelfType;
5225
5226 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
5227 typedef bslmf::MovableRefUtil MoveUtil;
5228
5229 public:
5230 // TRAITS
5233 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5236 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5239 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5240 BSLMF_NESTED_TRAIT_DECLARATION(Variant18, HasPrintMethod);
5241
5242 // CREATORS
5243
5244 /// Create a variant object in the unset state that uses the currently
5245 /// installed default allocator to supply memory.
5246 Variant18();
5247
5248 /// Create a variant object with the specified `valueOrAllocator` that
5249 /// can be either a value of a type that the variant can hold or an
5250 /// allocator to supply memory. If `valueOrAllocator` is not a
5251 /// `bslma::Allocator *`, then the variant will hold the value and type
5252 /// of `valueOrAllocator`, and use the currently installed default
5253 /// allocator to supply memory. Otherwise, the variant will be unset
5254 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5255 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5256 ///
5257 /// \note Note that this
5258 /// parameterized constructor is defined instead of two constructors
5259 /// (one taking a `bslma::Allocator *` and the other not) because
5260 /// template parameter arguments are always a better match than
5261 /// derived-to-base conversion (a concrete allocator pointer converted
5262 /// to `bslma::Allocator *`).
5263 template <class TYPE_OR_ALLOCATOR>
5264 explicit
5265 Variant18(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5266
5267 /// Create a variant object having the specified `value` of template
5268 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5269 /// supply memory. If `basicAllocator` is 0, the currently installed
5270 /// default allocator is used. `TYPE` must be the same as one of the
5271 /// types that this variant can hold.
5272 template <class TYPE>
5273 Variant18(const TYPE& value, bslma::Allocator *basicAllocator);
5274
5275 template <class TYPE>
5276 explicit
5277#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5278 Variant18(TYPE&& value,
5279 typename bsl::enable_if<
5280 !bsl::is_same<
5281 SelfType,
5282 typename bsl::remove_const<
5283 typename bsl::remove_reference<TYPE>::type>::type>::value
5284 &&
5286 void>::type * = 0);
5287#else
5288 Variant18(bslmf::MovableRef<TYPE> value);
5289#endif
5290 // Create a variant object having the specified 'value' of template
5291 // parameter 'TYPE' by moving the contents of 'value' to the
5292 // newly-created object. Use the currently installed default allocator
5293 // to supply memory. 'value' is left in a valid but unspecified state.
5294 // 'TYPE' must be the same as one of the types that this variant can
5295 // hold. Note that in C++11 mode, this method does not participate in
5296 // overload resolution if it would lead to ambiguity with the move
5297 // constructor that does not take an allocator (below) or with the
5298 // constructor taking a 'valueOrAllocator' (above).
5299
5300 template <class TYPE>
5301#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5302 Variant18(TYPE&& value,
5303 typename bsl::enable_if<
5304 !bsl::is_same<
5305 SelfType,
5306 typename bsl::remove_const<
5307 typename bsl::remove_reference<TYPE>::type>::type>::value,
5308 bslma::Allocator>::type *basicAllocator);
5309#else
5310 Variant18(bslmf::MovableRef<TYPE> value,
5311 bslma::Allocator *basicAllocator);
5312#endif
5313 // Create a variant object having the specified 'value' of template
5314 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5315 // memory. If 'basicAllocator' is 0, the currently installed default
5316 // allocator is used. The contents of 'value' are moved to the
5317 // newly-created object with 'value' left in a valid but unspecified
5318 // state. 'TYPE' must be the same as one of the types that this
5319 // variant can hold. Note that in C++11 mode, this method does not
5320 // participate in overload resolution if it would lead to ambiguity
5321 // with the move constructor that takes an allocator (below).
5322
5323 /// Create a variant object having the type and value of the specified
5324 /// `original` variant. Optionally specify a `basicAllocator` used to
5325 /// supply memory. If `basicAllocator` is 0, the currently installed
5326 /// default allocator is used.
5327 Variant18(const Variant18& original, bslma::Allocator *basicAllocator = 0);
5328
5329 /// Create a variant object having the type and value of the specified
5330 /// `original` object by moving the contents of `original` to the
5331 /// newly-created object. The allocator associated with `original` (if
5332 /// any) is propagated for use in the newly-created object. `original`
5333 /// is left in a valid but unspecified state.
5334 Variant18(bslmf::MovableRef<Variant18> original);
5335
5336 /// Create a variant object having the type and value of the specified
5337 /// `original` object that uses the specified `basicAllocator` to supply
5338 /// memory. If `basicAllocator` is 0, the currently installed default
5339 /// allocator is used. The contents of `original` are moved to the
5340 /// newly-created object with `original` left in a valid but unspecified
5341 /// state.
5342 Variant18(bslmf::MovableRef<Variant18> original,
5343 bslma::Allocator *basicAllocator);
5344
5345 // MANIPULATORS
5346
5347 /// Assign to this object the specified `value` of template parameter
5348 /// `TYPE`, and return a reference providing modifiable access to this
5349 /// object. The value currently held by this variant (if any) is
5350 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5351 /// must be the same as one of the types that this variant can hold.
5352 template <class TYPE>
5353 Variant18& operator=(const TYPE& value);
5354
5355 template <class TYPE>
5356#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5357 typename bsl::enable_if<
5358 !bsl::is_same<SelfType,
5359 typename bsl::remove_cvref<TYPE>::type>::value,
5360 SelfType>::type&
5361 operator=(TYPE&& value);
5362#else
5363 Variant18&
5364 operator=(bslmf::MovableRef<TYPE> value);
5365#endif
5366 // Assign to this object the specified 'value' of template parameter
5367 // 'TYPE', and return a reference providing modifiable access to this
5368 // object. The contents of 'value' are moved to this object with
5369 // 'value' left in a valid but unspecified state. The value currently
5370 // held by this variant (if any) is destroyed if that value's type is
5371 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5372 // that this variant can hold. Note that in C++11 mode, this method
5373 // does not participate in overload resolution if it would lead to
5374 // ambiguity with the move-assignment operator (below).
5375
5376 /// Assign to this object the type and value currently held by the
5377 /// specified `rhs` object, and return a reference providing modifiable
5378 /// access to this object. The value currently held by this variant
5379 /// (if any) is destroyed if that value's type is not the same as the
5380 /// type held by the `rhs` object.
5381 Variant18& operator=(const Variant18& rhs);
5382
5383 /// Assign to this object the type and value currently held by the
5384 /// specified `rhs` object, and return a reference providing modifiable
5385 /// access to this object. The value currently held by this variant
5386 /// (if any) is destroyed if that value's type is not the same as the
5387 /// type held by the `rhs` object. The contents of `rhs` are either
5388 /// move-inserted into or move-assigned to this object with `rhs` left
5389 /// in a valid but unspecified state.
5390 Variant18& operator=(bslmf::MovableRef<Variant18> rhs);
5391};
5392
5393 // ====================
5394 // class Variant19<...>
5395 // ====================
5396
5397/// This class is a "specialization" of `Variant` for a fixed number (19) of
5398/// types. Its 19 template arguments *must* all be specified (none are
5399/// defaulted to `bslmf::Nil`). It provides the same functionality as
5400/// `Variant<A1, A2, ..., A19>`.
5401template <class A1, class A2, class A3, class A4, class A5, class A6,
5402 class A7, class A8, class A9, class A10, class A11, class A12,
5403 class A13, class A14, class A15, class A16, class A17, class A18,
5404 class A19>
5405class Variant19 : public VariantImp<typename bslmf::TypeList19<
5406 A1, A2, A3, A4, A5,
5407 A6, A7, A8, A9, A10,
5408 A11, A12, A13, A14, A15,
5409 A16, A17, A18, A19>::ListType> {
5410
5411 // PRIVATE TYPES
5412 typedef VariantImp<typename bslmf::TypeList19<A1, A2, A3, A4, A5, A6,
5413 A7, A8, A9, A10, A11, A12,
5414 A13, A14, A15, A16, A17, A18,
5415 A19>::ListType> Imp;
5416
5417 /// `SelfType` is an alias to this class.
5418 typedef Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9,
5419 A10, A11, A12, A13, A14, A15, A16, A17, A18,
5420 A19> SelfType;
5421
5422 typedef VariantImp_Traits<typename Imp::TypeList> Traits;
5423 typedef bslmf::MovableRefUtil MoveUtil;
5424
5425 public:
5426 // TRAITS
5429 Traits::k_VARIANT_USES_BSLMA_ALLOCATOR);
5432 Traits::k_VARIANT_IS_BITWISE_COPYABLE);
5435 Traits::k_VARIANT_IS_BITWISE_MOVEABLE);
5436 BSLMF_NESTED_TRAIT_DECLARATION(Variant19, HasPrintMethod);
5437
5438 // CREATORS
5439
5440 /// Create a variant object in the unset state that uses the currently
5441 /// installed default allocator to supply memory.
5442 Variant19();
5443
5444 /// Create a variant object with the specified `valueOrAllocator` that
5445 /// can be either a value of a type that the variant can hold or an
5446 /// allocator to supply memory. If `valueOrAllocator` is not a
5447 /// `bslma::Allocator *`, then the variant will hold the value and type
5448 /// of `valueOrAllocator`, and use the currently installed default
5449 /// allocator to supply memory. Otherwise, the variant will be unset
5450 /// and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR`
5451 /// must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`.
5452 ///
5453 /// \note Note that this
5454 /// parameterized constructor is defined instead of two constructors
5455 /// (one taking a `bslma::Allocator *` and the other not) because
5456 /// template parameter arguments are always a better match than
5457 /// derived-to-base conversion (a concrete allocator pointer converted
5458 /// to `bslma::Allocator *`).
5459 template <class TYPE_OR_ALLOCATOR>
5460 explicit
5461 Variant19(const TYPE_OR_ALLOCATOR& valueOrAllocator);
5462
5463 /// Create a variant object having the specified `value` of template
5464 /// parameter `TYPE` and that uses the specified `basicAllocator` to
5465 /// supply memory. If `basicAllocator` is 0, the currently installed
5466 /// default allocator is used. `TYPE` must be the same as one of the
5467 /// types that this variant can hold.
5468 template <class TYPE>
5469 Variant19(const TYPE& value, bslma::Allocator *basicAllocator);
5470
5471 template <class TYPE>
5472 explicit
5473#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5474 Variant19(TYPE&& value,
5475 typename bsl::enable_if<
5476 !bsl::is_same<
5477 SelfType,
5478 typename bsl::remove_const<
5479 typename bsl::remove_reference<TYPE>::type>::type>::value
5480 &&
5482 void>::type * = 0);
5483#else
5484 Variant19(bslmf::MovableRef<TYPE> value);
5485#endif
5486 // Create a variant object having the specified 'value' of template
5487 // parameter 'TYPE' by moving the contents of 'value' to the
5488 // newly-created object. Use the currently installed default allocator
5489 // to supply memory. 'value' is left in a valid but unspecified state.
5490 // 'TYPE' must be the same as one of the types that this variant can
5491 // hold. Note that in C++11 mode, this method does not participate in
5492 // overload resolution if it would lead to ambiguity with the move
5493 // constructor that does not take an allocator (below) or with the
5494 // constructor taking a 'valueOrAllocator' (above).
5495
5496 template <class TYPE>
5497#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5498 Variant19(TYPE&& value,
5499 typename bsl::enable_if<
5500 !bsl::is_same<
5501 SelfType,
5502 typename bsl::remove_const<
5503 typename bsl::remove_reference<TYPE>::type>::type>::value,
5504 bslma::Allocator>::type *basicAllocator);
5505#else
5506 Variant19(bslmf::MovableRef<TYPE> value,
5507 bslma::Allocator *basicAllocator);
5508#endif
5509 // Create a variant object having the specified 'value' of template
5510 // parameter 'TYPE' that uses the specified 'basicAllocator' to supply
5511 // memory. If 'basicAllocator' is 0, the currently installed default
5512 // allocator is used. The contents of 'value' are moved to the
5513 // newly-created object with 'value' left in a valid but unspecified
5514 // state. 'TYPE' must be the same as one of the types that this
5515 // variant can hold. Note that in C++11 mode, this method does not
5516 // participate in overload resolution if it would lead to ambiguity
5517 // with the move constructor that takes an allocator (below).
5518
5519 /// Create a variant object having the type and value of the specified
5520 /// `original` variant. Optionally specify a `basicAllocator` used to
5521 /// supply memory. If `basicAllocator` is 0, the currently installed
5522 /// default allocator is used.
5523 Variant19(const Variant19& original, bslma::Allocator *basicAllocator = 0);
5524
5525 /// Create a variant object having the type and value of the specified
5526 /// `original` object by moving the contents of `original` to the
5527 /// newly-created object. The allocator associated with `original` (if
5528 /// any) is propagated for use in the newly-created object. `original`
5529 /// is left in a valid but unspecified state.
5530 Variant19(bslmf::MovableRef<Variant19> original);
5531
5532 /// Create a variant object having the type and value of the specified
5533 /// `original` object that uses the specified `basicAllocator` to supply
5534 /// memory. If `basicAllocator` is 0, the currently installed default
5535 /// allocator is used. The contents of `original` are moved to the
5536 /// newly-created object with `original` left in a valid but unspecified
5537 /// state.
5538 Variant19(bslmf::MovableRef<Variant19> original,
5539 bslma::Allocator *basicAllocator);
5540
5541 // MANIPULATORS
5542
5543 /// Assign to this object the specified `value` of template parameter
5544 /// `TYPE`, and return a reference providing modifiable access to this
5545 /// object. The value currently held by this variant (if any) is
5546 /// destroyed if that value's type is not the same as `TYPE`. `TYPE`
5547 /// must be the same as one of the types that this variant can hold.
5548 template <class TYPE>
5549 Variant19& operator=(const TYPE& value);
5550
5551 template <class TYPE>
5552#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5553 typename bsl::enable_if<
5554 !bsl::is_same<SelfType,
5555 typename bsl::remove_cvref<TYPE>::type>::value,
5556 SelfType>::type&
5557 operator=(TYPE&& value);
5558#else
5559 Variant19&
5560 operator=(bslmf::MovableRef<TYPE> value);
5561#endif
5562 // Assign to this object the specified 'value' of template parameter
5563 // 'TYPE', and return a reference providing modifiable access to this
5564 // object. The contents of 'value' are moved to this object with
5565 // 'value' left in a valid but unspecified state. The value currently
5566 // held by this variant (if any) is destroyed if that value's type is
5567 // not the same as 'TYPE'. 'TYPE' must be the same as one of the types
5568 // that this variant can hold. Note that in C++11 mode, this method
5569 // does not participate in overload resolution if it would lead to
5570 // ambiguity with the move-assignment operator (below).
5571
5572 /// Assign to this object the type and value currently held by the
5573 /// specified `rhs` object, and return a reference providing modifiable
5574 /// access to this object. The value currently held by this variant
5575 /// (if any) is destroyed if that value's type is not the same as the
5576 /// type held by the `rhs` object.
5577 Variant19& operator=(const Variant19& rhs);
5578
5579 /// Assign to this object the type and value currently held by the
5580 /// specified `rhs` object, and return a reference providing modifiable
5581 /// access to this object. The value currently held by this variant
5582 /// (if any) is destroyed if that value's type is not the same as the
5583 /// type held by the `rhs` object. The contents of `rhs` are either
5584 /// move-inserted into or move-assigned to this object with `rhs` left
5585 /// in a valid but unspecified state.
5586 Variant19& operator=(bslmf::MovableRef<Variant19> rhs);
5587};
5588
5589// ---- Anything below this line is implementation specific. Do not use. ----
5590
5591 // =====================================
5592 // struct Variant_TypeIndex<TYPES, TYPE>
5593 // =====================================
5594
5595/// Component-private meta-function. Do not use. This meta-function
5596/// computes the index of the template parameter `TYPE` in the template
5597/// parameter list of `TYPES`.
5598///
5599/// See @ref bdlb_variant_cpp03
5600template <class TYPES, class TYPE>
5601struct Variant_TypeIndex {
5602
5603 enum {
5604 value = bsl::is_same<
5606 TYPE>::value ? 1
5607 : bsl::is_same<
5609 TYPE>::value ? 2
5610 : bsl::is_same<
5612 TYPE>::value ? 3
5613 : bsl::is_same<
5615 TYPE>::value ? 4
5616 : bsl::is_same<
5618 TYPE>::value ? 5
5619 : bsl::is_same<
5621 TYPE>::value ? 6
5622 : bsl::is_same<
5624 TYPE>::value ? 7
5625 : bsl::is_same<
5627 TYPE>::value ? 8
5628 : bsl::is_same<
5630 TYPE>::value ? 9
5631 : bsl::is_same<
5633 TYPE>::value ? 10
5634 : bsl::is_same<
5636 TYPE>::value ? 11
5637 : bsl::is_same<
5639 TYPE>::value ? 12
5640 : bsl::is_same<
5642 TYPE>::value ? 13
5643 : bsl::is_same<
5645 TYPE>::value ? 14
5646 : bsl::is_same<
5648 TYPE>::value ? 15
5649 : bsl::is_same<
5651 TYPE>::value ? 16
5652 : bsl::is_same<
5654 TYPE>::value ? 17
5655 : bsl::is_same<
5657 TYPE>::value ? 18
5658 : bsl::is_same<
5660 TYPE>::value ? 19
5661 : bsl::is_same<
5663 TYPE>::value ? 20
5665 ? 21
5666 : 0
5667 };
5668
5669 BSLMF_ASSERT(0 != value);
5670
5671#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
5672 // See 'testCase17' in the test driver for code snippets that motivate this
5673 // compile-time assertion (see the "out of bounds" comments). In C++03,
5674 // 'TYPES::LENGTH' yields an incorrect value if 'TYPES' has a trailing
5675 // 'bslmf::Nil' (unless the variant is declared using 'VariantN'). It is
5676 // arguably dubious to allow 'bslmf::Nil' as one of the types that a
5677 // variant may hold, but there is such use in production code that needs to
5678 // be considered if that "feature" is to be suppressed. This would do it:
5679 //..
5680 // BSLMF_ASSERT((!bsl::is_same<TYPE, bslmf::Nil>::value));
5681 //..
5682
5683 // TBD The following breaks compilation of some client code in C++11 mode
5684 // that is most likely misusing 'bslmf::Nil'.
5685 // BSLMF_ASSERT(((int)value <= (int)TYPES::LENGTH || 21 == value));
5686#endif
5687};
5688
5689 // ======================================
5690 // struct Variant_DefaultConstructVisitor
5691 // ======================================
5692
5693/// This visitor, when invoked as a non-modifiable function object on an
5694/// instance of some template parameter `TYPE`, will create a default
5695/// instance of `TYPE`.
5696///
5697/// See @ref bdlb_variant_cpp03
5698struct Variant_DefaultConstructVisitor {
5699
5700 // PUBLIC DATA
5701 bslma::Allocator *d_allocator_p;
5702
5703 // CREATORS
5704 explicit
5705 Variant_DefaultConstructVisitor(bslma::Allocator *allocator)
5706 : d_allocator_p(allocator)
5707 {
5708 }
5709
5710 // ACCESSORS
5711 template <class TYPE>
5712 void operator()(TYPE& value) const
5713 {
5714 bslma::ConstructionUtil::construct(&value, d_allocator_p);
5715 }
5716};
5717
5718 // ===================================
5719 // struct Variant_CopyConstructVisitor
5720 // ===================================
5721
5722/// This visitor, when invoked as a non-modifiable function object on an
5723/// instance of some template parameter `TYPE`, will copy-insert that
5724/// instance to create an instance of the same `TYPE` in an uninitialized
5725/// buffer specified at construction of this visitor.
5726///
5727/// See @ref bdlb_variant_cpp03
5728struct Variant_CopyConstructVisitor {
5729
5730 // PUBLIC DATA
5731 void *d_buffer_p;
5732 bslma::Allocator *d_allocator_p;
5733
5734 // CREATORS
5735 Variant_CopyConstructVisitor(void *buffer, bslma::Allocator *allocator)
5736 : d_buffer_p(buffer)
5737 , d_allocator_p(allocator)
5738 {
5739 BSLS_ASSERT_SAFE(d_buffer_p);
5740 }
5741
5742 // ACCESSORS
5743 template <class TYPE>
5744 void operator()(const TYPE& value) const
5745 {
5747 reinterpret_cast<TYPE *>(d_buffer_p),
5748 d_allocator_p,
5749 value);
5750 }
5751};
5752
5753 // ===================================
5754 // struct Variant_MoveConstructVisitor
5755 // ===================================
5756
5757/// This visitor, when invoked as a non-modifiable function object on an
5758/// instance of some template parameter `TYPE`, will move-insert that
5759/// instance to create an instance of the same `TYPE` in an uninitialized
5760/// buffer specified at construction of this visitor.
5761///
5762/// See @ref bdlb_variant_cpp03
5763struct Variant_MoveConstructVisitor {
5764
5765 // PUBLIC DATA
5766 void *d_buffer_p;
5767 bslma::Allocator *d_allocator_p;
5768
5769 // CREATORS
5770 Variant_MoveConstructVisitor(void *buffer, bslma::Allocator *allocator)
5771 : d_buffer_p(buffer)
5772 , d_allocator_p(allocator)
5773 {
5774 BSLS_ASSERT_SAFE(d_buffer_p);
5775 }
5776
5777 // ACCESSORS
5778 template <class TYPE>
5779 void operator()(TYPE& value) const
5780 {
5782 reinterpret_cast<TYPE *>(d_buffer_p),
5783 d_allocator_p,
5785 }
5786};
5787
5788 // ================================
5789 // struct Variant_DestructorVisitor
5790 // ================================
5791
5792/// This visitor, when invoked as a function object on an instance of some
5793/// template parameter `TYPE`, will destroy that instance.
5794///
5795/// See @ref bdlb_variant_cpp03
5796struct Variant_DestructorVisitor {
5797
5798 // ACCESSORS
5799 template <class TYPE>
5800 void operator()(TYPE& object) const
5801 {
5802 bslma::DestructionUtil::destroy(&object);
5803 }
5804};
5805
5806 // ================================
5807 // struct Variant_CopyAssignVisitor
5808 // ================================
5809
5810/// This visitor, when invoked as a non-modifiable function object on an
5811/// instance of some template parameter `TYPE`, will copy-assign that
5812/// instance to the instance of the same `TYPE` held in a buffer specified
5813/// at construction of this visitor.
5814///
5815/// See @ref bdlb_variant_cpp03
5816struct Variant_CopyAssignVisitor {
5817
5818 // PUBLIC DATA
5819 void *d_buffer_p;
5820
5821 // CREATORS
5822 explicit
5823 Variant_CopyAssignVisitor(void *buffer)
5824 : d_buffer_p(buffer)
5825 {
5826 BSLS_ASSERT_SAFE(d_buffer_p);
5827 }
5828
5829 // ACCESSORS
5830 template <class TYPE>
5831 void operator()(const TYPE& value)
5832 {
5833 *reinterpret_cast<TYPE *>(d_buffer_p) = value;
5834 }
5835};
5836
5837 // ================================
5838 // struct Variant_MoveAssignVisitor
5839 // ================================
5840
5841/// This visitor, when invoked as a non-modifiable function object on an
5842/// instance of some template parameter `TYPE`, will move-assign that
5843/// instance to the instance of the same `TYPE` held in a buffer specified
5844/// at construction of this visitor.
5845///
5846/// See @ref bdlb_variant_cpp03
5847struct Variant_MoveAssignVisitor {
5848
5849 // PUBLIC DATA
5850 void *d_buffer_p;
5851
5852 // CREATORS
5853 explicit
5854 Variant_MoveAssignVisitor(void *buffer)
5855 : d_buffer_p(buffer)
5856 {
5857 BSLS_ASSERT_SAFE(d_buffer_p);
5858 }
5859
5860 // ACCESSORS
5861 template <class TYPE>
5862 void operator()(TYPE& value)
5863 {
5864 *reinterpret_cast<TYPE *>(d_buffer_p) =
5866 }
5867};
5868
5869 // ==========================
5870 // struct Variant_SwapVisitor
5871 // ==========================
5872
5873/// This visitor swaps the variant object data that it holds with another
5874/// variant object data of parameterize `TYPE`. It requires that the two
5875/// variant objects being swapped contain data of the same type, and use the
5876/// same allocator.
5877///
5878/// See @ref bdlb_variant_cpp03
5879struct Variant_SwapVisitor {
5880
5881 // PUBLIC DATA
5882 void *d_buffer_p;
5883
5884 // CREATORS
5885 explicit
5886 Variant_SwapVisitor(void *buffer)
5887 : d_buffer_p(buffer)
5888 {
5889 BSLS_ASSERT_SAFE(d_buffer_p);
5890 }
5891
5892 // MANIPULATORS
5893 template <class TYPE>
5894 void operator()(TYPE& value)
5895 {
5896 bslalg::SwapUtil::swap(reinterpret_cast<TYPE *>(d_buffer_p), &value);
5897 }
5898};
5899
5900#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5901
5902 // ==================================
5903 // struct Variant_BdexStreamInVisitor
5904 // ==================================
5905
5906/// This visitor, when invoked as a non-modifiable function object on an
5907/// initialized instance of some parameterized `TYPE`, will stream in
5908/// a value of the same `TYPE` into that instance from a stream specified at
5909/// construction of this visitor, using a version also specified at
5910/// construction of this visitor.
5911///
5912/// See @ref bdlb_variant_cpp03
5913template <class STREAM>
5914struct Variant_BdexStreamInVisitor {
5915
5916 // PUBLIC DATA
5917 STREAM& d_stream; // held, not owned
5918 int d_version; // BDEX version
5919
5920 // CREATORS
5921 Variant_BdexStreamInVisitor(STREAM& stream, int version)
5922 : d_stream(stream)
5923 , d_version(version)
5924 {
5925 }
5926
5927 // ACCESSORS
5928 template <class VALUETYPE>
5929 inline
5930 void operator()(VALUETYPE& object) const
5931 {
5932 bslx::InStreamFunctions::bdexStreamIn(d_stream, object, d_version);
5933 }
5934
5935 inline
5936 void operator()(bslmf::Nil) const
5937 {
5938 // no op
5939 }
5940};
5941
5942 // ===================================
5943 // struct Variant_BdexStreamOutVisitor
5944 // ===================================
5945
5946/// This visitor, when invoked as a non-modifiable function object on an
5947/// initialized instance of some parameterized `TYPE`, will stream out the
5948/// value of that instance into a stream specified at construction of this
5949/// visitor, using a version also specified at construction of this
5950/// visitor.
5951///
5952/// See @ref bdlb_variant_cpp03
5953template <class STREAM>
5954struct Variant_BdexStreamOutVisitor {
5955
5956 // PUBLIC DATA
5957 STREAM& d_stream; // held, not owned
5958 int d_version; // BDEX version
5959
5960 // CREATORS
5961 Variant_BdexStreamOutVisitor(STREAM& stream, int version)
5962 : d_stream(stream)
5963 , d_version(version)
5964 {
5965 }
5966
5967 // ACCESSORS
5968 template <class VALUETYPE>
5969 inline
5970 void operator()(const VALUETYPE& object) const
5971 {
5972 bslx::OutStreamFunctions::bdexStreamOut(d_stream, object, d_version);
5973 }
5974
5975 inline
5976 void operator()(bslmf::Nil) const
5977 {
5978 // no op
5979 }
5980};
5981#endif
5982
5983 // ===========================
5984 // struct Variant_PrintVisitor
5985 // ===========================
5986
5987/// This visitor, when invoked as a non-modifiable function object on an
5988/// instance of some template parameter `TYPE`, writes the value of that
5989/// instance to a stream specified at construction of this visitor, using
5990/// spacing information also specified at construction.
5991///
5992/// See @ref bdlb_variant_cpp03
5993struct Variant_PrintVisitor {
5994
5995 // PUBLIC DATA
5996 bsl::ostream *d_stream_p; // held, not owned
5997 int d_level;
5998 int d_spacesPerLevel;
5999
6000 // CREATORS
6001 Variant_PrintVisitor(bsl::ostream *stream,
6002 int level,
6003 int spacesPerLevel)
6004 : d_stream_p(stream)
6005 , d_level(level)
6006 , d_spacesPerLevel(spacesPerLevel)
6007 {
6008 BSLS_ASSERT_SAFE(d_stream_p);
6009 }
6010
6011 // ACCESSORS
6012 template <class TYPE>
6013 void operator()(const TYPE& value) const
6014 {
6015 PrintMethods::print(*d_stream_p, value, d_level, d_spacesPerLevel);
6016 }
6017
6018 void operator()(bslmf::Nil) const
6019 {
6020 // no op
6021 }
6022};
6023
6024 // ==================================
6025 // struct Variant_EqualityTestVisitor
6026 // ==================================
6027
6028/// This visitor, when invoked as a non-modifiable function object on an
6029/// instance of some template parameter `TYPE`, tests the equality of the
6030/// value of that instance and of another instance held in a buffer
6031/// specified at construction of this visitor, and stores the result into
6032/// its publicly accessible `d_result` member.
6033///
6034/// See @ref bdlb_variant_cpp03
6035struct Variant_EqualityTestVisitor {
6036
6037 // PUBLIC DATA
6038 mutable bool d_result;
6039 const void *d_buffer_p; // held, not owned
6040
6041 // CREATORS
6042 explicit
6043 Variant_EqualityTestVisitor(const void *buffer)
6044 : d_result(true)
6045 , d_buffer_p(buffer)
6046 {
6047 BSLS_ASSERT_SAFE(d_buffer_p);
6048 }
6049
6050 // ACCESSORS
6051 template <class TYPE>
6052 void operator()(const TYPE& value) const
6053 {
6054 d_result = *reinterpret_cast<const TYPE *>(d_buffer_p) == value;
6055 }
6056
6057 void operator()(bslmf::Nil) const
6058 {
6059 d_result = true;
6060 }
6061};
6062
6063// ============================================================================
6064// INLINE DEFINITIONS
6065// ============================================================================
6066
6067 // -------------------------------------
6068 // class VariantImp_AllocatorBase<TYPES>
6069 // -------------------------------------
6070
6071// CREATORS
6072template <class TYPES>
6073inline
6075VariantImp_AllocatorBase(int type, bslma::Allocator *basicAllocator)
6076: d_type(type)
6077, d_allocator_p(bslma::Default::allocator(basicAllocator))
6078{
6079}
6080
6081template <class TYPES>
6082inline
6083VariantImp_AllocatorBase<TYPES>::
6084VariantImp_AllocatorBase(int, bslma::Allocator *basicAllocator, bsl::true_type)
6085: d_type(0)
6086, d_allocator_p(bslma::Default::allocator(basicAllocator))
6087{
6088}
6089
6090template <class TYPES>
6091template <class TYPE>
6092inline
6093VariantImp_AllocatorBase<TYPES>::
6094VariantImp_AllocatorBase(int type, const TYPE&, bsl::false_type)
6095: d_type(type)
6096, d_allocator_p(bslma::Default::allocator(0))
6097{
6098}
6099
6100// ACCESSORS
6101template <class TYPES>
6102inline
6104VariantImp_AllocatorBase<TYPES>::getAllocator() const
6105{
6106 return d_allocator_p;
6107}
6108
6109 // ---------------------------------------
6110 // class VariantImp_NoAllocatorBase<TYPES>
6111 // ---------------------------------------
6112
6113// CREATORS
6114template <class TYPES>
6115inline
6116VariantImp_NoAllocatorBase<TYPES>::
6117VariantImp_NoAllocatorBase(int type, bslma::Allocator *)
6118: d_type(type)
6119{
6120}
6121
6122template <class TYPES>
6123inline
6124VariantImp_NoAllocatorBase<TYPES>::
6125VariantImp_NoAllocatorBase(int, bslma::Allocator *, bsl::true_type)
6126: d_type(0)
6127{
6128}
6129
6130template <class TYPES>
6131template <class TYPE>
6132inline
6133VariantImp_NoAllocatorBase<TYPES>::
6134VariantImp_NoAllocatorBase(int type, const TYPE&, bsl::false_type)
6135: d_type(type)
6136{
6137}
6138
6139// ACCESSORS
6140template <class TYPES>
6141inline
6143VariantImp_NoAllocatorBase<TYPES>::getAllocator() const
6144{
6145 return 0;
6146}
6147
6148 // ------------------------------
6149 // class Variant_RawVisitorHelper
6150 // ------------------------------
6151
6152// CREATORS
6153template <class RESULT_TYPE, class VISITOR>
6154inline
6155Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::
6156Variant_RawVisitorHelper(VISITOR *visitor)
6157: d_visitor(visitor)
6158{
6159 BSLS_ASSERT_SAFE(0 != visitor);
6160}
6161
6162// MANIPULATORS
6163template <class RESULT_TYPE, class VISITOR>
6164template <class ARGUMENT_TYPE>
6165inline
6166RESULT_TYPE
6167Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::operator()(
6168 ARGUMENT_TYPE& argument)
6169{
6170 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6171}
6172
6173template <class RESULT_TYPE, class VISITOR>
6174template <class ARGUMENT_TYPE>
6175inline
6176RESULT_TYPE
6177Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::operator()(
6178 const ARGUMENT_TYPE& argument)
6179{
6180 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6181}
6182
6183// ACCESSORS
6184template <class RESULT_TYPE, class VISITOR>
6185template <class ARGUMENT_TYPE>
6186inline
6187RESULT_TYPE
6188Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::operator()(
6189 ARGUMENT_TYPE& argument) const
6190{
6191 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6192}
6193
6194template <class RESULT_TYPE, class VISITOR>
6195template <class ARGUMENT_TYPE>
6196inline
6197RESULT_TYPE
6198Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::operator()(
6199 const ARGUMENT_TYPE& argument) const
6200{
6201 return static_cast<RESULT_TYPE>((*d_visitor)(argument));
6202}
6203
6204template <class RESULT_TYPE, class VISITOR>
6205RESULT_TYPE
6206Variant_RawVisitorHelper<RESULT_TYPE, VISITOR>::operator()(bslmf::Nil) const
6207{
6208 BSLS_ASSERT_INVOKE_NORETURN("unreachable");
6209}
6210
6211 // -----------------------
6212 // class VariantImp<TYPES>
6213 // -----------------------
6214
6215// PRIVATE MANIPULATORS
6216template <class TYPES>
6217template <class TYPE, class VISITOR_REF>
6218inline
6219void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::false_type)
6220{
6221 typedef bsls::ObjectBuffer<TYPE> BufferType;
6222
6223 visitor(reinterpret_cast<BufferType *>(&this->d_value)->object());
6224}
6225
6226template <class TYPES>
6227template <class TYPE, class VISITOR_REF>
6228inline
6229void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::true_type)
6230{
6231 bslmf::Nil nil = bslmf::Nil();
6232 visitor(nil);
6233}
6234
6235template <class TYPES>
6236template <class TYPE, class VISITOR_REF>
6237inline
6238void VariantImp<TYPES>::applyImp(VISITOR_REF visitor)
6239{
6240 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6241 applyImp<TYPE, VISITOR_REF>(visitor, IsUnset());
6242}
6243
6244template <class TYPES>
6245template <class TYPE, class VISITOR_REF, class RET_TYPE>
6246inline
6247RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor, bsl::false_type)
6248{
6249 typedef bsls::ObjectBuffer<TYPE> BufferType;
6250
6251 return visitor(reinterpret_cast<BufferType *>(&this->d_value)->object());
6252}
6253
6254template <class TYPES>
6255template <class TYPE, class VISITOR_REF, class RET_TYPE>
6256inline
6257RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor, bsl::true_type)
6258{
6259 bslmf::Nil nil = bslmf::Nil();
6260 return visitor(nil);
6261}
6262
6263template <class TYPES>
6264template <class TYPE, class VISITOR_REF, class RET_TYPE>
6265inline
6266RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor)
6267{
6268 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6269 return applyImpR<TYPE, VISITOR_REF, RET_TYPE>(visitor, IsUnset());
6270}
6271
6272template <class TYPES>
6273template <class TYPE, class SOURCE_TYPE>
6274void VariantImp<TYPES>::assignImp(const SOURCE_TYPE& value)
6275{
6276 typedef bsls::ObjectBuffer<TYPE> BufferType;
6277
6278 reset();
6280 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6281 this->getAllocator(),
6282 value);
6283 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
6284}
6285
6286template <class TYPES>
6287template <class TYPE>
6288#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6289void VariantImp<TYPES>::assignImp(TYPE&& value)
6290#else
6291void VariantImp<TYPES>::assignImp(bslmf::MovableRef<TYPE> value)
6292#endif
6293{
6295 BufferType;
6296
6297 reset();
6298
6299#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6301 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6302 this->getAllocator(),
6303 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
6304#else
6305 TYPE& lvalue = value;
6307 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6308 this->getAllocator(),
6310#endif
6311
6312 this->d_type =
6313 Variant_TypeIndex<TYPES,
6314 typename bsl::remove_reference<TYPE>::type>::value;
6315}
6316
6317template <class TYPES>
6318template <class VISITOR_REF>
6319void VariantImp<TYPES>::doApply(VISITOR_REF visitor, int type)
6320{
6321 switch (type) {
6322 case 0: {
6323 BSLS_ASSERT(0 == "'doApply' invoked on an unset variant");
6324 } break;
6325 case 1: {
6326 applyImp<typename Base::Type1, VISITOR_REF>(visitor);
6327 } break;
6328 case 2: {
6329 applyImp<typename Base::Type2, VISITOR_REF>(visitor);
6330 } break;
6331 case 3: {
6332 applyImp<typename Base::Type3, VISITOR_REF>(visitor);
6333 } break;
6334 case 4: {
6335 applyImp<typename Base::Type4, VISITOR_REF>(visitor);
6336 } break;
6337 case 5: {
6338 applyImp<typename Base::Type5, VISITOR_REF>(visitor);
6339 } break;
6340 case 6: {
6341 applyImp<typename Base::Type6, VISITOR_REF>(visitor);
6342 } break;
6343 case 7: {
6344 applyImp<typename Base::Type7, VISITOR_REF>(visitor);
6345 } break;
6346 case 8: {
6347 applyImp<typename Base::Type8, VISITOR_REF>(visitor);
6348 } break;
6349 case 9: {
6350 applyImp<typename Base::Type9, VISITOR_REF>(visitor);
6351 } break;
6352 case 10: {
6353 applyImp<typename Base::Type10, VISITOR_REF>(visitor);
6354 } break;
6355 case 11: {
6356 applyImp<typename Base::Type11, VISITOR_REF>(visitor);
6357 } break;
6358 case 12: {
6359 applyImp<typename Base::Type12, VISITOR_REF>(visitor);
6360 } break;
6361 case 13: {
6362 applyImp<typename Base::Type13, VISITOR_REF>(visitor);
6363 } break;
6364 case 14: {
6365 applyImp<typename Base::Type14, VISITOR_REF>(visitor);
6366 } break;
6367 case 15: {
6368 applyImp<typename Base::Type15, VISITOR_REF>(visitor);
6369 } break;
6370 case 16: {
6371 applyImp<typename Base::Type16, VISITOR_REF>(visitor);
6372 } break;
6373 case 17: {
6374 applyImp<typename Base::Type17, VISITOR_REF>(visitor);
6375 } break;
6376 case 18: {
6377 applyImp<typename Base::Type18, VISITOR_REF>(visitor);
6378 } break;
6379 case 19: {
6380 applyImp<typename Base::Type19, VISITOR_REF>(visitor);
6381 } break;
6382 case 20: {
6383 applyImp<typename Base::Type20, VISITOR_REF>(visitor);
6384 } break;
6385 default: {
6386 BSLS_ASSERT_UNREACHABLE("Variant type index exceeds maximum");
6387 } break;
6388 }
6389}
6390
6391template <class TYPES>
6392template <class TYPE>
6393inline
6394void VariantImp<TYPES>::create(const TYPE& value, bsl::false_type)
6395{
6396 typedef bsls::ObjectBuffer<TYPE> BufferType;
6397
6399 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6400 this->getAllocator(),
6401 value);
6402}
6403
6404template <class TYPES>
6405inline
6406void VariantImp<TYPES>::create(bslma::Allocator *, bsl::true_type)
6407{
6408}
6409
6410template <class TYPES>
6411template <class VISITOR_REF, class RET_TYPE>
6412RET_TYPE VariantImp<TYPES>::doApplyR(VISITOR_REF visitor, int type)
6413{
6414 switch (type) {
6415 case 0: {
6416 BSLS_ASSERT_INVOKE_NORETURN("'doApplyR' invoked on an unset variant");
6417 } break;
6418 case 1: {
6419 return applyImpR<typename Base::Type1,
6420 VISITOR_REF,
6421 RET_TYPE>(visitor); // RETURN
6422 } break;
6423 case 2: {
6424 return applyImpR<typename Base::Type2,
6425 VISITOR_REF,
6426 RET_TYPE>(visitor); // RETURN
6427 } break;
6428 case 3: {
6429 return applyImpR<typename Base::Type3,
6430 VISITOR_REF,
6431 RET_TYPE>(visitor); // RETURN
6432 } break;
6433 case 4: {
6434 return applyImpR<typename Base::Type4,
6435 VISITOR_REF,
6436 RET_TYPE>(visitor); // RETURN
6437 } break;
6438 case 5: {
6439 return applyImpR<typename Base::Type5,
6440 VISITOR_REF,
6441 RET_TYPE>(visitor); // RETURN
6442 } break;
6443 case 6: {
6444 return applyImpR<typename Base::Type6,
6445 VISITOR_REF,
6446 RET_TYPE>(visitor); // RETURN
6447 } break;
6448 case 7: {
6449 return applyImpR<typename Base::Type7,
6450 VISITOR_REF,
6451 RET_TYPE>(visitor); // RETURN
6452 } break;
6453 case 8: {
6454 return applyImpR<typename Base::Type8,
6455 VISITOR_REF,
6456 RET_TYPE>(visitor); // RETURN
6457 } break;
6458 case 9: {
6459 return applyImpR<typename Base::Type9,
6460 VISITOR_REF,
6461 RET_TYPE>(visitor); // RETURN
6462 } break;
6463 case 10: {
6464 return applyImpR<typename Base::Type10,
6465 VISITOR_REF,
6466 RET_TYPE>(visitor); // RETURN
6467 } break;
6468 case 11: {
6469 return applyImpR<typename Base::Type11,
6470 VISITOR_REF,
6471 RET_TYPE>(visitor); // RETURN
6472 } break;
6473 case 12: {
6474 return applyImpR<typename Base::Type12,
6475 VISITOR_REF,
6476 RET_TYPE>(visitor); // RETURN
6477 } break;
6478 case 13: {
6479 return applyImpR<typename Base::Type13,
6480 VISITOR_REF,
6481 RET_TYPE>(visitor); // RETURN
6482 } break;
6483 case 14: {
6484 return applyImpR<typename Base::Type14,
6485 VISITOR_REF,
6486 RET_TYPE>(visitor); // RETURN
6487 } break;
6488 case 15: {
6489 return applyImpR<typename Base::Type15,
6490 VISITOR_REF,
6491 RET_TYPE>(visitor); // RETURN
6492 } break;
6493 case 16: {
6494 return applyImpR<typename Base::Type16,
6495 VISITOR_REF,
6496 RET_TYPE>(visitor); // RETURN
6497 } break;
6498 case 17: {
6499 return applyImpR<typename Base::Type17,
6500 VISITOR_REF,
6501 RET_TYPE>(visitor); // RETURN
6502 } break;
6503 case 18: {
6504 return applyImpR<typename Base::Type18,
6505 VISITOR_REF,
6506 RET_TYPE>(visitor); // RETURN
6507 } break;
6508 case 19: {
6509 return applyImpR<typename Base::Type19,
6510 VISITOR_REF,
6511 RET_TYPE>(visitor); // RETURN
6512 } break;
6513 case 20: {
6514 return applyImpR<typename Base::Type20,
6515 VISITOR_REF,
6516 RET_TYPE>(visitor); // RETURN
6517 } break;
6518 default: {
6519 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
6520 } break;
6521 }
6522}
6523
6524// PRIVATE ACCESSORS
6525template <class TYPES>
6526template <class TYPE, class VISITOR_REF>
6527inline
6528void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::false_type) const
6529{
6530 typedef bsls::ObjectBuffer<TYPE> BufferType;
6531
6532 visitor(reinterpret_cast<const BufferType *>(&this->d_value)->object());
6533}
6534
6535template <class TYPES>
6536template <class TYPE, class VISITOR_REF>
6537inline
6538void VariantImp<TYPES>::applyImp(VISITOR_REF visitor, bsl::true_type) const
6539{
6540 bslmf::Nil nil = bslmf::Nil();
6541 visitor(nil);
6542}
6543
6544template <class TYPES>
6545template <class TYPE, class VISITOR_REF>
6546inline
6547void VariantImp<TYPES>::applyImp(VISITOR_REF visitor) const
6548{
6549 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6550 applyImp<TYPE, VISITOR_REF>(visitor, IsUnset());
6551}
6552
6553template <class TYPES>
6554template <class TYPE, class VISITOR_REF, class RET_TYPE>
6555inline
6556RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor,
6557 bsl::false_type) const
6558{
6559 typedef bsls::ObjectBuffer<TYPE> BufferType;
6560
6561 return visitor(reinterpret_cast<const BufferType *>(
6562 &this->d_value)->object());
6563}
6564
6565template <class TYPES>
6566template <class TYPE, class VISITOR_REF, class RET_TYPE>
6567inline
6568RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor,
6569 bsl::true_type) const
6570{
6571 bslmf::Nil nil = bslmf::Nil();
6572 return visitor(nil);
6573}
6574
6575template <class TYPES>
6576template <class TYPE, class VISITOR_REF, class RET_TYPE>
6577inline
6578RET_TYPE VariantImp<TYPES>::applyImpR(VISITOR_REF visitor) const
6579{
6580 typedef typename bsl::is_same<TYPE, bslmf::Nil>::type IsUnset;
6581 return applyImpR<TYPE, VISITOR_REF, RET_TYPE>(visitor, IsUnset());
6582}
6583
6584template <class TYPES>
6585template <class VISITOR_REF>
6586void VariantImp<TYPES>::doApply(VISITOR_REF visitor, int type) const
6587{
6588 switch (type) {
6589 case 0: {
6590 BSLS_ASSERT_INVOKE_NORETURN("'doApply' invoked on an unset variant");
6591 } break;
6592 case 1: {
6593 applyImp<typename Base::Type1, VISITOR_REF>(visitor);
6594 } break;
6595 case 2: {
6596 applyImp<typename Base::Type2, VISITOR_REF>(visitor);
6597 } break;
6598 case 3: {
6599 applyImp<typename Base::Type3, VISITOR_REF>(visitor);
6600 } break;
6601 case 4: {
6602 applyImp<typename Base::Type4, VISITOR_REF>(visitor);
6603 } break;
6604 case 5: {
6605 applyImp<typename Base::Type5, VISITOR_REF>(visitor);
6606 } break;
6607 case 6: {
6608 applyImp<typename Base::Type6, VISITOR_REF>(visitor);
6609 } break;
6610 case 7: {
6611 applyImp<typename Base::Type7, VISITOR_REF>(visitor);
6612 } break;
6613 case 8: {
6614 applyImp<typename Base::Type8, VISITOR_REF>(visitor);
6615 } break;
6616 case 9: {
6617 applyImp<typename Base::Type9, VISITOR_REF>(visitor);
6618 } break;
6619 case 10: {
6620 applyImp<typename Base::Type10, VISITOR_REF>(visitor);
6621 } break;
6622 case 11: {
6623 applyImp<typename Base::Type11, VISITOR_REF>(visitor);
6624 } break;
6625 case 12: {
6626 applyImp<typename Base::Type12, VISITOR_REF>(visitor);
6627 } break;
6628 case 13: {
6629 applyImp<typename Base::Type13, VISITOR_REF>(visitor);
6630 } break;
6631 case 14: {
6632 applyImp<typename Base::Type14, VISITOR_REF>(visitor);
6633 } break;
6634 case 15: {
6635 applyImp<typename Base::Type15, VISITOR_REF>(visitor);
6636 } break;
6637 case 16: {
6638 applyImp<typename Base::Type16, VISITOR_REF>(visitor);
6639 } break;
6640 case 17: {
6641 applyImp<typename Base::Type17, VISITOR_REF>(visitor);
6642 } break;
6643 case 18: {
6644 applyImp<typename Base::Type18, VISITOR_REF>(visitor);
6645 } break;
6646 case 19: {
6647 applyImp<typename Base::Type19, VISITOR_REF>(visitor);
6648 } break;
6649 case 20: {
6650 applyImp<typename Base::Type20, VISITOR_REF>(visitor);
6651 } break;
6652 default: {
6653 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
6654 } break;
6655 }
6656}
6657
6658template <class TYPES>
6659template <class VISITOR_REF, class RET_TYPE>
6660RET_TYPE VariantImp<TYPES>::doApplyR(VISITOR_REF visitor, int type) const
6661{
6662 switch (type) {
6663 case 0: {
6664 BSLS_ASSERT_INVOKE_NORETURN("'doApplyR' invoked on an unset variant");
6665 } break;
6666 case 1: {
6667 return applyImpR<typename Base::Type1,
6668 VISITOR_REF,
6669 RET_TYPE>(visitor); // RETURN
6670 } break;
6671 case 2: {
6672 return applyImpR<typename Base::Type2,
6673 VISITOR_REF,
6674 RET_TYPE>(visitor); // RETURN
6675 } break;
6676 case 3: {
6677 return applyImpR<typename Base::Type3,
6678 VISITOR_REF,
6679 RET_TYPE>(visitor); // RETURN
6680 } break;
6681 case 4: {
6682 return applyImpR<typename Base::Type4,
6683 VISITOR_REF,
6684 RET_TYPE>(visitor); // RETURN
6685 } break;
6686 case 5: {
6687 return applyImpR<typename Base::Type5,
6688 VISITOR_REF,
6689 RET_TYPE>(visitor); // RETURN
6690 } break;
6691 case 6: {
6692 return applyImpR<typename Base::Type6,
6693 VISITOR_REF,
6694 RET_TYPE>(visitor); // RETURN
6695 } break;
6696 case 7: {
6697 return applyImpR<typename Base::Type7,
6698 VISITOR_REF,
6699 RET_TYPE>(visitor); // RETURN
6700 } break;
6701 case 8: {
6702 return applyImpR<typename Base::Type8,
6703 VISITOR_REF,
6704 RET_TYPE>(visitor); // RETURN
6705 } break;
6706 case 9: {
6707 return applyImpR<typename Base::Type9,
6708 VISITOR_REF,
6709 RET_TYPE>(visitor); // RETURN
6710 } break;
6711 case 10: {
6712 return applyImpR<typename Base::Type10,
6713 VISITOR_REF,
6714 RET_TYPE>(visitor); // RETURN
6715 } break;
6716 case 11: {
6717 return applyImpR<typename Base::Type11,
6718 VISITOR_REF,
6719 RET_TYPE>(visitor); // RETURN
6720 } break;
6721 case 12: {
6722 return applyImpR<typename Base::Type12,
6723 VISITOR_REF,
6724 RET_TYPE>(visitor); // RETURN
6725 } break;
6726 case 13: {
6727 return applyImpR<typename Base::Type13,
6728 VISITOR_REF,
6729 RET_TYPE>(visitor); // RETURN
6730 } break;
6731 case 14: {
6732 return applyImpR<typename Base::Type14,
6733 VISITOR_REF,
6734 RET_TYPE>(visitor); // RETURN
6735 } break;
6736 case 15: {
6737 return applyImpR<typename Base::Type15,
6738 VISITOR_REF,
6739 RET_TYPE>(visitor); // RETURN
6740 } break;
6741 case 16: {
6742 return applyImpR<typename Base::Type16,
6743 VISITOR_REF,
6744 RET_TYPE>(visitor); // RETURN
6745 } break;
6746 case 17: {
6747 return applyImpR<typename Base::Type17,
6748 VISITOR_REF,
6749 RET_TYPE>(visitor); // RETURN
6750 } break;
6751 case 18: {
6752 return applyImpR<typename Base::Type18,
6753 VISITOR_REF,
6754 RET_TYPE>(visitor); // RETURN
6755 } break;
6756 case 19: {
6757 return applyImpR<typename Base::Type19,
6758 VISITOR_REF,
6759 RET_TYPE>(visitor); // RETURN
6760 } break;
6761 case 20: {
6762 return applyImpR<typename Base::Type20,
6763 VISITOR_REF,
6764 RET_TYPE>(visitor); // RETURN
6765 } break;
6766 default: {
6767 BSLS_ASSERT_INVOKE_NORETURN("Unreachable by design!");
6768 } break;
6769 }
6770}
6771
6772// CREATORS
6773template <class TYPES>
6774inline
6775VariantImp<TYPES>::VariantImp()
6776: Base(0, 0)
6777{
6778}
6779
6780template <class TYPES>
6781template <class TYPE_OR_ALLOCATOR>
6782inline
6783VariantImp<TYPES>::VariantImp(const TYPE_OR_ALLOCATOR& valueOrAllocator)
6784: Base(Variant_TypeIndex<TYPES, TYPE_OR_ALLOCATOR>::value,
6785 valueOrAllocator,
6786 bsl::integral_constant<bool, bsl::is_convertible<TYPE_OR_ALLOCATOR,
6787 bslma::Allocator *>::value>())
6788{
6789 enum {
6790 k_IS_ALLOCATOR = bsl::is_convertible<TYPE_OR_ALLOCATOR,
6791 bslma::Allocator *>::value
6792 };
6793
6794 create(valueOrAllocator, bsl::integral_constant<bool, k_IS_ALLOCATOR>());
6795}
6796
6797template <class TYPES>
6798template <class TYPE>
6799inline
6800VariantImp<TYPES>::VariantImp(const TYPE& value,
6801 bslma::Allocator *basicAllocator)
6802: Base(Variant_TypeIndex<TYPES, TYPE>::value, basicAllocator)
6803{
6804 typedef bsls::ObjectBuffer<TYPE> BufferType;
6805
6807 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6808 this->getAllocator(),
6809 value);
6810}
6811
6812template <class TYPES>
6813template <class TYPE>
6814VariantImp<TYPES>::
6815#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6816VariantImp(TYPE&& value,
6817 typename bsl::enable_if<
6818 !bsl::is_same<
6819 SelfType,
6820 typename bsl::remove_const<
6821 typename bsl::remove_reference<TYPE>::type>::type>::value
6822 &&
6824 void>::type *)
6825#else
6826VariantImp(bslmf::MovableRef<TYPE> value)
6827#endif
6828: Base(Variant_TypeIndex<
6829 TYPES,
6830 typename bsl::remove_const<
6831 typename bsl::remove_reference<TYPE>::type>::type>::value,
6832 0)
6833{
6834 typedef bsls::ObjectBuffer<
6835 typename bsl::remove_const<
6836 typename bsl::remove_reference<TYPE>::type>::type> BufferType;
6837
6838#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6840 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6841 this->getAllocator(),
6842 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
6843#else
6844 TYPE& lvalue = value;
6846 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6847 this->getAllocator(),
6849#endif
6850}
6851
6852template <class TYPES>
6853template <class TYPE>
6854VariantImp<TYPES>::
6855#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6856VariantImp(TYPE&& value,
6857 typename bsl::enable_if<
6858 !bsl::is_same<
6859 SelfType,
6860 typename bsl::remove_const<
6861 typename bsl::remove_reference<TYPE>::type>::type>::value,
6862 bslma::Allocator>::type *basicAllocator)
6863#else
6864VariantImp(bslmf::MovableRef<TYPE> value,
6865 bslma::Allocator *basicAllocator)
6866#endif
6867: Base(Variant_TypeIndex<
6868 TYPES,
6869 typename bsl::remove_const<
6870 typename bsl::remove_reference<TYPE>::type>::type>::value,
6871 basicAllocator)
6872{
6873 typedef bsls::ObjectBuffer<
6874 typename bsl::remove_const<
6875 typename bsl::remove_reference<TYPE>::type>::type> BufferType;
6876
6877#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6879 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6880 this->getAllocator(),
6881 BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
6882#else
6883 TYPE& lvalue = value;
6885 reinterpret_cast<BufferType *>(&this->d_value)->address(),
6886 this->getAllocator(),
6888#endif
6889}
6890
6891template <class TYPES>
6892VariantImp<TYPES>::VariantImp(const VariantImp& original,
6893 bslma::Allocator *basicAllocator)
6894: Base(original.d_type, basicAllocator)
6895{
6896 if (this->d_type) {
6897 Variant_CopyConstructVisitor copyConstructor(&this->d_value,
6898 this->getAllocator());
6899 original.apply(copyConstructor);
6900 }
6901}
6902
6903template <class TYPES>
6904VariantImp<TYPES>::VariantImp(bslmf::MovableRef<VariantImp> original)
6905: Base(MoveUtil::access(original).d_type,
6906 MoveUtil::access(original).getAllocator())
6907{
6908 if (this->d_type) {
6909 Variant_MoveConstructVisitor moveConstructor(&this->d_value,
6910 this->getAllocator());
6911 VariantImp& lvalue = original;
6912
6913 lvalue.apply(moveConstructor);
6914 }
6915}
6916
6917template <class TYPES>
6918VariantImp<TYPES>::VariantImp(bslmf::MovableRef<VariantImp> original,
6919 bslma::Allocator *basicAllocator)
6920: Base(MoveUtil::access(original).d_type, basicAllocator)
6921{
6922 if (this->d_type) {
6923 Variant_MoveConstructVisitor moveConstructor(&this->d_value,
6924 this->getAllocator());
6925 VariantImp& lvalue = original;
6926
6927 lvalue.apply(moveConstructor);
6928 }
6929}
6930
6931template <class TYPES>
6932inline
6933VariantImp<TYPES>::~VariantImp()
6934{
6935 reset();
6936}
6937
6938// MANIPULATORS
6939template <class TYPES>
6940template <class TYPE>
6941inline
6942VariantImp<TYPES>&
6943VariantImp<TYPES>::operator=(const TYPE& value)
6944{
6945 return assign(value);
6946}
6947
6948template <class TYPES>
6949template <class TYPE>
6950inline
6951#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6952typename bsl::enable_if<
6954 typename bsl::remove_cvref<TYPE>::type>::value,
6955VariantImp<TYPES> >::type&
6956VariantImp<TYPES>::operator=(TYPE&& value)
6957#else
6958VariantImp<TYPES>&
6959VariantImp<TYPES>::operator=(bslmf::MovableRef<TYPE> value)
6960#endif
6961{
6962#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6963 return assign(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
6964#else
6965 TYPE& lvalue = value;
6966 return assign(MoveUtil::move(lvalue));
6967#endif
6968}
6969
6970template <class TYPES>
6971VariantImp<TYPES>&
6972VariantImp<TYPES>::operator=(const VariantImp& rhs)
6973{
6974 if (&rhs != this) {
6975 if (this->d_type == rhs.d_type) {
6976 if (this->d_type) {
6977 Variant_CopyAssignVisitor assigner(&this->d_value);
6978 rhs.apply(assigner);
6979 }
6980 }
6981 else {
6982 reset();
6983 if (rhs.d_type) {
6984 Variant_CopyConstructVisitor copyConstructor(
6985 &this->d_value,
6986 this->getAllocator());
6987 rhs.apply(copyConstructor);
6988 this->d_type = rhs.d_type;
6989 }
6990 }
6991 }
6992
6993 return *this;
6994}
6995
6996template <class TYPES>
6997VariantImp<TYPES>&
6998VariantImp<TYPES>::operator=(bslmf::MovableRef<VariantImp> rhs)
6999{
7000 VariantImp& lvalue = rhs;
7001
7002 if (&lvalue != this) {
7003 if (this->d_type == lvalue.d_type) {
7004 if (this->d_type) {
7005 Variant_MoveAssignVisitor assigner(&this->d_value);
7006 lvalue.apply(assigner);
7007 }
7008 }
7009 else {
7010 reset();
7011 if (lvalue.d_type) {
7012 Variant_MoveConstructVisitor moveConstructor(
7013 &this->d_value,
7014 this->getAllocator());
7015 lvalue.apply(moveConstructor);
7016 this->d_type = lvalue.d_type;
7017 }
7018 }
7019 }
7020
7021 return *this;
7022}
7023
7024template <class TYPES>
7025template <class RET_TYPE, class VISITOR>
7026inline
7027RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor)
7028{
7029 if (this->d_type) {
7030 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7031 }
7032
7033 bslmf::Nil nil = bslmf::Nil();
7034 return visitor(nil);
7035}
7036
7037template <class TYPES>
7038template <class RET_TYPE, class VISITOR>
7039inline
7040RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor)
7041{
7042 if (this->d_type) {
7043 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7044 // RETURN
7045 }
7046
7047 bslmf::Nil nil = bslmf::Nil();
7048 return visitor(nil);
7049}
7050
7051template <class TYPES>
7052template <class RET_TYPE, class VISITOR, class TYPE>
7053inline
7054RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor, const TYPE& defaultValue)
7055{
7056 if (this->d_type) {
7057 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7058 }
7059
7060 return visitor(defaultValue);
7061}
7062
7063template <class TYPES>
7064template <class RET_TYPE, class VISITOR, class TYPE>
7065inline
7066RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor,
7067 const TYPE& defaultValue)
7068{
7069 if (this->d_type) {
7070 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7071 // RETURN
7072 }
7073
7074 return visitor(defaultValue);
7075}
7076
7077template <class TYPES>
7078template <class RET_TYPE, class VISITOR>
7079inline
7080RET_TYPE VariantImp<TYPES>::applyRaw(VISITOR& visitor)
7081{
7082 typedef Variant_RawVisitorHelper<RET_TYPE, VISITOR> Helper;
7083
7084 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7085}
7086
7087template <class TYPES>
7088template <class RET_TYPE, class VISITOR>
7089inline
7090RET_TYPE VariantImp<TYPES>::applyRaw(const VISITOR& visitor)
7091{
7092 typedef Variant_RawVisitorHelper<RET_TYPE, const VISITOR> Helper;
7093
7094 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7095}
7096
7097template <class TYPES>
7098template <class TYPE>
7099VariantImp<TYPES>& VariantImp<TYPES>::assign(const TYPE& value)
7100{
7101 typedef bsls::ObjectBuffer<TYPE> BufferType;
7102
7103 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type) {
7104 reinterpret_cast<BufferType *>(&this->d_value)->object() = value;
7105 }
7106 else {
7107 assignImp<TYPE, TYPE>(value);
7108 }
7109
7110 return *this;
7111}
7112
7113template <class TYPES>
7114template <class TYPE>
7115#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7116VariantImp<TYPES>& VariantImp<TYPES>::assign(TYPE&& value)
7117#else
7118VariantImp<TYPES>& VariantImp<TYPES>::assign(bslmf::MovableRef<TYPE> value)
7119#endif
7120{
7122 BufferType;
7123
7124#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
7125 if (Variant_TypeIndex<TYPES,
7126 typename bsl::remove_reference<TYPE>::type>::value
7127 == this->d_type) {
7128 reinterpret_cast<BufferType *>(&this->d_value)->object() =
7129 BSLS_COMPILERFEATURES_FORWARD(TYPE, value);
7130 }
7131 else {
7132 assignImp<TYPE>(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
7133 }
7134#else
7135 TYPE& lvalue = value;
7136
7137 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type) {
7138 reinterpret_cast<BufferType *>(&this->d_value)->object() =
7139 MoveUtil::move(lvalue);
7140 }
7141 else {
7142 assignImp<TYPE>(MoveUtil::move(lvalue));
7143 }
7144#endif
7145
7146 return *this;
7147}
7148
7149template <class TYPES>
7150template <class TYPE, class SOURCE_TYPE>
7151VariantImp<TYPES>& VariantImp<TYPES>::assignTo(const SOURCE_TYPE& value)
7152{
7153 typedef bsls::ObjectBuffer<TYPE> BufferType;
7154
7155 if (Variant_TypeIndex<TYPES, TYPE>::value == this->d_type
7157 reinterpret_cast<BufferType *>(&this->d_value)->object() = value;
7158 }
7159 else {
7160 assignImp<TYPE, SOURCE_TYPE>(value);
7161 }
7162
7163 return *this;
7164}
7165
7166#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
7167// {{{ BEGIN GENERATED CODE
7168// Command line: sim_cpp11_features.pl bdlb_variant.h
7169#ifndef BDLB_VARIANT_VARIADIC_LIMIT
7170#define BDLB_VARIANT_VARIADIC_LIMIT 14
7171#endif
7172#ifndef BDLB_VARIANT_VARIADIC_LIMIT_B
7173#define BDLB_VARIANT_VARIADIC_LIMIT_B BDLB_VARIANT_VARIADIC_LIMIT
7174#endif
7175
7176#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 0
7177template <class TYPES>
7178template <class TYPE>
7179inline
7180TYPE& VariantImp<TYPES>::createInPlace(
7181 )
7182{
7183 typedef bsls::ObjectBuffer<TYPE> BufferType;
7184 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7185
7186 reset();
7188 bufR.address(),
7189 this->getAllocator());
7190 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7191
7192 return bufR.object();
7193}
7194#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 0
7195
7196#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 1
7197template <class TYPES>
7198template <class TYPE, class ARGS_01>
7199inline
7200TYPE& VariantImp<TYPES>::createInPlace(
7201 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01)
7202{
7203 typedef bsls::ObjectBuffer<TYPE> BufferType;
7204 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7205
7206 reset();
7208 bufR.address(),
7209 this->getAllocator(),
7210 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01));
7211 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7212
7213 return bufR.object();
7214}
7215#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 1
7216
7217#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 2
7218template <class TYPES>
7219template <class TYPE, class ARGS_01,
7220 class ARGS_02>
7221inline
7222TYPE& VariantImp<TYPES>::createInPlace(
7223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02)
7225{
7226 typedef bsls::ObjectBuffer<TYPE> BufferType;
7227 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7228
7229 reset();
7231 bufR.address(),
7232 this->getAllocator(),
7233 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7234 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02));
7235 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7236
7237 return bufR.object();
7238}
7239#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 2
7240
7241#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 3
7242template <class TYPES>
7243template <class TYPE, class ARGS_01,
7244 class ARGS_02,
7245 class ARGS_03>
7246inline
7247TYPE& VariantImp<TYPES>::createInPlace(
7248 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7249 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7250 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03)
7251{
7252 typedef bsls::ObjectBuffer<TYPE> BufferType;
7253 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7254
7255 reset();
7257 bufR.address(),
7258 this->getAllocator(),
7259 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7260 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7261 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03));
7262 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7263
7264 return bufR.object();
7265}
7266#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 3
7267
7268#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 4
7269template <class TYPES>
7270template <class TYPE, class ARGS_01,
7271 class ARGS_02,
7272 class ARGS_03,
7273 class ARGS_04>
7274inline
7275TYPE& VariantImp<TYPES>::createInPlace(
7276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04)
7280{
7281 typedef bsls::ObjectBuffer<TYPE> BufferType;
7282 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7283
7284 reset();
7286 bufR.address(),
7287 this->getAllocator(),
7288 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7289 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7290 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7291 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04));
7292 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7293
7294 return bufR.object();
7295}
7296#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 4
7297
7298#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 5
7299template <class TYPES>
7300template <class TYPE, class ARGS_01,
7301 class ARGS_02,
7302 class ARGS_03,
7303 class ARGS_04,
7304 class ARGS_05>
7305inline
7306TYPE& VariantImp<TYPES>::createInPlace(
7307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7309 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7310 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7311 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05)
7312{
7313 typedef bsls::ObjectBuffer<TYPE> BufferType;
7314 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7315
7316 reset();
7318 bufR.address(),
7319 this->getAllocator(),
7320 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7321 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7322 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7323 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7324 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05));
7325 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7326
7327 return bufR.object();
7328}
7329#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 5
7330
7331#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 6
7332template <class TYPES>
7333template <class TYPE, class ARGS_01,
7334 class ARGS_02,
7335 class ARGS_03,
7336 class ARGS_04,
7337 class ARGS_05,
7338 class ARGS_06>
7339inline
7340TYPE& VariantImp<TYPES>::createInPlace(
7341 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7342 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06)
7347{
7348 typedef bsls::ObjectBuffer<TYPE> BufferType;
7349 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7350
7351 reset();
7353 bufR.address(),
7354 this->getAllocator(),
7355 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7356 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7357 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7358 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7359 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7360 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06));
7361 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7362
7363 return bufR.object();
7364}
7365#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 6
7366
7367#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 7
7368template <class TYPES>
7369template <class TYPE, class ARGS_01,
7370 class ARGS_02,
7371 class ARGS_03,
7372 class ARGS_04,
7373 class ARGS_05,
7374 class ARGS_06,
7375 class ARGS_07>
7376inline
7377TYPE& VariantImp<TYPES>::createInPlace(
7378 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7379 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7380 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7381 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7382 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7383 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7384 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07)
7385{
7386 typedef bsls::ObjectBuffer<TYPE> BufferType;
7387 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7388
7389 reset();
7391 bufR.address(),
7392 this->getAllocator(),
7393 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7394 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7395 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7396 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7397 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7398 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7399 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07));
7400 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7401
7402 return bufR.object();
7403}
7404#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 7
7405
7406#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 8
7407template <class TYPES>
7408template <class TYPE, class ARGS_01,
7409 class ARGS_02,
7410 class ARGS_03,
7411 class ARGS_04,
7412 class ARGS_05,
7413 class ARGS_06,
7414 class ARGS_07,
7415 class ARGS_08>
7416inline
7417TYPE& VariantImp<TYPES>::createInPlace(
7418 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7419 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7420 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7421 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7422 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7423 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7424 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7425 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08)
7426{
7427 typedef bsls::ObjectBuffer<TYPE> BufferType;
7428 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7429
7430 reset();
7432 bufR.address(),
7433 this->getAllocator(),
7434 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7435 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7436 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7437 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7438 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7439 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7440 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7441 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08));
7442 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7443
7444 return bufR.object();
7445}
7446#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 8
7447
7448#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 9
7449template <class TYPES>
7450template <class TYPE, class ARGS_01,
7451 class ARGS_02,
7452 class ARGS_03,
7453 class ARGS_04,
7454 class ARGS_05,
7455 class ARGS_06,
7456 class ARGS_07,
7457 class ARGS_08,
7458 class ARGS_09>
7459inline
7460TYPE& VariantImp<TYPES>::createInPlace(
7461 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7462 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7463 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7464 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7465 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7466 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7467 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7468 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7469 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09)
7470{
7471 typedef bsls::ObjectBuffer<TYPE> BufferType;
7472 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7473
7474 reset();
7476 bufR.address(),
7477 this->getAllocator(),
7478 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7479 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7480 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7481 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7482 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7483 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7484 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7485 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7486 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09));
7487 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7488
7489 return bufR.object();
7490}
7491#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 9
7492
7493#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 10
7494template <class TYPES>
7495template <class TYPE, class ARGS_01,
7496 class ARGS_02,
7497 class ARGS_03,
7498 class ARGS_04,
7499 class ARGS_05,
7500 class ARGS_06,
7501 class ARGS_07,
7502 class ARGS_08,
7503 class ARGS_09,
7504 class ARGS_10>
7505inline
7506TYPE& VariantImp<TYPES>::createInPlace(
7507 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7508 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7509 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7510 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7511 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7512 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7513 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7514 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7515 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
7516 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10)
7517{
7518 typedef bsls::ObjectBuffer<TYPE> BufferType;
7519 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7520
7521 reset();
7523 bufR.address(),
7524 this->getAllocator(),
7525 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7526 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7527 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7528 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7529 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7530 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7531 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7532 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7533 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09),
7534 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, arguments_10));
7535 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7536
7537 return bufR.object();
7538}
7539#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 10
7540
7541#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 11
7542template <class TYPES>
7543template <class TYPE, class ARGS_01,
7544 class ARGS_02,
7545 class ARGS_03,
7546 class ARGS_04,
7547 class ARGS_05,
7548 class ARGS_06,
7549 class ARGS_07,
7550 class ARGS_08,
7551 class ARGS_09,
7552 class ARGS_10,
7553 class ARGS_11>
7554inline
7555TYPE& VariantImp<TYPES>::createInPlace(
7556 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7557 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7558 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7559 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7560 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7561 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7562 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7563 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7564 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
7565 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
7566 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11)
7567{
7568 typedef bsls::ObjectBuffer<TYPE> BufferType;
7569 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7570
7571 reset();
7573 bufR.address(),
7574 this->getAllocator(),
7575 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7576 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7577 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7578 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7579 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7580 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7581 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7582 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7583 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09),
7584 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, arguments_10),
7585 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, arguments_11));
7586 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7587
7588 return bufR.object();
7589}
7590#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 11
7591
7592#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 12
7593template <class TYPES>
7594template <class TYPE, class ARGS_01,
7595 class ARGS_02,
7596 class ARGS_03,
7597 class ARGS_04,
7598 class ARGS_05,
7599 class ARGS_06,
7600 class ARGS_07,
7601 class ARGS_08,
7602 class ARGS_09,
7603 class ARGS_10,
7604 class ARGS_11,
7605 class ARGS_12>
7606inline
7607TYPE& VariantImp<TYPES>::createInPlace(
7608 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7609 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7610 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7611 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7612 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7613 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7614 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7615 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7616 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
7617 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
7618 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
7619 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12)
7620{
7621 typedef bsls::ObjectBuffer<TYPE> BufferType;
7622 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7623
7624 reset();
7626 bufR.address(),
7627 this->getAllocator(),
7628 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7629 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7630 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7631 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7632 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7633 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7634 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7635 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7636 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09),
7637 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, arguments_10),
7638 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, arguments_11),
7639 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, arguments_12));
7640 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7641
7642 return bufR.object();
7643}
7644#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 12
7645
7646#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 13
7647template <class TYPES>
7648template <class TYPE, class ARGS_01,
7649 class ARGS_02,
7650 class ARGS_03,
7651 class ARGS_04,
7652 class ARGS_05,
7653 class ARGS_06,
7654 class ARGS_07,
7655 class ARGS_08,
7656 class ARGS_09,
7657 class ARGS_10,
7658 class ARGS_11,
7659 class ARGS_12,
7660 class ARGS_13>
7661inline
7662TYPE& VariantImp<TYPES>::createInPlace(
7663 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7664 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7665 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7666 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7667 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7668 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7669 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7670 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7671 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
7672 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
7673 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
7674 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12,
7675 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) arguments_13)
7676{
7677 typedef bsls::ObjectBuffer<TYPE> BufferType;
7678 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7679
7680 reset();
7682 bufR.address(),
7683 this->getAllocator(),
7684 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7685 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7686 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7687 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7688 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7689 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7690 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7691 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7692 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09),
7693 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, arguments_10),
7694 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, arguments_11),
7695 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, arguments_12),
7696 BSLS_COMPILERFEATURES_FORWARD(ARGS_13, arguments_13));
7697 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7698
7699 return bufR.object();
7700}
7701#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 13
7702
7703#if BDLB_VARIANT_VARIADIC_LIMIT_B >= 14
7704template <class TYPES>
7705template <class TYPE, class ARGS_01,
7706 class ARGS_02,
7707 class ARGS_03,
7708 class ARGS_04,
7709 class ARGS_05,
7710 class ARGS_06,
7711 class ARGS_07,
7712 class ARGS_08,
7713 class ARGS_09,
7714 class ARGS_10,
7715 class ARGS_11,
7716 class ARGS_12,
7717 class ARGS_13,
7718 class ARGS_14>
7719inline
7720TYPE& VariantImp<TYPES>::createInPlace(
7721 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
7722 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
7723 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
7724 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
7725 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
7726 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
7727 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
7728 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
7729 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
7730 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10,
7731 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) arguments_11,
7732 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) arguments_12,
7733 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) arguments_13,
7734 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) arguments_14)
7735{
7736 typedef bsls::ObjectBuffer<TYPE> BufferType;
7737 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7738
7739 reset();
7741 bufR.address(),
7742 this->getAllocator(),
7743 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, arguments_01),
7744 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, arguments_02),
7745 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, arguments_03),
7746 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, arguments_04),
7747 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, arguments_05),
7748 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, arguments_06),
7749 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, arguments_07),
7750 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, arguments_08),
7751 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, arguments_09),
7752 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, arguments_10),
7753 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, arguments_11),
7754 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, arguments_12),
7755 BSLS_COMPILERFEATURES_FORWARD(ARGS_13, arguments_13),
7756 BSLS_COMPILERFEATURES_FORWARD(ARGS_14, arguments_14));
7757 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7758
7759 return bufR.object();
7760}
7761#endif // BDLB_VARIANT_VARIADIC_LIMIT_B >= 14
7762
7763#else
7764// The generated code below is a workaround for the absence of perfect
7765// forwarding in some compilers.
7766
7767template <class TYPES>
7768template <class TYPE, class... ARGS>
7769inline
7770TYPE& VariantImp<TYPES>::createInPlace(
7771 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments)
7772{
7773 typedef bsls::ObjectBuffer<TYPE> BufferType;
7774 BufferType& bufR = *reinterpret_cast<BufferType *>(&this->d_value);
7775
7776 reset();
7778 bufR.address(),
7779 this->getAllocator(),
7780 BSLS_COMPILERFEATURES_FORWARD(ARGS, arguments)...);
7781 this->d_type = Variant_TypeIndex<TYPES, TYPE>::value;
7782
7783 return bufR.object();
7784}
7785
7786// }}} END GENERATED CODE
7787#endif
7788
7789template <class TYPES>
7790void VariantImp<TYPES>::reset()
7791{
7792 if (this->d_type) {
7793 Variant_DestructorVisitor destructor;
7794 apply(destructor);
7795 this->d_type = 0;
7796 }
7797}
7798
7799template <class TYPES>
7800void VariantImp<TYPES>::swap(VariantImp<TYPES>& other)
7801{
7802 if (!this->d_type) {
7803 if (!other.d_type) {
7804 return; // RETURN
7805 }
7806 *this = other;
7807 other.reset();
7808 }
7809 else if (!other.d_type) {
7810 other = *this;
7811 this->reset();
7812 }
7813 else {
7814 if (this->d_type == other.d_type
7815 && this->getAllocator() == other.getAllocator()) {
7816 // Same types and same allocators, so use a visitor that calls
7817 // 'swap'.
7818
7819 Variant_SwapVisitor swapper(&this->d_value);
7820 other.apply(swapper);
7821 }
7822 else {
7823 // Different types and/or allocators, so swap via assignment. Note
7824 // that this doesn't fit the usual pattern for calling 'swap'
7825 // because infinite recursion would result.
7826
7827 bsl::swap(*this, other);
7828 }
7829 }
7830}
7831
7832template <class TYPES>
7833template <class TYPE>
7834inline
7835TYPE& VariantImp<TYPES>::the()
7836{
7837 BSLMF_ASSERT((0 != Variant_TypeIndex<TYPES, TYPE>::value));
7838 BSLS_ASSERT_SAFE((this->d_type == Variant_TypeIndex<TYPES, TYPE>::value));
7839
7840 typedef bsls::ObjectBuffer<TYPE> BufferType;
7841
7842 return reinterpret_cast<BufferType *>(&this->d_value)->object();
7843}
7844
7845// ACCESSORS
7846template <class TYPES>
7847template <class RET_TYPE, class VISITOR>
7848inline
7849RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor) const
7850{
7851 if (this->d_type) {
7852 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7853 }
7854
7855 bslmf::Nil nil = bslmf::Nil();
7856 return visitor(nil);
7857}
7858
7859template <class TYPES>
7860template <class RET_TYPE, class VISITOR>
7861inline
7862RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor) const
7863{
7864 if (this->d_type) {
7865 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7866 // RETURN
7867 }
7868
7869 bslmf::Nil nil = bslmf::Nil();
7870 return visitor(nil);
7871}
7872
7873template <class TYPES>
7874template <class RET_TYPE, class VISITOR, class TYPE>
7875inline
7876RET_TYPE VariantImp<TYPES>::apply(VISITOR& visitor,
7877 const TYPE& defaultValue) const
7878{
7879 if (this->d_type) {
7880 return doApplyR<VISITOR&, RET_TYPE>(visitor, this->d_type); // RETURN
7881 }
7882
7883 return visitor(defaultValue);
7884}
7885
7886template <class TYPES>
7887template <class RET_TYPE, class VISITOR, class TYPE>
7888inline
7889RET_TYPE VariantImp<TYPES>::apply(const VISITOR& visitor,
7890 const TYPE& defaultValue) const
7891{
7892 if (this->d_type) {
7893 return doApplyR<const VISITOR&, RET_TYPE>(visitor, this->d_type);
7894 // RETURN
7895 }
7896
7897 return visitor(defaultValue);
7898}
7899
7900template <class TYPES>
7901template <class RET_TYPE, class VISITOR>
7902inline
7903RET_TYPE VariantImp<TYPES>::applyRaw(VISITOR& visitor) const
7904{
7905 typedef Variant_RawVisitorHelper<RET_TYPE, VISITOR> Helper;
7906
7907 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7908}
7909
7910template <class TYPES>
7911template <class RET_TYPE, class VISITOR>
7912inline
7913RET_TYPE VariantImp<TYPES>::applyRaw(const VISITOR& visitor) const
7914{
7915 typedef Variant_RawVisitorHelper<RET_TYPE, const VISITOR> Helper;
7916
7917 return doApplyR<const Helper&, RET_TYPE>(Helper(&visitor), this->d_type);
7918}
7919
7920template <class TYPES>
7921template <class TYPE>
7922inline
7923bool VariantImp<TYPES>::is() const
7924{
7925 return Variant_TypeIndex<TYPES, TYPE>::value == this->d_type;
7926}
7927
7928template <class TYPES>
7929inline
7930bool VariantImp<TYPES>::isUnset() const
7931{
7932 return !this->d_type;
7933}
7934
7935template <class TYPES>
7936bsl::ostream&
7937VariantImp<TYPES>::print(bsl::ostream& stream,
7938 int level,
7939 int spacesPerLevel) const
7940{
7941 if (this->d_type) {
7942 Variant_PrintVisitor visitor(&stream, level, spacesPerLevel);
7943
7944 doApply<const Variant_PrintVisitor&>(visitor, this->d_type);
7945 }
7946 return stream;
7947}
7948
7949template <class TYPES>
7950template <class TYPE>
7951inline
7952const TYPE& VariantImp<TYPES>::the() const
7953{
7954 BSLMF_ASSERT((0 != Variant_TypeIndex<TYPES, TYPE>::value));
7955 BSLS_ASSERT_SAFE((this->d_type == Variant_TypeIndex<TYPES, TYPE>::value));
7956
7957 typedef bsls::ObjectBuffer<TYPE> BufferType;
7958
7959 return reinterpret_cast<const BufferType *>(&this->d_value)->object();
7960}
7961
7962template <class TYPES>
7963inline
7964int VariantImp<TYPES>::typeIndex() const
7965{
7966 return this->d_type;
7967}
7968
7969#ifndef BDE_OMIT_INTERNAL_DEPRECATED
7970template <class TYPES>
7971inline
7972const bsl::type_info& VariantImp<TYPES>::typeInfo() const
7973{
7974 return typeid(void);
7975}
7976
7977template <class TYPES>
7978template <class STREAM>
7979STREAM& VariantImp<TYPES>::bdexStreamIn(STREAM& stream, int version)
7980{
7981 int type;
7983
7984 if (!stream || type < 0 || 20 < type) {
7985 stream.invalidate();
7986 return stream;
7987 }
7988
7989 if (type != this->d_type) {
7990 reset();
7991
7992 if (type) {
7993 Variant_DefaultConstructVisitor defaultConstructor(
7994 this->getAllocator());
7995 doApply(defaultConstructor, type);
7996 }
7997
7998 this->d_type = type;
7999 }
8000
8001 if (type) {
8002 Variant_BdexStreamInVisitor<STREAM> streamer(stream, version);
8003 doApply(streamer, type);
8004 }
8005 return stream;
8006}
8007
8008template <class TYPES>
8009inline
8010int VariantImp<TYPES>::maxSupportedBdexVersion() const
8011{
8012 return 1;
8013}
8014
8015template <class TYPES>
8016template <class STREAM>
8017STREAM& VariantImp<TYPES>::bdexStreamOut(STREAM& stream, int version) const
8018{
8019 bslx::OutStreamFunctions::bdexStreamOut(stream, this->d_type, 0);
8020
8021 if (this->d_type) {
8022 typedef Variant_BdexStreamOutVisitor<STREAM> Streamer;
8023
8024 Streamer streamer(stream, version);
8025 doApply<Streamer&>(streamer, this->d_type);
8026 }
8027 return stream;
8028}
8029
8030#endif // BDE_OMIT_INTERNAL_DEPRECATED
8031
8032} // close package namespace
8033
8034// FREE OPERATORS
8035template <class TYPES>
8036bool bdlb::operator==(const VariantImp<TYPES>& lhs,
8037 const VariantImp<TYPES>& rhs)
8038{
8039 if (lhs.typeIndex() != rhs.typeIndex()) {
8040 return false; // RETURN
8041 }
8042
8043 if (0 == lhs.typeIndex()) {
8044 return true; // RETURN
8045 }
8046
8047 Variant_EqualityTestVisitor visitor(&rhs.d_value);
8048 lhs.apply(visitor);
8049
8050 return visitor.d_result;
8051}
8052
8053template <class TYPES>
8054inline
8055bool bdlb::operator!=(const VariantImp<TYPES>& lhs,
8056 const VariantImp<TYPES>& rhs)
8057{
8058 return !(lhs == rhs);
8059}
8060
8061template <class TYPES>
8062inline
8063bsl::ostream& bdlb::operator<<(bsl::ostream& stream,
8064 const VariantImp<TYPES>& object)
8065{
8066 return object.print(stream, 0, -1);
8067}
8068
8069// FREE FUNCTIONS
8070template <class TYPES>
8071inline
8072void bdlb::swap(VariantImp<TYPES>& a, VariantImp<TYPES>& b)
8073{
8074 a.swap(b);
8075}
8076
8077namespace bdlb {
8078
8079 // ------------------
8080 // class Variant<...>
8081 // ------------------
8082
8083// CREATORS
8084#if defined(BDLB_VARIANT_USING_VARIADIC_TEMPLATES)
8085template <class ...TYPES>
8086inline
8088{
8089}
8090
8091template <class ...TYPES>
8092template <class TYPE_OR_ALLOCATOR>
8093inline
8094Variant<TYPES...>::Variant(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8095: Imp(valueOrAllocator)
8096{
8097}
8098
8099template <class ...TYPES>
8100template <class TYPE>
8101inline
8102Variant<TYPES...>::Variant(const TYPE& value, bslma::Allocator *basicAllocator)
8103: Imp(value, basicAllocator)
8104{
8105}
8106
8107template <class ...TYPES>
8108template <class TYPE>
8109inline
8110Variant<TYPES...>::
8111#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8112Variant(TYPE&& value,
8113 typename bsl::enable_if<
8114 !bsl::is_same<
8115 SelfType,
8116 typename bsl::remove_const<
8117 typename bsl::remove_reference<TYPE>::type>::type>::value
8118 &&
8120 void>::type *)
8121: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8122#else
8123Variant(bslmf::MovableRef<TYPE> value)
8124: Imp(MoveUtil::move(value))
8125#endif
8126{
8127}
8128
8129template <class ...TYPES>
8130template <class TYPE>
8131inline
8132Variant<TYPES...>::
8133#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8134Variant(TYPE&& value,
8135 typename bsl::enable_if<
8136 !bsl::is_same<
8137 SelfType,
8138 typename bsl::remove_const<
8139 typename bsl::remove_reference<TYPE>::type>::type>::value,
8140 bslma::Allocator>::type *basicAllocator)
8141: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8142#else
8143Variant(bslmf::MovableRef<TYPE> value,
8144 bslma::Allocator *basicAllocator)
8145: Imp(MoveUtil::move(value), basicAllocator)
8146#endif
8147{
8148}
8149
8150/// Up-cast needed since template matching has higher overloading precedence
8151/// than derived-to-base matching.
8152template <class ...TYPES>
8153inline
8154Variant<TYPES...>::Variant(const Variant& original,
8155 bslma::Allocator *basicAllocator)
8156: Imp(static_cast<const Imp&>(original), basicAllocator)
8157{
8158}
8159
8160template <class ...TYPES>
8161inline
8162Variant<TYPES...>::Variant(bslmf::MovableRef<Variant> original)
8163: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8164{
8165}
8166
8167template <class ...TYPES>
8168inline
8169Variant<TYPES...>::Variant(bslmf::MovableRef<Variant> original,
8170 bslma::Allocator *basicAllocator)
8171: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8172 basicAllocator)
8173{
8174}
8175
8176// MANIPULATORS
8177template <class ...TYPES>
8178template <class TYPE>
8179inline
8180Variant<TYPES...>& Variant<TYPES...>::operator=(const TYPE& value)
8181{
8182 Imp::operator=(value);
8183 return *this;
8184}
8185
8186template <class ...TYPES>
8187template <class TYPE>
8188inline
8189#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8190typename bsl::enable_if<
8191 !bsl::is_same<Variant<TYPES...>,
8192 typename bsl::remove_cvref<TYPE>::type>::value,
8193Variant<TYPES...> >::type&
8194Variant<TYPES...>::operator=(TYPE&& value)
8195#else
8196Variant<TYPES...>&
8197Variant<TYPES...>::operator=(bslmf::MovableRef<TYPE> value)
8198#endif
8199{
8200#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8201 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8202#else
8203 TYPE& lvalue = value;
8204 Imp::operator=(MoveUtil::move(lvalue));
8205#endif
8206
8207 return *this;
8208}
8209
8210template <class ...TYPES>
8211inline
8212Variant<TYPES...>& Variant<TYPES...>::operator=(const Variant& rhs)
8213{
8214 // Up-cast needed since template matching has higher overloading precedence
8215 // than derived-to-base matching.
8216
8217 Imp::operator=(static_cast<const Imp&>(rhs));
8218 return *this;
8219}
8220
8221template <class ...TYPES>
8222inline
8223Variant<TYPES...>& Variant<TYPES...>::operator=(bslmf::MovableRef<Variant> rhs)
8224{
8225 // Up-cast needed since template matching has higher overloading precedence
8226 // than derived-to-base matching.
8227
8228 Variant& lvalue = rhs;
8229
8230 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8231 return *this;
8232}
8233
8234#else // BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8235template <class A1, class A2, class A3, class A4, class A5, class A6,
8236 class A7, class A8, class A9, class A10, class A11, class A12,
8237 class A13, class A14, class A15, class A16, class A17, class A18,
8238 class A19, class A20>
8239inline
8240Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8241 A13, A14, A15, A16, A17, A18, A19, A20>::Variant()
8242{
8243}
8244
8245template <class A1, class A2, class A3, class A4, class A5, class A6,
8246 class A7, class A8, class A9, class A10, class A11, class A12,
8247 class A13, class A14, class A15, class A16, class A17, class A18,
8248 class A19, class A20>
8249template <class TYPE_OR_ALLOCATOR>
8250inline
8251Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8252 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8253 const TYPE_OR_ALLOCATOR& valueOrAllocator)
8254: Imp(valueOrAllocator)
8255{
8256}
8257
8258template <class A1, class A2, class A3, class A4, class A5, class A6,
8259 class A7, class A8, class A9, class A10, class A11, class A12,
8260 class A13, class A14, class A15, class A16, class A17, class A18,
8261 class A19, class A20>
8262template <class TYPE>
8263inline
8264Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8265 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8266 const TYPE& value,
8267 bslma::Allocator *basicAllocator)
8268: Imp(value, basicAllocator)
8269{
8270}
8271
8272template <class A1, class A2, class A3, class A4, class A5, class A6,
8273 class A7, class A8, class A9, class A10, class A11, class A12,
8274 class A13, class A14, class A15, class A16, class A17, class A18,
8275 class A19, class A20>
8276template <class TYPE>
8277inline
8278Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8279 A13, A14, A15, A16, A17, A18, A19, A20>::
8280#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8281Variant(TYPE&& value,
8282 typename bsl::enable_if<
8283 !bsl::is_same<
8284 SelfType,
8285 typename bsl::remove_const<
8286 typename bsl::remove_reference<TYPE>::type>::type>::value
8287 &&
8289 void>::type *)
8290: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8291#else
8292Variant(bslmf::MovableRef<TYPE> value)
8293: Imp(MoveUtil::move(value))
8294#endif
8295{
8296}
8297
8298template <class A1, class A2, class A3, class A4, class A5, class A6,
8299 class A7, class A8, class A9, class A10, class A11, class A12,
8300 class A13, class A14, class A15, class A16, class A17, class A18,
8301 class A19, class A20>
8302template <class TYPE>
8303inline
8304Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8305 A13, A14, A15, A16, A17, A18, A19, A20>::
8306#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8307Variant(TYPE&& value,
8308 typename bsl::enable_if<
8309 !bsl::is_same<
8310 SelfType,
8311 typename bsl::remove_const<
8312 typename bsl::remove_reference<TYPE>::type>::type>::value,
8313 bslma::Allocator>::type *basicAllocator)
8314: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8315#else
8316Variant(bslmf::MovableRef<TYPE> value,
8317 bslma::Allocator *basicAllocator)
8318: Imp(MoveUtil::move(value), basicAllocator)
8319#endif
8320{
8321}
8322
8323template <class A1, class A2, class A3, class A4, class A5, class A6,
8324 class A7, class A8, class A9, class A10, class A11, class A12,
8325 class A13, class A14, class A15, class A16, class A17, class A18,
8326 class A19, class A20>
8327inline
8328Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8329 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8330 const Variant& original,
8331 bslma::Allocator *basicAllocator)
8332: Imp(static_cast<const Imp&>(original), basicAllocator)
8333 // Up-cast needed since template matching has higher overloading precedence
8334 // than derived-to-base matching.
8335{
8336}
8337
8338template <class A1, class A2, class A3, class A4, class A5, class A6,
8339 class A7, class A8, class A9, class A10, class A11, class A12,
8340 class A13, class A14, class A15, class A16, class A17, class A18,
8341 class A19, class A20>
8342inline
8343Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8344 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8346: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8347{
8348}
8349
8350template <class A1, class A2, class A3, class A4, class A5, class A6,
8351 class A7, class A8, class A9, class A10, class A11, class A12,
8352 class A13, class A14, class A15, class A16, class A17, class A18,
8353 class A19, class A20>
8354inline
8355Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8356 A13, A14, A15, A16, A17, A18, A19, A20>::Variant(
8358 bslma::Allocator *basicAllocator)
8359: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8360 basicAllocator)
8361{
8362}
8363
8364// MANIPULATORS
8365template <class A1, class A2, class A3, class A4, class A5, class A6,
8366 class A7, class A8, class A9, class A10, class A11, class A12,
8367 class A13, class A14, class A15, class A16, class A17, class A18,
8368 class A19, class A20>
8369template <class TYPE>
8370inline
8371Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8372 A13, A14, A15, A16, A17, A18, A19, A20>&
8373Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8374 A13, A14, A15, A16, A17, A18, A19, A20>::operator=(const TYPE& value)
8375{
8376 Imp::operator=(value);
8377 return *this;
8378}
8379
8380template <class A1, class A2, class A3, class A4, class A5, class A6,
8381 class A7, class A8, class A9, class A10, class A11, class A12,
8382 class A13, class A14, class A15, class A16, class A17, class A18,
8383 class A19, class A20>
8384template <class TYPE>
8385inline
8386#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8387typename bsl::enable_if<
8388 !bsl::is_same<Variant<A1, A2, A3, A4, A5, A6, A7,
8389 A8, A9, A10, A11, A12, A13, A14,
8390 A15, A16, A17, A18, A19, A20>,
8391 typename bsl::remove_cvref<TYPE>::type>::value,
8392Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8393 A16, A17, A18, A19, A20> >::type&
8394Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8395 A16, A17, A18, A19, A20>::operator=(TYPE&& value)
8396#else
8397Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8398 A16, A17, A18, A19, A20>&
8399Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
8400 A16, A17, A18, A19, A20>::operator=(bslmf::MovableRef<TYPE> value)
8401#endif
8402{
8403#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8404 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8405#else
8406 TYPE& lvalue = value;
8407 Imp::operator=(MoveUtil::move(lvalue));
8408#endif
8409
8410 return *this;
8411}
8412
8413template <class A1, class A2, class A3, class A4, class A5, class A6,
8414 class A7, class A8, class A9, class A10, class A11, class A12,
8415 class A13, class A14, class A15, class A16, class A17, class A18,
8416 class A19, class A20>
8417inline
8418Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8419 A13, A14, A15, A16, A17, A18, A19, A20>&
8420Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8421 A13, A14, A15, A16, A17, A18, A19, A20>::operator=(const Variant& rhs)
8422{
8423 // Up-cast needed since template matching has higher overloading precedence
8424 // than derived-to-base matching.
8425
8426 Imp::operator=(static_cast<const Imp&>(rhs));
8427 return *this;
8428}
8429
8430template <class A1, class A2, class A3, class A4, class A5, class A6,
8431 class A7, class A8, class A9, class A10, class A11, class A12,
8432 class A13, class A14, class A15, class A16, class A17, class A18,
8433 class A19, class A20>
8434inline
8435Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8436 A13, A14, A15, A16, A17, A18, A19, A20>&
8437Variant<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
8438 A13, A14, A15, A16, A17, A18, A19, A20>::
8440{
8441 // Up-cast needed since template matching has higher overloading precedence
8442 // than derived-to-base matching.
8443
8444 Variant& lvalue = rhs;
8445
8446 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8447 return *this;
8448}
8449
8450#endif // BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8451
8452#ifdef BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8453#undef BDLB_VARIANT_USING_VARIADIC_TEMPLATES
8454#endif
8455
8456 // -------------------
8457 // class Variant2<...>
8458 // -------------------
8459
8460// CREATORS
8461template <class A1, class A2>
8462inline
8463Variant2<A1, A2>::Variant2()
8464{
8465}
8466
8467template <class A1, class A2>
8468template <class TYPE_OR_ALLOCATOR>
8469inline
8470Variant2<A1, A2>::Variant2(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8471: Imp(valueOrAllocator)
8472{
8473}
8474
8475template <class A1, class A2>
8476template <class TYPE>
8477inline
8478Variant2<A1, A2>::Variant2(const TYPE& value,
8479 bslma::Allocator *basicAllocator)
8480: Imp(value, basicAllocator)
8481{
8482}
8483
8484template <class A1, class A2>
8485template <class TYPE>
8486inline
8487Variant2<A1, A2>::
8488#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8489Variant2(TYPE&& value,
8490 typename bsl::enable_if<
8491 !bsl::is_same<
8492 SelfType,
8493 typename bsl::remove_const<
8494 typename bsl::remove_reference<TYPE>::type>::type>::value
8495 &&
8497 void>::type *)
8498: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8499#else
8500Variant2(bslmf::MovableRef<TYPE> value)
8501: Imp(MoveUtil::move(value))
8502#endif
8503{
8504}
8505
8506template <class A1, class A2>
8507template <class TYPE>
8508inline
8509Variant2<A1, A2>::
8510#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8511Variant2(TYPE&& value,
8512 typename bsl::enable_if<
8513 !bsl::is_same<
8514 SelfType,
8515 typename bsl::remove_const<
8516 typename bsl::remove_reference<TYPE>::type>::type>::value,
8517 bslma::Allocator>::type *basicAllocator)
8518: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8519#else
8520Variant2(bslmf::MovableRef<TYPE> value,
8521 bslma::Allocator *basicAllocator)
8522: Imp(MoveUtil::move(value), basicAllocator)
8523#endif
8524{
8525}
8526
8527template <class A1, class A2>
8528inline
8529Variant2<A1, A2>::Variant2(const Variant2& original,
8530 bslma::Allocator *basicAllocator)
8531: Imp(static_cast<const Imp&>(original), basicAllocator)
8532{
8533}
8534
8535template <class A1, class A2>
8536inline
8537Variant2<A1, A2>::Variant2(bslmf::MovableRef<Variant2> original)
8538: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8539{
8540}
8541
8542template <class A1, class A2>
8543inline
8544Variant2<A1, A2>::Variant2(bslmf::MovableRef<Variant2> original,
8545 bslma::Allocator *basicAllocator)
8546: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8547 basicAllocator)
8548{
8549}
8550
8551// MANIPULATORS
8552template <class A1, class A2>
8553template <class TYPE>
8554inline
8555Variant2<A1, A2>&
8556Variant2<A1, A2>::operator=(const TYPE& value)
8557{
8558 Imp::operator=(value);
8559 return *this;
8560}
8561
8562template <class A1, class A2>
8563template <class TYPE>
8564inline
8565#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8566typename bsl::enable_if<
8568 typename bsl::remove_cvref<TYPE>::type>::value,
8569Variant2<A1, A2> >::type&
8570Variant2<A1, A2>::operator=(TYPE&& value)
8571#else
8572Variant2<A1, A2>&
8573Variant2<A1, A2>::operator=(bslmf::MovableRef<TYPE> value)
8574#endif
8575{
8576#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8577 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8578#else
8579 TYPE& lvalue = value;
8580 Imp::operator=(MoveUtil::move(lvalue));
8581#endif
8582
8583 return *this;
8584}
8585
8586template <class A1, class A2>
8587inline
8588Variant2<A1, A2>&
8589Variant2<A1, A2>::operator=(const Variant2& rhs)
8590{
8591 Imp::operator=(static_cast<const Imp&>(rhs));
8592 return *this;
8593}
8594
8595template <class A1, class A2>
8596inline
8597Variant2<A1, A2>&
8598Variant2<A1, A2>::operator=(bslmf::MovableRef<Variant2> rhs)
8599{
8600 Variant2& lvalue = rhs;
8601
8602 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8603 return *this;
8604}
8605
8606 // -------------------
8607 // class Variant3<...>
8608 // -------------------
8609
8610// CREATORS
8611template <class A1, class A2, class A3>
8612inline
8613Variant3<A1, A2, A3>::Variant3()
8614{
8615}
8616
8617template <class A1, class A2, class A3>
8618template <class TYPE_OR_ALLOCATOR>
8619inline
8620Variant3<A1, A2, A3>::
8621Variant3(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8622: Imp(valueOrAllocator)
8623{
8624}
8625
8626template <class A1, class A2, class A3>
8627template <class TYPE>
8628inline
8629Variant3<A1, A2, A3>::
8630Variant3(const TYPE& value, bslma::Allocator *basicAllocator)
8631: Imp(value, basicAllocator)
8632{
8633}
8634
8635template <class A1, class A2, class A3>
8636template <class TYPE>
8637inline
8638Variant3<A1, A2, A3>::
8639#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8640Variant3(TYPE&& value,
8641 typename bsl::enable_if<
8642 !bsl::is_same<
8643 SelfType,
8644 typename bsl::remove_const<
8645 typename bsl::remove_reference<TYPE>::type>::type>::value
8646 &&
8648 void>::type *)
8649: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8650#else
8651Variant3(bslmf::MovableRef<TYPE> value)
8652: Imp(MoveUtil::move(value))
8653#endif
8654{
8655}
8656
8657template <class A1, class A2, class A3>
8658template <class TYPE>
8659inline
8660Variant3<A1, A2, A3>::
8661#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8662Variant3(TYPE&& value,
8663 typename bsl::enable_if<
8664 !bsl::is_same<
8665 SelfType,
8666 typename bsl::remove_const<
8667 typename bsl::remove_reference<TYPE>::type>::type>::value,
8668 bslma::Allocator>::type *basicAllocator)
8669: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8670#else
8671Variant3(bslmf::MovableRef<TYPE> value,
8672 bslma::Allocator *basicAllocator)
8673: Imp(MoveUtil::move(value), basicAllocator)
8674#endif
8675{
8676}
8677
8678template <class A1, class A2, class A3>
8679inline
8680Variant3<A1, A2, A3>::
8681Variant3(const Variant3& original, bslma::Allocator *basicAllocator)
8682: Imp(static_cast<const Imp&>(original), basicAllocator)
8683{
8684}
8685
8686template <class A1, class A2, class A3>
8687inline
8688Variant3<A1, A2, A3>::
8689Variant3(bslmf::MovableRef<Variant3> original)
8690: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8691{
8692}
8693
8694template <class A1, class A2, class A3>
8695inline
8696Variant3<A1, A2, A3>::
8697Variant3(bslmf::MovableRef<Variant3> original,
8698 bslma::Allocator *basicAllocator)
8699: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8700 basicAllocator)
8701{
8702}
8703
8704// MANIPULATORS
8705template <class A1, class A2, class A3>
8706template <class TYPE>
8707inline
8708Variant3<A1, A2, A3>&
8709Variant3<A1, A2, A3>::operator=(const TYPE& value)
8710{
8711 Imp::operator=(value);
8712 return *this;
8713}
8714
8715template <class A1, class A2, class A3>
8716template <class TYPE>
8717inline
8718#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8719typename bsl::enable_if<
8721 typename bsl::remove_cvref<TYPE>::type>::value,
8722Variant3<A1, A2, A3> >::type&
8723Variant3<A1, A2, A3>::operator=(TYPE&& value)
8724#else
8725Variant3<A1, A2, A3>&
8726Variant3<A1, A2, A3>::operator=(bslmf::MovableRef<TYPE> value)
8727#endif
8728{
8729#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8730 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8731#else
8732 TYPE& lvalue = value;
8733 Imp::operator=(MoveUtil::move(lvalue));
8734#endif
8735
8736 return *this;
8737}
8738
8739template <class A1, class A2, class A3>
8740inline
8741Variant3<A1, A2, A3>&
8742Variant3<A1, A2, A3>::operator=(const Variant3& rhs)
8743{
8744 Imp::operator=(static_cast<const Imp&>(rhs));
8745 return *this;
8746}
8747
8748template <class A1, class A2, class A3>
8749inline
8750Variant3<A1, A2, A3>&
8751Variant3<A1, A2, A3>::operator=(bslmf::MovableRef<Variant3> rhs)
8752{
8753 Variant3& lvalue = rhs;
8754
8755 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8756 return *this;
8757}
8758
8759 // -------------------
8760 // class Variant4<...>
8761 // -------------------
8762
8763// CREATORS
8764template <class A1, class A2, class A3, class A4>
8765inline
8766Variant4<A1, A2, A3, A4>::Variant4()
8767{
8768}
8769
8770template <class A1, class A2, class A3, class A4>
8771template <class TYPE_OR_ALLOCATOR>
8772inline
8773Variant4<A1, A2, A3, A4>::
8774Variant4(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8775: Imp(valueOrAllocator)
8776{
8777}
8778
8779template <class A1, class A2, class A3, class A4>
8780template <class TYPE>
8781inline
8782Variant4<A1, A2, A3, A4>::
8783Variant4(const TYPE& value, bslma::Allocator *basicAllocator)
8784: Imp(value, basicAllocator)
8785{
8786}
8787
8788template <class A1, class A2, class A3, class A4>
8789template <class TYPE>
8790inline
8791Variant4<A1, A2, A3, A4>::
8792#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8793Variant4(TYPE&& value,
8794 typename bsl::enable_if<
8795 !bsl::is_same<
8796 SelfType,
8797 typename bsl::remove_const<
8798 typename bsl::remove_reference<TYPE>::type>::type>::value
8799 &&
8801 void>::type *)
8802: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8803#else
8804Variant4(bslmf::MovableRef<TYPE> value)
8805: Imp(MoveUtil::move(value))
8806#endif
8807{
8808}
8809
8810template <class A1, class A2, class A3, class A4>
8811template <class TYPE>
8812inline
8813Variant4<A1, A2, A3, A4>::
8814#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8815Variant4(TYPE&& value,
8816 typename bsl::enable_if<
8817 !bsl::is_same<
8818 SelfType,
8819 typename bsl::remove_const<
8820 typename bsl::remove_reference<TYPE>::type>::type>::value,
8821 bslma::Allocator>::type *basicAllocator)
8822: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8823#else
8824Variant4(bslmf::MovableRef<TYPE> value,
8825 bslma::Allocator *basicAllocator)
8826: Imp(MoveUtil::move(value), basicAllocator)
8827#endif
8828{
8829}
8830
8831template <class A1, class A2, class A3, class A4>
8832inline
8833Variant4<A1, A2, A3, A4>::
8834Variant4(const Variant4& original, bslma::Allocator *basicAllocator)
8835: Imp(static_cast<const Imp&>(original), basicAllocator)
8836{
8837}
8838
8839template <class A1, class A2, class A3, class A4>
8840inline
8841Variant4<A1, A2, A3, A4>::
8842Variant4(bslmf::MovableRef<Variant4> original)
8843: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8844{
8845}
8846
8847template <class A1, class A2, class A3, class A4>
8848inline
8849Variant4<A1, A2, A3, A4>::
8850Variant4(bslmf::MovableRef<Variant4> original,
8851 bslma::Allocator *basicAllocator)
8852: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
8853 basicAllocator)
8854{
8855}
8856
8857// MANIPULATORS
8858template <class A1, class A2, class A3, class A4>
8859template <class TYPE>
8860inline
8861Variant4<A1, A2, A3, A4>&
8862Variant4<A1, A2, A3, A4>::operator=(const TYPE& value)
8863{
8864 Imp::operator=(value);
8865 return *this;
8866}
8867
8868template <class A1, class A2, class A3, class A4>
8869template <class TYPE>
8870inline
8871#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8872typename bsl::enable_if<
8874 typename bsl::remove_cvref<TYPE>::type>::value,
8875Variant4<A1, A2, A3, A4> >::type&
8876Variant4<A1, A2, A3, A4>::operator=(TYPE&& value)
8877#else
8878Variant4<A1, A2, A3, A4>&
8879Variant4<A1, A2, A3, A4>::operator=(bslmf::MovableRef<TYPE> value)
8880#endif
8881{
8882#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8883 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
8884#else
8885 TYPE& lvalue = value;
8886 Imp::operator=(MoveUtil::move(lvalue));
8887#endif
8888
8889 return *this;
8890}
8891
8892template <class A1, class A2, class A3, class A4>
8893inline
8894Variant4<A1, A2, A3, A4>&
8895Variant4<A1, A2, A3, A4>::operator=(const Variant4& rhs)
8896{
8897 Imp::operator=(static_cast<const Imp&>(rhs));
8898 return *this;
8899}
8900
8901template <class A1, class A2, class A3, class A4>
8902inline
8903Variant4<A1, A2, A3, A4>&
8904Variant4<A1, A2, A3, A4>::operator=(bslmf::MovableRef<Variant4> rhs)
8905{
8906 Variant4& lvalue = rhs;
8907
8908 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
8909 return *this;
8910}
8911
8912 // -------------------
8913 // class Variant5<...>
8914 // -------------------
8915
8916// CREATORS
8917template <class A1, class A2, class A3, class A4, class A5>
8918inline
8919Variant5<A1, A2, A3, A4, A5>::Variant5()
8920{
8921}
8922
8923template <class A1, class A2, class A3, class A4, class A5>
8924template <class TYPE_OR_ALLOCATOR>
8925inline
8926Variant5<A1, A2, A3, A4, A5>::
8927Variant5(const TYPE_OR_ALLOCATOR& valueOrAllocator)
8928: Imp(valueOrAllocator)
8929{
8930}
8931
8932template <class A1, class A2, class A3, class A4, class A5>
8933template <class TYPE>
8934inline
8935Variant5<A1, A2, A3, A4, A5>::
8936Variant5(const TYPE& value, bslma::Allocator *basicAllocator)
8937: Imp(value, basicAllocator)
8938{
8939}
8940
8941template <class A1, class A2, class A3, class A4, class A5>
8942template <class TYPE>
8943inline
8944Variant5<A1, A2, A3, A4, A5>::
8945#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8946Variant5(TYPE&& value,
8947 typename bsl::enable_if<
8948 !bsl::is_same<
8949 SelfType,
8950 typename bsl::remove_const<
8951 typename bsl::remove_reference<TYPE>::type>::type>::value
8952 &&
8954 void>::type *)
8955: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
8956#else
8957Variant5(bslmf::MovableRef<TYPE> value)
8958: Imp(MoveUtil::move(value))
8959#endif
8960{
8961}
8962
8963template <class A1, class A2, class A3, class A4, class A5>
8964template <class TYPE>
8965inline
8966Variant5<A1, A2, A3, A4, A5>::
8967#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
8968Variant5(TYPE&& value,
8969 typename bsl::enable_if<
8970 !bsl::is_same<
8971 SelfType,
8972 typename bsl::remove_const<
8973 typename bsl::remove_reference<TYPE>::type>::type>::value,
8974 bslma::Allocator>::type *basicAllocator)
8975: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
8976#else
8977Variant5(bslmf::MovableRef<TYPE> value,
8978 bslma::Allocator *basicAllocator)
8979: Imp(MoveUtil::move(value), basicAllocator)
8980#endif
8981{
8982}
8983
8984template <class A1, class A2, class A3, class A4, class A5>
8985inline
8986Variant5<A1, A2, A3, A4, A5>::
8987Variant5(const Variant5& original, bslma::Allocator *basicAllocator)
8988: Imp(static_cast<const Imp&>(original), basicAllocator)
8989{
8990}
8991
8992template <class A1, class A2, class A3, class A4, class A5>
8993inline
8994Variant5<A1, A2, A3, A4, A5>::
8995Variant5(bslmf::MovableRef<Variant5> original)
8996: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
8997{
8998}
8999
9000template <class A1, class A2, class A3, class A4, class A5>
9001inline
9002Variant5<A1, A2, A3, A4, A5>::
9003Variant5(bslmf::MovableRef<Variant5> original,
9004 bslma::Allocator *basicAllocator)
9005: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9006 basicAllocator)
9007{
9008}
9009
9010// MANIPULATORS
9011template <class A1, class A2, class A3, class A4, class A5>
9012template <class TYPE>
9013inline
9014Variant5<A1, A2, A3, A4, A5>&
9015Variant5<A1, A2, A3, A4, A5>::operator=(const TYPE& value)
9016{
9017 Imp::operator=(value);
9018 return *this;
9019}
9020
9021template <class A1, class A2, class A3, class A4, class A5>
9022template <class TYPE>
9023inline
9024#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9025typename bsl::enable_if<
9027 typename bsl::remove_cvref<TYPE>::type>::value,
9028Variant5<A1, A2, A3, A4, A5> >::type&
9029Variant5<A1, A2, A3, A4, A5>::operator=(TYPE&& value)
9030#else
9031Variant5<A1, A2, A3, A4, A5>&
9032Variant5<A1, A2, A3, A4, A5>::operator=(bslmf::MovableRef<TYPE> value)
9033#endif
9034{
9035#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9036 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9037#else
9038 TYPE& lvalue = value;
9039 Imp::operator=(MoveUtil::move(lvalue));
9040#endif
9041
9042 return *this;
9043}
9044
9045template <class A1, class A2, class A3, class A4, class A5>
9046inline
9047Variant5<A1, A2, A3, A4, A5>&
9048Variant5<A1, A2, A3, A4, A5>::operator=(const Variant5& rhs)
9049{
9050 Imp::operator=(static_cast<const Imp&>(rhs));
9051 return *this;
9052}
9053
9054template <class A1, class A2, class A3, class A4, class A5>
9055inline
9056Variant5<A1, A2, A3, A4, A5>&
9057Variant5<A1, A2, A3, A4, A5>::operator=(bslmf::MovableRef<Variant5> rhs)
9058{
9059 Variant5& lvalue = rhs;
9060
9061 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9062 return *this;
9063}
9064
9065 // -------------------
9066 // class Variant6<...>
9067 // -------------------
9068
9069// CREATORS
9070template <class A1, class A2, class A3, class A4, class A5, class A6>
9071inline
9072Variant6<A1, A2, A3, A4, A5, A6>::Variant6()
9073{
9074}
9075
9076template <class A1, class A2, class A3, class A4, class A5, class A6>
9077template <class TYPE_OR_ALLOCATOR>
9078inline
9079Variant6<A1, A2, A3, A4, A5, A6>::
9080Variant6(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9081: Imp(valueOrAllocator)
9082{
9083}
9084
9085template <class A1, class A2, class A3, class A4, class A5, class A6>
9086template <class TYPE>
9087inline
9088Variant6<A1, A2, A3, A4, A5, A6>::
9089Variant6(const TYPE& value, bslma::Allocator *basicAllocator)
9090: Imp(value, basicAllocator)
9091{
9092}
9093
9094template <class A1, class A2, class A3, class A4, class A5, class A6>
9095template <class TYPE>
9096inline
9097Variant6<A1, A2, A3, A4, A5, A6>::
9098#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9099Variant6(TYPE&& value,
9100 typename bsl::enable_if<
9101 !bsl::is_same<
9102 SelfType,
9103 typename bsl::remove_const<
9104 typename bsl::remove_reference<TYPE>::type>::type>::value
9105 &&
9107 void>::type *)
9108: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9109#else
9110Variant6(bslmf::MovableRef<TYPE> value)
9111: Imp(MoveUtil::move(value))
9112#endif
9113{
9114}
9115
9116template <class A1, class A2, class A3, class A4, class A5, class A6>
9117template <class TYPE>
9118inline
9119Variant6<A1, A2, A3, A4, A5, A6>::
9120#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9121Variant6(TYPE&& value,
9122 typename bsl::enable_if<
9123 !bsl::is_same<
9124 SelfType,
9125 typename bsl::remove_const<
9126 typename bsl::remove_reference<TYPE>::type>::type>::value,
9127 bslma::Allocator>::type *basicAllocator)
9128: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9129#else
9130Variant6(bslmf::MovableRef<TYPE> value,
9131 bslma::Allocator *basicAllocator)
9132: Imp(MoveUtil::move(value), basicAllocator)
9133#endif
9134{
9135}
9136
9137template <class A1, class A2, class A3, class A4, class A5, class A6>
9138inline
9139Variant6<A1, A2, A3, A4, A5, A6>::
9140Variant6(const Variant6& original, bslma::Allocator *basicAllocator)
9141: Imp(static_cast<const Imp&>(original), basicAllocator)
9142{
9143}
9144
9145template <class A1, class A2, class A3, class A4, class A5, class A6>
9146inline
9147Variant6<A1, A2, A3, A4, A5, A6>::
9148Variant6(bslmf::MovableRef<Variant6> original)
9149: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9150{
9151}
9152
9153template <class A1, class A2, class A3, class A4, class A5, class A6>
9154inline
9155Variant6<A1, A2, A3, A4, A5, A6>::
9156Variant6(bslmf::MovableRef<Variant6> original,
9157 bslma::Allocator *basicAllocator)
9158: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9159 basicAllocator)
9160{
9161}
9162
9163// MANIPULATORS
9164template <class A1, class A2, class A3, class A4, class A5, class A6>
9165template <class TYPE>
9166inline
9167Variant6<A1, A2, A3, A4, A5, A6>&
9168Variant6<A1, A2, A3, A4, A5, A6>::operator=(const TYPE& value)
9169{
9170 Imp::operator=(value);
9171 return *this;
9172}
9173
9174template <class A1, class A2, class A3, class A4, class A5, class A6>
9175template <class TYPE>
9176inline
9177#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9178typename bsl::enable_if<
9180 typename bsl::remove_cvref<TYPE>::type>::value,
9181Variant6<A1, A2, A3, A4, A5, A6> >::type&
9182Variant6<A1, A2, A3, A4, A5, A6>::operator=(TYPE&& value)
9183#else
9184Variant6<A1, A2, A3, A4, A5, A6>&
9185Variant6<A1, A2, A3, A4, A5, A6>::operator=(bslmf::MovableRef<TYPE> value)
9186#endif
9187{
9188#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9189 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9190#else
9191 TYPE& lvalue = value;
9192 Imp::operator=(MoveUtil::move(lvalue));
9193#endif
9194
9195 return *this;
9196}
9197
9198template <class A1, class A2, class A3, class A4, class A5, class A6>
9199inline
9200Variant6<A1, A2, A3, A4, A5, A6>&
9201Variant6<A1, A2, A3, A4, A5, A6>::operator=(const Variant6& rhs)
9202{
9203 Imp::operator=(static_cast<const Imp&>(rhs));
9204 return *this;
9205}
9206
9207template <class A1, class A2, class A3, class A4, class A5, class A6>
9208inline
9209Variant6<A1, A2, A3, A4, A5, A6>&
9210Variant6<A1, A2, A3, A4, A5, A6>::operator=(bslmf::MovableRef<Variant6> rhs)
9211{
9212 Variant6& lvalue = rhs;
9213
9214 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9215 return *this;
9216}
9217
9218 // -------------------
9219 // class Variant7<...>
9220 // -------------------
9221
9222// CREATORS
9223template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9224inline
9225Variant7<A1, A2, A3, A4, A5, A6, A7>::Variant7()
9226{
9227}
9228
9229template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9230template <class TYPE_OR_ALLOCATOR>
9231inline
9232Variant7<A1, A2, A3, A4, A5, A6, A7>::
9233Variant7(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9234: Imp(valueOrAllocator)
9235{
9236}
9237
9238template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9239template <class TYPE>
9240inline
9241Variant7<A1, A2, A3, A4, A5, A6, A7>::
9242Variant7(const TYPE& value, bslma::Allocator *basicAllocator)
9243: Imp(value, basicAllocator)
9244{
9245}
9246
9247template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9248template <class TYPE>
9249inline
9250Variant7<A1, A2, A3, A4, A5, A6, A7>::
9251#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9252Variant7(TYPE&& value,
9253 typename bsl::enable_if<
9254 !bsl::is_same<
9255 SelfType,
9256 typename bsl::remove_const<
9257 typename bsl::remove_reference<TYPE>::type>::type>::value
9258 &&
9260 void>::type *)
9261: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9262#else
9263Variant7(bslmf::MovableRef<TYPE> value)
9264: Imp(MoveUtil::move(value))
9265#endif
9266{
9267}
9268
9269template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9270template <class TYPE>
9271inline
9272Variant7<A1, A2, A3, A4, A5, A6, A7>::
9273#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9274Variant7(TYPE&& value,
9275 typename bsl::enable_if<
9276 !bsl::is_same<
9277 SelfType,
9278 typename bsl::remove_const<
9279 typename bsl::remove_reference<TYPE>::type>::type>::value,
9280 bslma::Allocator>::type *basicAllocator)
9281: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9282#else
9283Variant7(bslmf::MovableRef<TYPE> value,
9284 bslma::Allocator *basicAllocator)
9285: Imp(MoveUtil::move(value), basicAllocator)
9286#endif
9287{
9288}
9289
9290template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9291inline
9292Variant7<A1, A2, A3, A4, A5, A6, A7>::
9293Variant7(const Variant7& original, bslma::Allocator *basicAllocator)
9294: Imp(static_cast<const Imp&>(original), basicAllocator)
9295{
9296}
9297
9298template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9299inline
9300Variant7<A1, A2, A3, A4, A5, A6, A7>::
9301Variant7(bslmf::MovableRef<Variant7> original)
9302: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9303{
9304}
9305
9306template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9307inline
9308Variant7<A1, A2, A3, A4, A5, A6, A7>::
9309Variant7(bslmf::MovableRef<Variant7> original,
9310 bslma::Allocator *basicAllocator)
9311: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9312 basicAllocator)
9313{
9314}
9315
9316// MANIPULATORS
9317template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9318template <class TYPE>
9319inline
9320Variant7<A1, A2, A3, A4, A5, A6, A7>&
9321Variant7<A1, A2, A3, A4, A5, A6, A7>::operator=(const TYPE& value)
9322{
9323 Imp::operator=(value);
9324 return *this;
9325}
9326
9327template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9328template <class TYPE>
9329inline
9330#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9331typename bsl::enable_if<
9333 typename bsl::remove_cvref<TYPE>::type>::value,
9334Variant7<A1, A2, A3, A4, A5, A6, A7> >::type&
9335Variant7<A1, A2, A3, A4, A5, A6, A7>::operator=(TYPE&& value)
9336#else
9337Variant7<A1, A2, A3, A4, A5, A6, A7>&
9338Variant7<A1, A2, A3, A4, A5, A6, A7>::operator=(bslmf::MovableRef<TYPE> value)
9339#endif
9340{
9341#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9342 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9343#else
9344 TYPE& lvalue = value;
9345 Imp::operator=(MoveUtil::move(lvalue));
9346#endif
9347
9348 return *this;
9349}
9350
9351template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9352inline
9353Variant7<A1, A2, A3, A4, A5, A6, A7>&
9354Variant7<A1, A2, A3, A4, A5, A6, A7>::
9355operator=(const Variant7& rhs)
9356{
9357 Imp::operator=(static_cast<const Imp&>(rhs));
9358 return *this;
9359}
9360
9361template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
9362inline
9363Variant7<A1, A2, A3, A4, A5, A6, A7>&
9364Variant7<A1, A2, A3, A4, A5, A6, A7>::
9365operator=(bslmf::MovableRef<Variant7> rhs)
9366{
9367 Variant7& lvalue = rhs;
9368
9369 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9370 return *this;
9371}
9372
9373 // -------------------
9374 // class Variant8<...>
9375 // -------------------
9376
9377// CREATORS
9378template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9379 class A8>
9380inline
9381Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::Variant8()
9382{
9383}
9384
9385template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9386 class A8>
9387template <class TYPE_OR_ALLOCATOR>
9388inline
9389Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9390Variant8(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9391: Imp(valueOrAllocator)
9392{
9393}
9394
9395template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9396 class A8>
9397template <class TYPE>
9398inline
9399Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9400Variant8(const TYPE& value, bslma::Allocator *basicAllocator)
9401: Imp(value, basicAllocator)
9402{
9403}
9404
9405template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9406 class A8>
9407template <class TYPE>
9408inline
9409Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9410#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9411Variant8(TYPE&& value,
9412 typename bsl::enable_if<
9413 !bsl::is_same<
9414 SelfType,
9415 typename bsl::remove_const<
9416 typename bsl::remove_reference<TYPE>::type>::type>::value
9417 &&
9419 void>::type *)
9420: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9421#else
9422Variant8(bslmf::MovableRef<TYPE> value)
9423: Imp(MoveUtil::move(value))
9424#endif
9425{
9426}
9427
9428template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9429 class A8>
9430template <class TYPE>
9431inline
9432Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9433#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9434Variant8(TYPE&& value,
9435 typename bsl::enable_if<
9436 !bsl::is_same<
9437 SelfType,
9438 typename bsl::remove_const<
9439 typename bsl::remove_reference<TYPE>::type>::type>::value,
9440 bslma::Allocator>::type *basicAllocator)
9441: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9442#else
9443Variant8(bslmf::MovableRef<TYPE> value,
9444 bslma::Allocator *basicAllocator)
9445: Imp(MoveUtil::move(value), basicAllocator)
9446#endif
9447{
9448}
9449
9450template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9451 class A8>
9452inline
9453Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9454Variant8(const Variant8& original, bslma::Allocator *basicAllocator)
9455: Imp(static_cast<const Imp&>(original), basicAllocator)
9456{
9457}
9458
9459template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9460 class A8>
9461inline
9462Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9463Variant8(bslmf::MovableRef<Variant8> original)
9464: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9465{
9466}
9467
9468template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9469 class A8>
9470inline
9471Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9472Variant8(bslmf::MovableRef<Variant8> original,
9473 bslma::Allocator *basicAllocator)
9474: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9475 basicAllocator)
9476{
9477}
9478
9479// MANIPULATORS
9480template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9481 class A8>
9482template <class TYPE>
9483inline
9484Variant8<A1, A2, A3, A4, A5, A6, A7, A8>&
9485Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::operator=(const TYPE& value)
9486{
9487 Imp::operator=(value);
9488 return *this;
9489}
9490
9491template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9492 class A8>
9493template <class TYPE>
9494inline
9495#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9496typename bsl::enable_if<
9498 typename bsl::remove_cvref<TYPE>::type>::value,
9499Variant8<A1, A2, A3, A4, A5, A6, A7, A8> >::type&
9500Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9501operator=(TYPE&& value)
9502#else
9503Variant8<A1, A2, A3, A4, A5, A6, A7, A8>&
9504Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9505operator=(bslmf::MovableRef<TYPE> value)
9506#endif
9507{
9508#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9509 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9510#else
9511 TYPE& lvalue = value;
9512 Imp::operator=(MoveUtil::move(lvalue));
9513#endif
9514
9515 return *this;
9516}
9517
9518template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9519 class A8>
9520inline
9521Variant8<A1, A2, A3, A4, A5, A6, A7, A8>&
9522Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9523operator=(const Variant8& rhs)
9524{
9525 Imp::operator=(static_cast<const Imp&>(rhs));
9526 return *this;
9527}
9528
9529template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9530 class A8>
9531inline
9532Variant8<A1, A2, A3, A4, A5, A6, A7, A8>&
9533Variant8<A1, A2, A3, A4, A5, A6, A7, A8>::
9534operator=(bslmf::MovableRef<Variant8> rhs)
9535{
9536 Variant8& lvalue = rhs;
9537
9538 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9539 return *this;
9540}
9541
9542 // -------------------
9543 // class Variant9<...>
9544 // -------------------
9545
9546// CREATORS
9547template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9548 class A8, class A9>
9549inline
9550Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::Variant9()
9551{
9552}
9553
9554template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9555 class A8, class A9>
9556template <class TYPE_OR_ALLOCATOR>
9557inline
9558Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9559Variant9(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9560: Imp(valueOrAllocator)
9561{
9562}
9563
9564template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9565 class A8, class A9>
9566template <class TYPE>
9567inline
9568Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9569Variant9(const TYPE& value, bslma::Allocator *basicAllocator)
9570: Imp(value, basicAllocator)
9571{
9572}
9573
9574template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9575 class A8, class A9>
9576template <class TYPE>
9577inline
9578Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9579#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9580Variant9(TYPE&& value,
9581 typename bsl::enable_if<
9582 !bsl::is_same<
9583 SelfType,
9584 typename bsl::remove_const<
9585 typename bsl::remove_reference<TYPE>::type>::type>::value
9586 &&
9588 void>::type *)
9589: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9590#else
9591Variant9(bslmf::MovableRef<TYPE> value)
9592: Imp(MoveUtil::move(value))
9593#endif
9594{
9595}
9596
9597template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9598 class A8, class A9>
9599template <class TYPE>
9600inline
9601Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9602#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9603Variant9(TYPE&& value,
9604 typename bsl::enable_if<
9605 !bsl::is_same<
9606 SelfType,
9607 typename bsl::remove_const<
9608 typename bsl::remove_reference<TYPE>::type>::type>::value,
9609 bslma::Allocator>::type *basicAllocator)
9610: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9611#else
9612Variant9(bslmf::MovableRef<TYPE> value,
9613 bslma::Allocator *basicAllocator)
9614: Imp(MoveUtil::move(value), basicAllocator)
9615#endif
9616{
9617}
9618
9619template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9620 class A8, class A9>
9621inline
9622Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9623Variant9(const Variant9& original, bslma::Allocator *basicAllocator)
9624: Imp(static_cast<const Imp&>(original), basicAllocator)
9625{
9626}
9627
9628template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9629 class A8, class A9>
9630inline
9631Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9632Variant9(bslmf::MovableRef<Variant9> original)
9633: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9634{
9635}
9636
9637template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9638 class A8, class A9>
9639inline
9640Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9641Variant9(bslmf::MovableRef<Variant9> original,
9642 bslma::Allocator *basicAllocator)
9643: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9644 basicAllocator)
9645{
9646}
9647
9648// MANIPULATORS
9649template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9650 class A8, class A9>
9651template <class TYPE>
9652inline
9653Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>&
9654Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9655operator=(const TYPE& value)
9656{
9657 Imp::operator=(value);
9658 return *this;
9659}
9660
9661template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9662 class A8, class A9>
9663template <class TYPE>
9664inline
9665#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9666typename bsl::enable_if<
9668 typename bsl::remove_cvref<TYPE>::type>::value,
9669Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9> >::type&
9670Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9671operator=(TYPE&& value)
9672#else
9673Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>&
9674Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9675operator=(bslmf::MovableRef<TYPE> value)
9676#endif
9677{
9678#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9679 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9680#else
9681 TYPE& lvalue = value;
9682 Imp::operator=(MoveUtil::move(lvalue));
9683#endif
9684
9685 return *this;
9686}
9687
9688template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9689 class A8, class A9>
9690inline
9691Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>&
9692Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9693operator=(const Variant9& rhs)
9694{
9695 Imp::operator=(static_cast<const Imp&>(rhs));
9696 return *this;
9697}
9698
9699template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9700 class A8, class A9>
9701inline
9702Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>&
9703Variant9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::
9704operator=(bslmf::MovableRef<Variant9> rhs)
9705{
9706 Variant9& lvalue = rhs;
9707
9708 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9709 return *this;
9710}
9711
9712 // --------------------
9713 // class Variant10<...>
9714 // --------------------
9715
9716// CREATORS
9717template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9718 class A8, class A9, class A10>
9719inline
9720Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::Variant10()
9721{
9722}
9723
9724template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9725 class A8, class A9, class A10>
9726template <class TYPE_OR_ALLOCATOR>
9727inline
9728Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9729Variant10(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9730: Imp(valueOrAllocator)
9731{
9732}
9733
9734template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9735 class A8, class A9, class A10>
9736template <class TYPE>
9737inline
9738Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9739Variant10(const TYPE& value, bslma::Allocator *basicAllocator)
9740: Imp(value, basicAllocator)
9741{
9742}
9743
9744template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9745 class A8, class A9, class A10>
9746template <class TYPE>
9747inline
9748Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9749#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9750Variant10(TYPE&& value,
9751 typename bsl::enable_if<
9752 !bsl::is_same<
9753 SelfType,
9754 typename bsl::remove_const<
9755 typename bsl::remove_reference<TYPE>::type>::type>::value
9756 &&
9758 void>::type *)
9759: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9760#else
9761Variant10(bslmf::MovableRef<TYPE> value)
9762: Imp(MoveUtil::move(value))
9763#endif
9764{
9765}
9766
9767template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9768 class A8, class A9, class A10>
9769template <class TYPE>
9770inline
9771Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9772#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9773Variant10(TYPE&& value,
9774 typename bsl::enable_if<
9775 !bsl::is_same<
9776 SelfType,
9777 typename bsl::remove_const<
9778 typename bsl::remove_reference<TYPE>::type>::type>::value,
9779 bslma::Allocator>::type *basicAllocator)
9780: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9781#else
9782Variant10(bslmf::MovableRef<TYPE> value,
9783 bslma::Allocator *basicAllocator)
9784: Imp(MoveUtil::move(value), basicAllocator)
9785#endif
9786{
9787}
9788
9789template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9790 class A8, class A9, class A10>
9791inline
9792Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9793Variant10(const Variant10& original, bslma::Allocator *basicAllocator)
9794: Imp(static_cast<const Imp&>(original), basicAllocator)
9795{
9796}
9797
9798template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9799 class A8, class A9, class A10>
9800inline
9801Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9802Variant10(bslmf::MovableRef<Variant10> original)
9803: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9804{
9805}
9806
9807template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9808 class A8, class A9, class A10>
9809inline
9810Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9811Variant10(bslmf::MovableRef<Variant10> original,
9812 bslma::Allocator *basicAllocator)
9813: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9814 basicAllocator)
9815{
9816}
9817
9818// MANIPULATORS
9819template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9820 class A8, class A9, class A10>
9821template <class TYPE>
9822inline
9823Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>&
9824Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9825operator=(const TYPE& value)
9826{
9827 Imp::operator=(value);
9828 return *this;
9829}
9830
9831template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9832 class A8, class A9, class A10>
9833template <class TYPE>
9834inline
9835#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9836typename bsl::enable_if<
9838 typename bsl::remove_cvref<TYPE>::type>::value,
9839Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> >::type&
9840Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9841operator=(TYPE&& value)
9842#else
9843Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>&
9844Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9845operator=(bslmf::MovableRef<TYPE> value)
9846#endif
9847{
9848#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9849 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
9850#else
9851 TYPE& lvalue = value;
9852 Imp::operator=(MoveUtil::move(lvalue));
9853#endif
9854
9855 return *this;
9856}
9857
9858template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9859 class A8, class A9, class A10>
9860inline
9861Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>&
9862Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9863operator=(const Variant10& rhs)
9864{
9865 Imp::operator=(static_cast<const Imp&>(rhs));
9866 return *this;
9867}
9868
9869template <class A1, class A2, class A3, class A4, class A5, class A6, class A7,
9870 class A8, class A9, class A10>
9871inline
9872Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>&
9873Variant10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::
9874operator=(bslmf::MovableRef<Variant10> rhs)
9875{
9876 Variant10& lvalue = rhs;
9877
9878 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
9879 return *this;
9880}
9881
9882 // --------------------
9883 // class Variant11<...>
9884 // --------------------
9885
9886// CREATORS
9887template <class A1, class A2, class A3, class A4, class A5, class A6,
9888 class A7, class A8, class A9, class A10, class A11>
9889inline
9890Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9891Variant11()
9892{
9893}
9894
9895template <class A1, class A2, class A3, class A4, class A5, class A6,
9896 class A7, class A8, class A9, class A10, class A11>
9897template <class TYPE_OR_ALLOCATOR>
9898inline
9899Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9900Variant11(const TYPE_OR_ALLOCATOR& valueOrAllocator)
9901: Imp(valueOrAllocator)
9902{
9903}
9904
9905template <class A1, class A2, class A3, class A4, class A5, class A6,
9906 class A7, class A8, class A9, class A10, class A11>
9907template <class TYPE>
9908inline
9909Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9910Variant11(const TYPE& value, bslma::Allocator *basicAllocator)
9911: Imp(value, basicAllocator)
9912{
9913}
9914
9915template <class A1, class A2, class A3, class A4, class A5, class A6,
9916 class A7, class A8, class A9, class A10, class A11>
9917template <class TYPE>
9918inline
9919Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9920#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9921Variant11(TYPE&& value,
9922 typename bsl::enable_if<
9923 !bsl::is_same<
9924 SelfType,
9925 typename bsl::remove_const<
9926 typename bsl::remove_reference<TYPE>::type>::type>::value
9927 &&
9929 void>::type *)
9930: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
9931#else
9932Variant11(bslmf::MovableRef<TYPE> value)
9933: Imp(MoveUtil::move(value))
9934#endif
9935{
9936}
9937
9938template <class A1, class A2, class A3, class A4, class A5, class A6,
9939 class A7, class A8, class A9, class A10, class A11>
9940template <class TYPE>
9941inline
9942Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9943#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
9944Variant11(TYPE&& value,
9945 typename bsl::enable_if<
9946 !bsl::is_same<
9947 SelfType,
9948 typename bsl::remove_const<
9949 typename bsl::remove_reference<TYPE>::type>::type>::value,
9950 bslma::Allocator>::type *basicAllocator)
9951: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
9952#else
9953Variant11(bslmf::MovableRef<TYPE> value,
9954 bslma::Allocator *basicAllocator)
9955: Imp(MoveUtil::move(value), basicAllocator)
9956#endif
9957{
9958}
9959
9960template <class A1, class A2, class A3, class A4, class A5, class A6,
9961 class A7, class A8, class A9, class A10, class A11>
9962inline
9963Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9964Variant11(const Variant11& original, bslma::Allocator *basicAllocator)
9965: Imp(static_cast<const Imp&>(original), basicAllocator)
9966{
9967}
9968
9969template <class A1, class A2, class A3, class A4, class A5, class A6,
9970 class A7, class A8, class A9, class A10, class A11>
9971inline
9972Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9973Variant11(bslmf::MovableRef<Variant11> original)
9974: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
9975{
9976}
9977
9978template <class A1, class A2, class A3, class A4, class A5, class A6,
9979 class A7, class A8, class A9, class A10, class A11>
9980inline
9981Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9982Variant11(bslmf::MovableRef<Variant11> original,
9983 bslma::Allocator *basicAllocator)
9984: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
9985 basicAllocator)
9986{
9987}
9988
9989// MANIPULATORS
9990template <class A1, class A2, class A3, class A4, class A5, class A6,
9991 class A7, class A8, class A9, class A10, class A11>
9992template <class TYPE>
9993inline
9994Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>&
9995Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
9996operator=(const TYPE& value)
9997{
9998 Imp::operator=(value);
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>
10004template <class TYPE>
10005inline
10006#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10007typename bsl::enable_if<
10009 typename bsl::remove_cvref<TYPE>::type>::value,
10010Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> >::type&
10011Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
10012operator=(TYPE&& value)
10013#else
10014Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>&
10015Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
10016operator=(bslmf::MovableRef<TYPE> value)
10017#endif
10018{
10019#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10020 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10021#else
10022 TYPE& lvalue = value;
10023 Imp::operator=(MoveUtil::move(lvalue));
10024#endif
10025
10026 return *this;
10027}
10028
10029template <class A1, class A2, class A3, class A4, class A5, class A6,
10030 class A7, class A8, class A9, class A10, class A11>
10031inline
10032Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>&
10033Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
10034operator=(const Variant11& rhs)
10035{
10036 Imp::operator=(static_cast<const Imp&>(rhs));
10037 return *this;
10038}
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>
10042inline
10043Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>&
10044Variant11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::
10045operator=(bslmf::MovableRef<Variant11> rhs)
10046{
10047 Variant11& lvalue = rhs;
10048
10049 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10050 return *this;
10051}
10052
10053 // --------------------
10054 // class Variant12<...>
10055 // --------------------
10056
10057// CREATORS
10058template <class A1, class A2, class A3, class A4, class A5, class A6,
10059 class A7, class A8, class A9, class A10, class A11, class A12>
10060inline
10061Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10062Variant12()
10063{
10064}
10065
10066template <class A1, class A2, class A3, class A4, class A5, class A6,
10067 class A7, class A8, class A9, class A10, class A11, class A12>
10068template <class TYPE_OR_ALLOCATOR>
10069inline
10070Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10071Variant12(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10072: Imp(valueOrAllocator)
10073{
10074}
10075
10076template <class A1, class A2, class A3, class A4, class A5, class A6,
10077 class A7, class A8, class A9, class A10, class A11, class A12>
10078template <class TYPE>
10079inline
10080Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10081Variant12(const TYPE& value, bslma::Allocator *basicAllocator)
10082: Imp(value, basicAllocator)
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>
10088template <class TYPE>
10089inline
10090Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10091#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10092Variant12(TYPE&& value,
10093 typename bsl::enable_if<
10094 !bsl::is_same<
10095 SelfType,
10096 typename bsl::remove_const<
10097 typename bsl::remove_reference<TYPE>::type>::type>::value
10098 &&
10100 void>::type *)
10101: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10102#else
10103Variant12(bslmf::MovableRef<TYPE> value)
10104: Imp(MoveUtil::move(value))
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>
10111template <class TYPE>
10112inline
10113Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10114#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10115Variant12(TYPE&& value,
10116 typename bsl::enable_if<
10117 !bsl::is_same<
10118 SelfType,
10119 typename bsl::remove_const<
10120 typename bsl::remove_reference<TYPE>::type>::type>::value,
10121 bslma::Allocator>::type *basicAllocator)
10122: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10123#else
10124Variant12(bslmf::MovableRef<TYPE> value,
10125 bslma::Allocator *basicAllocator)
10126: Imp(MoveUtil::move(value), basicAllocator)
10127#endif
10128{
10129}
10130
10131template <class A1, class A2, class A3, class A4, class A5, class A6,
10132 class A7, class A8, class A9, class A10, class A11, class A12>
10133inline
10134Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10135Variant12(const Variant12& original, bslma::Allocator *basicAllocator)
10136: Imp(static_cast<const Imp&>(original), basicAllocator)
10137{
10138}
10139
10140template <class A1, class A2, class A3, class A4, class A5, class A6,
10141 class A7, class A8, class A9, class A10, class A11, class A12>
10142inline
10143Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10144Variant12(bslmf::MovableRef<Variant12> original)
10145: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10146{
10147}
10148
10149template <class A1, class A2, class A3, class A4, class A5, class A6,
10150 class A7, class A8, class A9, class A10, class A11, class A12>
10151inline
10152Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10153Variant12(bslmf::MovableRef<Variant12> original,
10154 bslma::Allocator *basicAllocator)
10155: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10156 basicAllocator)
10157{
10158}
10159
10160// MANIPULATORS
10161template <class A1, class A2, class A3, class A4, class A5, class A6,
10162 class A7, class A8, class A9, class A10, class A11, class A12>
10163template <class TYPE>
10164inline
10165Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>&
10166Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10167operator=(const TYPE& value)
10168{
10169 Imp::operator=(value);
10170 return *this;
10171}
10172
10173template <class A1, class A2, class A3, class A4, class A5, class A6,
10174 class A7, class A8, class A9, class A10, class A11, class A12>
10175template <class TYPE>
10176inline
10177#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10178typename bsl::enable_if<
10180 typename bsl::remove_cvref<TYPE>::type>::value,
10181Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> >::type&
10182Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10183operator=(TYPE&& value)
10184#else
10185Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>&
10186Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10187operator=(bslmf::MovableRef<TYPE> value)
10188#endif
10189{
10190#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10191 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10192#else
10193 TYPE& lvalue = value;
10194 Imp::operator=(MoveUtil::move(lvalue));
10195#endif
10196
10197 return *this;
10198}
10199
10200template <class A1, class A2, class A3, class A4, class A5, class A6,
10201 class A7, class A8, class A9, class A10, class A11, class A12>
10202inline
10203Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>&
10204Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10205operator=(const Variant12& rhs)
10206{
10207 Imp::operator=(static_cast<const Imp&>(rhs));
10208 return *this;
10209}
10210
10211template <class A1, class A2, class A3, class A4, class A5, class A6,
10212 class A7, class A8, class A9, class A10, class A11, class A12>
10213inline
10214Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>&
10215Variant12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>::
10216operator=(bslmf::MovableRef<Variant12> rhs)
10217{
10218 Variant12& lvalue = rhs;
10219
10220 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10221 return *this;
10222}
10223
10224 // --------------------
10225 // class Variant13<...>
10226 // --------------------
10227
10228// CREATORS
10229template <class A1, class A2, class A3, class A4, class A5, class A6,
10230 class A7, class A8, class A9, class A10, class A11, class A12,
10231 class A13>
10232inline
10233Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10234Variant13()
10235{
10236}
10237
10238template <class A1, class A2, class A3, class A4, class A5, class A6,
10239 class A7, class A8, class A9, class A10, class A11, class A12,
10240 class A13>
10241template <class TYPE_OR_ALLOCATOR>
10242inline
10243Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10244Variant13(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10245: Imp(valueOrAllocator)
10246{
10247}
10248
10249template <class A1, class A2, class A3, class A4, class A5, class A6,
10250 class A7, class A8, class A9, class A10, class A11, class A12,
10251 class A13>
10252template <class TYPE>
10253inline
10254Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10255Variant13(const TYPE& value, bslma::Allocator *basicAllocator)
10256: Imp(value, basicAllocator)
10257{
10258}
10259
10260template <class A1, class A2, class A3, class A4, class A5, class A6,
10261 class A7, class A8, class A9, class A10, class A11, class A12,
10262 class A13>
10263template <class TYPE>
10264inline
10265Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10266#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10267Variant13(TYPE&& value,
10268 typename bsl::enable_if<
10269 !bsl::is_same<
10270 SelfType,
10271 typename bsl::remove_const<
10272 typename bsl::remove_reference<TYPE>::type>::type>::value
10273 &&
10275 void>::type *)
10276: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10277#else
10278Variant13(bslmf::MovableRef<TYPE> value)
10279: Imp(MoveUtil::move(value))
10280#endif
10281{
10282}
10283
10284template <class A1, class A2, class A3, class A4, class A5, class A6,
10285 class A7, class A8, class A9, class A10, class A11, class A12,
10286 class A13>
10287template <class TYPE>
10288inline
10289Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10290#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10291Variant13(TYPE&& value,
10292 typename bsl::enable_if<
10293 !bsl::is_same<
10294 SelfType,
10295 typename bsl::remove_const<
10296 typename bsl::remove_reference<TYPE>::type>::type>::value,
10297 bslma::Allocator>::type *basicAllocator)
10298: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10299#else
10300Variant13(bslmf::MovableRef<TYPE> value,
10301 bslma::Allocator *basicAllocator)
10302: Imp(MoveUtil::move(value), basicAllocator)
10303#endif
10304{
10305}
10306
10307template <class A1, class A2, class A3, class A4, class A5, class A6,
10308 class A7, class A8, class A9, class A10, class A11, class A12,
10309 class A13>
10310inline
10311Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10312Variant13(const Variant13& original, bslma::Allocator *basicAllocator)
10313: Imp(static_cast<const Imp&>(original), basicAllocator)
10314{
10315}
10316
10317template <class A1, class A2, class A3, class A4, class A5, class A6,
10318 class A7, class A8, class A9, class A10, class A11, class A12,
10319 class A13>
10320inline
10321Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10322Variant13(bslmf::MovableRef<Variant13> original)
10323: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10324{
10325}
10326
10327template <class A1, class A2, class A3, class A4, class A5, class A6,
10328 class A7, class A8, class A9, class A10, class A11, class A12,
10329 class A13>
10330inline
10331Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10332Variant13(bslmf::MovableRef<Variant13> original,
10333 bslma::Allocator *basicAllocator)
10334: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10335 basicAllocator)
10336{
10337}
10338
10339// MANIPULATORS
10340template <class A1, class A2, class A3, class A4, class A5, class A6,
10341 class A7, class A8, class A9, class A10, class A11, class A12,
10342 class A13>
10343template <class TYPE>
10344inline
10345Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>&
10346Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10347operator=(const TYPE& value)
10348{
10349 Imp::operator=(value);
10350 return *this;
10351}
10352
10353template <class A1, class A2, class A3, class A4, class A5, class A6,
10354 class A7, class A8, class A9, class A10, class A11, class A12,
10355 class A13>
10356template <class TYPE>
10357inline
10358#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10359typename bsl::enable_if<
10360 !bsl::is_same<Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
10361 A13>,
10362 typename bsl::remove_cvref<TYPE>::type>::value,
10363Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> >::type&
10364Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10365operator=(TYPE&& value)
10366#else
10367Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>&
10368Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10369operator=(bslmf::MovableRef<TYPE> value)
10370#endif
10371{
10372#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10373 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10374#else
10375 TYPE& lvalue = value;
10376 Imp::operator=(MoveUtil::move(lvalue));
10377#endif
10378
10379 return *this;
10380}
10381
10382template <class A1, class A2, class A3, class A4, class A5, class A6,
10383 class A7, class A8, class A9, class A10, class A11, class A12,
10384 class A13>
10385inline
10386Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>&
10387Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10388operator=(const Variant13& rhs)
10389{
10390 Imp::operator=(static_cast<const Imp&>(rhs));
10391 return *this;
10392}
10393
10394template <class A1, class A2, class A3, class A4, class A5, class A6,
10395 class A7, class A8, class A9, class A10, class A11, class A12,
10396 class A13>
10397inline
10398Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>&
10399Variant13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>::
10400operator=(bslmf::MovableRef<Variant13> rhs)
10401{
10402 Variant13& lvalue = rhs;
10403
10404 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10405 return *this;
10406}
10407
10408 // --------------------
10409 // class Variant14<...>
10410 // --------------------
10411
10412// CREATORS
10413template <class A1, class A2, class A3, class A4, class A5, class A6,
10414 class A7, class A8, class A9, class A10, class A11, class A12,
10415 class A13, class A14>
10416inline
10417Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10418Variant14()
10419{
10420}
10421
10422template <class A1, class A2, class A3, class A4, class A5, class A6,
10423 class A7, class A8, class A9, class A10, class A11, class A12,
10424 class A13, class A14>
10425template <class TYPE_OR_ALLOCATOR>
10426inline
10427Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10428Variant14(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10429: Imp(valueOrAllocator)
10430{
10431}
10432
10433template <class A1, class A2, class A3, class A4, class A5, class A6,
10434 class A7, class A8, class A9, class A10, class A11, class A12,
10435 class A13, class A14>
10436template <class TYPE>
10437inline
10438Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10439Variant14(const TYPE& value, bslma::Allocator *basicAllocator)
10440: Imp(value, basicAllocator)
10441{
10442}
10443
10444template <class A1, class A2, class A3, class A4, class A5, class A6,
10445 class A7, class A8, class A9, class A10, class A11, class A12,
10446 class A13, class A14>
10447template <class TYPE>
10448inline
10449Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10450#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10451Variant14(TYPE&& value,
10452 typename bsl::enable_if<
10453 !bsl::is_same<
10454 SelfType,
10455 typename bsl::remove_const<
10456 typename bsl::remove_reference<TYPE>::type>::type>::value
10457 &&
10459 void>::type *)
10460: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10461#else
10462Variant14(bslmf::MovableRef<TYPE> value)
10463: Imp(MoveUtil::move(value))
10464#endif
10465{
10466}
10467
10468template <class A1, class A2, class A3, class A4, class A5, class A6,
10469 class A7, class A8, class A9, class A10, class A11, class A12,
10470 class A13, class A14>
10471template <class TYPE>
10472inline
10473Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10474#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10475Variant14(TYPE&& value,
10476 typename bsl::enable_if<
10477 !bsl::is_same<
10478 SelfType,
10479 typename bsl::remove_const<
10480 typename bsl::remove_reference<TYPE>::type>::type>::value,
10481 bslma::Allocator>::type *basicAllocator)
10482: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10483#else
10484Variant14(bslmf::MovableRef<TYPE> value,
10485 bslma::Allocator *basicAllocator)
10486: Imp(MoveUtil::move(value), basicAllocator)
10487#endif
10488{
10489}
10490
10491template <class A1, class A2, class A3, class A4, class A5, class A6,
10492 class A7, class A8, class A9, class A10, class A11, class A12,
10493 class A13, class A14>
10494inline
10495Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10496Variant14(const Variant14& original, bslma::Allocator *basicAllocator)
10497: Imp(static_cast<const Imp&>(original), basicAllocator)
10498{
10499}
10500
10501template <class A1, class A2, class A3, class A4, class A5, class A6,
10502 class A7, class A8, class A9, class A10, class A11, class A12,
10503 class A13, class A14>
10504inline
10505Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10506Variant14(bslmf::MovableRef<Variant14> original)
10507: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10508{
10509}
10510
10511template <class A1, class A2, class A3, class A4, class A5, class A6,
10512 class A7, class A8, class A9, class A10, class A11, class A12,
10513 class A13, class A14>
10514inline
10515Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10516Variant14(bslmf::MovableRef<Variant14> original,
10517 bslma::Allocator *basicAllocator)
10518: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10519 basicAllocator)
10520{
10521}
10522
10523// MANIPULATORS
10524template <class A1, class A2, class A3, class A4, class A5, class A6,
10525 class A7, class A8, class A9, class A10, class A11, class A12,
10526 class A13, class A14>
10527template <class TYPE>
10528inline
10529Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>&
10530Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10531operator=(const TYPE& value)
10532{
10533 Imp::operator=(value);
10534 return *this;
10535}
10536
10537template <class A1, class A2, class A3, class A4, class A5, class A6,
10538 class A7, class A8, class A9, class A10, class A11, class A12,
10539 class A13, class A14>
10540template <class TYPE>
10541inline
10542#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10543typename bsl::enable_if<
10544 !bsl::is_same<Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12,
10545 A13, A14>,
10546 typename bsl::remove_cvref<TYPE>::type>::value,
10547Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> >::type&
10548Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10549operator=(TYPE&& value)
10550#else
10551Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>&
10552Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10553operator=(bslmf::MovableRef<TYPE> value)
10554#endif
10555{
10556#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10557 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10558#else
10559 TYPE& lvalue = value;
10560 Imp::operator=(MoveUtil::move(lvalue));
10561#endif
10562
10563 return *this;
10564}
10565
10566template <class A1, class A2, class A3, class A4, class A5, class A6,
10567 class A7, class A8, class A9, class A10, class A11, class A12,
10568 class A13, class A14>
10569inline
10570Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>&
10571Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10572operator=(const Variant14& rhs)
10573{
10574 Imp::operator=(static_cast<const Imp&>(rhs));
10575 return *this;
10576}
10577
10578template <class A1, class A2, class A3, class A4, class A5, class A6,
10579 class A7, class A8, class A9, class A10, class A11, class A12,
10580 class A13, class A14>
10581inline
10582Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>&
10583Variant14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>::
10584operator=(bslmf::MovableRef<Variant14> rhs)
10585{
10586 Variant14& lvalue = rhs;
10587
10588 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10589 return *this;
10590}
10591
10592 // --------------------
10593 // class Variant15<...>
10594 // --------------------
10595
10596// CREATORS
10597template <class A1, class A2, class A3, class A4, class A5, class A6,
10598 class A7, class A8, class A9, class A10, class A11, class A12,
10599 class A13, class A14, class A15>
10600inline
10601Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10602Variant15()
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>
10609template <class TYPE_OR_ALLOCATOR>
10610inline
10611Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10612Variant15(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10613: Imp(valueOrAllocator)
10614{
10615}
10616
10617template <class A1, class A2, class A3, class A4, class A5, class A6,
10618 class A7, class A8, class A9, class A10, class A11, class A12,
10619 class A13, class A14, class A15>
10620template <class TYPE>
10621inline
10622Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10623Variant15(const TYPE& value, bslma::Allocator *basicAllocator)
10624: Imp(value, basicAllocator)
10625{
10626}
10627
10628template <class A1, class A2, class A3, class A4, class A5, class A6,
10629 class A7, class A8, class A9, class A10, class A11, class A12,
10630 class A13, class A14, class A15>
10631template <class TYPE>
10632inline
10633Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10634#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10635Variant15(TYPE&& value,
10636 typename bsl::enable_if<
10637 !bsl::is_same<
10638 SelfType,
10639 typename bsl::remove_const<
10640 typename bsl::remove_reference<TYPE>::type>::type>::value
10641 &&
10643 void>::type *)
10644: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10645#else
10646Variant15(bslmf::MovableRef<TYPE> value)
10647: Imp(MoveUtil::move(value))
10648#endif
10649{
10650}
10651
10652template <class A1, class A2, class A3, class A4, class A5, class A6,
10653 class A7, class A8, class A9, class A10, class A11, class A12,
10654 class A13, class A14, class A15>
10655template <class TYPE>
10656inline
10657Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10658#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10659Variant15(TYPE&& value,
10660 typename bsl::enable_if<
10661 !bsl::is_same<
10662 SelfType,
10663 typename bsl::remove_const<
10664 typename bsl::remove_reference<TYPE>::type>::type>::value,
10665 bslma::Allocator>::type *basicAllocator)
10666: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10667#else
10668Variant15(bslmf::MovableRef<TYPE> value,
10669 bslma::Allocator *basicAllocator)
10670: Imp(MoveUtil::move(value), basicAllocator)
10671#endif
10672{
10673}
10674
10675template <class A1, class A2, class A3, class A4, class A5, class A6,
10676 class A7, class A8, class A9, class A10, class A11, class A12,
10677 class A13, class A14, class A15>
10678inline
10679Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10680Variant15(const Variant15& original, bslma::Allocator *basicAllocator)
10681: Imp(static_cast<const Imp&>(original), basicAllocator)
10682{
10683}
10684
10685template <class A1, class A2, class A3, class A4, class A5, class A6,
10686 class A7, class A8, class A9, class A10, class A11, class A12,
10687 class A13, class A14, class A15>
10688inline
10689Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10690Variant15(bslmf::MovableRef<Variant15> original)
10691: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10692{
10693}
10694
10695template <class A1, class A2, class A3, class A4, class A5, class A6,
10696 class A7, class A8, class A9, class A10, class A11, class A12,
10697 class A13, class A14, class A15>
10698inline
10699Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10700Variant15(bslmf::MovableRef<Variant15> original,
10701 bslma::Allocator *basicAllocator)
10702: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10703 basicAllocator)
10704{
10705}
10706
10707// MANIPULATORS
10708template <class A1, class A2, class A3, class A4, class A5, class A6,
10709 class A7, class A8, class A9, class A10, class A11, class A12,
10710 class A13, class A14, class A15>
10711template <class TYPE>
10712inline
10713Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>&
10714Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10715operator=(const TYPE& value)
10716{
10717 Imp::operator=(value);
10718 return *this;
10719}
10720
10721template <class A1, class A2, class A3, class A4, class A5, class A6,
10722 class A7, class A8, class A9, class A10, class A11, class A12,
10723 class A13, class A14, class A15>
10724template <class TYPE>
10725inline
10726#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10727typename bsl::enable_if<
10728 !bsl::is_same<Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
10729 A12, A13, A14, A15>,
10730 typename bsl::remove_cvref<TYPE>::type>::value,
10731Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10732 A15> >::type&
10733Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10734operator=(TYPE&& value)
10735#else
10736Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>&
10737Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10738operator=(bslmf::MovableRef<TYPE> value)
10739#endif
10740{
10741#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10742 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10743#else
10744 TYPE& lvalue = value;
10745 Imp::operator=(MoveUtil::move(lvalue));
10746#endif
10747
10748 return *this;
10749}
10750
10751template <class A1, class A2, class A3, class A4, class A5, class A6,
10752 class A7, class A8, class A9, class A10, class A11, class A12,
10753 class A13, class A14, class A15>
10754inline
10755Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>&
10756Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10757operator=(const Variant15& 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>
10766inline
10767Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>&
10768Variant15<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>::
10769operator=(bslmf::MovableRef<Variant15> rhs)
10770{
10771 Variant15& lvalue = rhs;
10772
10773 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10774 return *this;
10775}
10776
10777 // --------------------
10778 // class Variant16<...>
10779 // --------------------
10780
10781// CREATORS
10782template <class A1, class A2, class A3, class A4, class A5, class A6,
10783 class A7, class A8, class A9, class A10, class A11, class A12,
10784 class A13, class A14, class A15, class A16>
10785inline
10786Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10787 A15, A16>::
10788Variant16()
10789{
10790}
10791
10792template <class A1, class A2, class A3, class A4, class A5, class A6,
10793 class A7, class A8, class A9, class A10, class A11, class A12,
10794 class A13, class A14, class A15, class A16>
10795template <class TYPE_OR_ALLOCATOR>
10796inline
10797Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10798 A15, A16>::
10799Variant16(const TYPE_OR_ALLOCATOR& valueOrAllocator)
10800: Imp(valueOrAllocator)
10801{
10802}
10803
10804template <class A1, class A2, class A3, class A4, class A5, class A6,
10805 class A7, class A8, class A9, class A10, class A11, class A12,
10806 class A13, class A14, class A15, class A16>
10807template <class TYPE>
10808inline
10809Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10810 A15, A16>::
10811Variant16(const TYPE& value, bslma::Allocator *basicAllocator)
10812: Imp(value, basicAllocator)
10813{
10814}
10815
10816template <class A1, class A2, class A3, class A4, class A5, class A6,
10817 class A7, class A8, class A9, class A10, class A11, class A12,
10818 class A13, class A14, class A15, class A16>
10819template <class TYPE>
10820inline
10821Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10822 A15, A16>::
10823#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10824Variant16(TYPE&& value,
10825 typename bsl::enable_if<
10826 !bsl::is_same<
10827 SelfType,
10828 typename bsl::remove_const<
10829 typename bsl::remove_reference<TYPE>::type>::type>::value
10830 &&
10832 void>::type *)
10833: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
10834#else
10835Variant16(bslmf::MovableRef<TYPE> value)
10836: Imp(MoveUtil::move(value))
10837#endif
10838{
10839}
10840
10841template <class A1, class A2, class A3, class A4, class A5, class A6,
10842 class A7, class A8, class A9, class A10, class A11, class A12,
10843 class A13, class A14, class A15, class A16>
10844template <class TYPE>
10845inline
10846Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10847 A15, A16>::
10848#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10849Variant16(TYPE&& value,
10850 typename bsl::enable_if<
10851 !bsl::is_same<
10852 SelfType,
10853 typename bsl::remove_const<
10854 typename bsl::remove_reference<TYPE>::type>::type>::value,
10855 bslma::Allocator>::type *basicAllocator)
10856: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
10857#else
10858Variant16(bslmf::MovableRef<TYPE> value,
10859 bslma::Allocator *basicAllocator)
10860: Imp(MoveUtil::move(value), basicAllocator)
10861#endif
10862{
10863}
10864
10865template <class A1, class A2, class A3, class A4, class A5, class A6,
10866 class A7, class A8, class A9, class A10, class A11, class A12,
10867 class A13, class A14, class A15, class A16>
10868inline
10869Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10870 A15, A16>::
10871Variant16(const Variant16& original, bslma::Allocator *basicAllocator)
10872: Imp(static_cast<const Imp&>(original), basicAllocator)
10873{
10874}
10875
10876template <class A1, class A2, class A3, class A4, class A5, class A6,
10877 class A7, class A8, class A9, class A10, class A11, class A12,
10878 class A13, class A14, class A15, class A16>
10879inline
10880Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10881 A15, A16>::
10882Variant16(bslmf::MovableRef<Variant16> original)
10883: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
10884{
10885}
10886
10887template <class A1, class A2, class A3, class A4, class A5, class A6,
10888 class A7, class A8, class A9, class A10, class A11, class A12,
10889 class A13, class A14, class A15, class A16>
10890inline
10891Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10892 A15, A16>::
10893Variant16(bslmf::MovableRef<Variant16> original,
10894 bslma::Allocator *basicAllocator)
10895: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
10896 basicAllocator)
10897{
10898}
10899
10900// MANIPULATORS
10901template <class A1, class A2, class A3, class A4, class A5, class A6,
10902 class A7, class A8, class A9, class A10, class A11, class A12,
10903 class A13, class A14, class A15, class A16>
10904template <class TYPE>
10905inline
10906Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10907 A15, A16>&
10908Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10909 A15, A16>::
10910operator=(const TYPE& value)
10911{
10912 Imp::operator=(value);
10913 return *this;
10914}
10915
10916template <class A1, class A2, class A3, class A4, class A5, class A6,
10917 class A7, class A8, class A9, class A10, class A11, class A12,
10918 class A13, class A14, class A15, class A16>
10919template <class TYPE>
10920inline
10921#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10922typename bsl::enable_if<
10923 !bsl::is_same<Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
10924 A12, A13, A14, A15, A16>,
10925 typename bsl::remove_cvref<TYPE>::type>::value,
10926Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10927 A16> >::type&
10928Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10929 A16>::operator=(TYPE&& value)
10930#else
10931Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10932 A16>&
10933Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
10934 A16>::operator=(bslmf::MovableRef<TYPE> value)
10935#endif
10936{
10937#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
10938 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
10939#else
10940 TYPE& lvalue = value;
10941 Imp::operator=(MoveUtil::move(lvalue));
10942#endif
10943
10944 return *this;
10945}
10946
10947template <class A1, class A2, class A3, class A4, class A5, class A6,
10948 class A7, class A8, class A9, class A10, class A11, class A12,
10949 class A13, class A14, class A15, class A16>
10950inline
10951Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10952 A15, A16>&
10953Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10954 A15, A16>::
10955operator=(const Variant16& rhs)
10956{
10957 Imp::operator=(static_cast<const Imp&>(rhs));
10958 return *this;
10959}
10960
10961template <class A1, class A2, class A3, class A4, class A5, class A6,
10962 class A7, class A8, class A9, class A10, class A11, class A12,
10963 class A13, class A14, class A15, class A16>
10964inline
10965Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10966 A15, A16>&
10967Variant16<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10968 A15, A16>::
10970{
10971 Variant16& lvalue = rhs;
10972
10973 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
10974 return *this;
10975}
10976
10977 // --------------------
10978 // class Variant17<...>
10979 // --------------------
10980
10981// CREATORS
10982template <class A1, class A2, class A3, class A4, class A5, class A6,
10983 class A7, class A8, class A9, class A10, class A11, class A12,
10984 class A13, class A14, class A15, class A16, class A17>
10985inline
10986Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10987 A15, A16, A17>::
10988Variant17()
10989{
10990}
10991
10992template <class A1, class A2, class A3, class A4, class A5, class A6,
10993 class A7, class A8, class A9, class A10, class A11, class A12,
10994 class A13, class A14, class A15, class A16, class A17>
10995template <class TYPE_OR_ALLOCATOR>
10996inline
10997Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
10998 A15, A16, A17>::
10999Variant17(const TYPE_OR_ALLOCATOR& valueOrAllocator)
11000: Imp(valueOrAllocator)
11001{
11002}
11003
11004template <class A1, class A2, class A3, class A4, class A5, class A6,
11005 class A7, class A8, class A9, class A10, class A11, class A12,
11006 class A13, class A14, class A15, class A16, class A17>
11007template <class TYPE>
11008inline
11009Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11010 A15, A16, A17>::
11011Variant17(const TYPE& value, bslma::Allocator *basicAllocator)
11012: Imp(value, basicAllocator)
11013{
11014}
11015
11016template <class A1, class A2, class A3, class A4, class A5, class A6,
11017 class A7, class A8, class A9, class A10, class A11, class A12,
11018 class A13, class A14, class A15, class A16, class A17>
11019template <class TYPE>
11020inline
11021Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11022 A15, A16, A17>::
11023#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11024Variant17(TYPE&& value,
11025 typename bsl::enable_if<
11026 !bsl::is_same<
11027 SelfType,
11028 typename bsl::remove_const<
11029 typename bsl::remove_reference<TYPE>::type>::type>::value
11030 &&
11032 void>::type *)
11033: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
11034#else
11035Variant17(bslmf::MovableRef<TYPE> value)
11036: Imp(MoveUtil::move(value))
11037#endif
11038{
11039}
11040
11041template <class A1, class A2, class A3, class A4, class A5, class A6,
11042 class A7, class A8, class A9, class A10, class A11, class A12,
11043 class A13, class A14, class A15, class A16, class A17>
11044template <class TYPE>
11045inline
11046Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11047 A15, A16, A17>::
11048#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11049Variant17(TYPE&& value,
11050 typename bsl::enable_if<
11051 !bsl::is_same<
11052 SelfType,
11053 typename bsl::remove_const<
11054 typename bsl::remove_reference<TYPE>::type>::type>::value,
11055 bslma::Allocator>::type *basicAllocator)
11056: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
11057#else
11058Variant17(bslmf::MovableRef<TYPE> value,
11059 bslma::Allocator *basicAllocator)
11060: Imp(MoveUtil::move(value), basicAllocator)
11061#endif
11062{
11063}
11064
11065template <class A1, class A2, class A3, class A4, class A5, class A6,
11066 class A7, class A8, class A9, class A10, class A11, class A12,
11067 class A13, class A14, class A15, class A16, class A17>
11068inline
11069Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11070 A15, A16, A17>::
11071Variant17(const Variant17& original, bslma::Allocator *basicAllocator)
11072: Imp(static_cast<const Imp&>(original), basicAllocator)
11073{
11074}
11075
11076template <class A1, class A2, class A3, class A4, class A5, class A6,
11077 class A7, class A8, class A9, class A10, class A11, class A12,
11078 class A13, class A14, class A15, class A16, class A17>
11079inline
11080Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11081 A15, A16, A17>::
11082Variant17(bslmf::MovableRef<Variant17> original)
11083: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
11084{
11085}
11086
11087template <class A1, class A2, class A3, class A4, class A5, class A6,
11088 class A7, class A8, class A9, class A10, class A11, class A12,
11089 class A13, class A14, class A15, class A16, class A17>
11090inline
11091Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11092 A15, A16, A17>::
11093Variant17(bslmf::MovableRef<Variant17> original,
11094 bslma::Allocator *basicAllocator)
11095: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
11096 basicAllocator)
11097{
11098}
11099
11100// MANIPULATORS
11101template <class A1, class A2, class A3, class A4, class A5, class A6,
11102 class A7, class A8, class A9, class A10, class A11, class A12,
11103 class A13, class A14, class A15, class A16, class A17>
11104template <class TYPE>
11105inline
11106Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11107 A15, A16, A17>&
11108Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11109 A15, A16, A17>::
11110operator=(const TYPE& value)
11111{
11112 Imp::operator=(value);
11113 return *this;
11114}
11115
11116template <class A1, class A2, class A3, class A4, class A5, class A6,
11117 class A7, class A8, class A9, class A10, class A11, class A12,
11118 class A13, class A14, class A15, class A16, class A17>
11119template <class TYPE>
11120inline
11121#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11122typename bsl::enable_if<
11123 !bsl::is_same<Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11,
11124 A12, A13, A14, A15, A16, A17>,
11125 typename bsl::remove_cvref<TYPE>::type>::value,
11126Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11127 A16, A17> >::type&
11128Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11129 A16, A17>::operator=(TYPE&& value)
11130#else
11131Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11132 A16, A17>&
11133Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11134 A16, A17>::operator=(bslmf::MovableRef<TYPE> value)
11135#endif
11136{
11137#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11138 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
11139#else
11140 TYPE& lvalue = value;
11141 Imp::operator=(MoveUtil::move(lvalue));
11142#endif
11143
11144 return *this;
11145}
11146
11147template <class A1, class A2, class A3, class A4, class A5, class A6,
11148 class A7, class A8, class A9, class A10, class A11, class A12,
11149 class A13, class A14, class A15, class A16, class A17>
11150inline
11151Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11152 A15, A16, A17>&
11153Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11154 A15, A16, A17>::
11155operator=(const Variant17& rhs)
11156{
11157 Imp::operator=(static_cast<const Imp&>(rhs));
11158 return *this;
11159}
11160
11161template <class A1, class A2, class A3, class A4, class A5, class A6,
11162 class A7, class A8, class A9, class A10, class A11, class A12,
11163 class A13, class A14, class A15, class A16, class A17>
11164inline
11165Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11166 A15, A16, A17>&
11167Variant17<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11168 A15, A16, A17>::
11170{
11171 Variant17& lvalue = rhs;
11172
11173 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
11174 return *this;
11175}
11176
11177 // --------------------
11178 // class Variant18<...>
11179 // --------------------
11180
11181// CREATORS
11182template <class A1, class A2, class A3, class A4, class A5, class A6,
11183 class A7, class A8, class A9, class A10, class A11, class A12,
11184 class A13, class A14, class A15, class A16, class A17, class A18>
11185inline
11186Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11187 A15, A16, A17, A18>::
11188Variant18()
11189{
11190}
11191
11192template <class A1, class A2, class A3, class A4, class A5, class A6,
11193 class A7, class A8, class A9, class A10, class A11, class A12,
11194 class A13, class A14, class A15, class A16, class A17, class A18>
11195template <class TYPE_OR_ALLOCATOR>
11196inline
11197Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11198 A15, A16, A17, A18>::
11199Variant18(const TYPE_OR_ALLOCATOR& valueOrAllocator)
11200: Imp(valueOrAllocator)
11201{
11202}
11203
11204template <class A1, class A2, class A3, class A4, class A5, class A6,
11205 class A7, class A8, class A9, class A10, class A11, class A12,
11206 class A13, class A14, class A15, class A16, class A17, class A18>
11207template <class TYPE>
11208inline
11209Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11210 A15, A16, A17, A18>::
11211Variant18(const TYPE& value, bslma::Allocator *basicAllocator)
11212: Imp(value, basicAllocator)
11213{
11214}
11215
11216template <class A1, class A2, class A3, class A4, class A5, class A6,
11217 class A7, class A8, class A9, class A10, class A11, class A12,
11218 class A13, class A14, class A15, class A16, class A17, class A18>
11219template <class TYPE>
11220inline
11221Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11222 A15, A16, A17, A18>::
11223#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11224Variant18(TYPE&& value,
11225 typename bsl::enable_if<
11226 !bsl::is_same<
11227 SelfType,
11228 typename bsl::remove_const<
11229 typename bsl::remove_reference<TYPE>::type>::type>::value
11230 &&
11232 void>::type *)
11233: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
11234#else
11235Variant18(bslmf::MovableRef<TYPE> value)
11236: Imp(MoveUtil::move(value))
11237#endif
11238{
11239}
11240
11241template <class A1, class A2, class A3, class A4, class A5, class A6,
11242 class A7, class A8, class A9, class A10, class A11, class A12,
11243 class A13, class A14, class A15, class A16, class A17, class A18>
11244template <class TYPE>
11245inline
11246Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11247 A15, A16, A17, A18>::
11248#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11249Variant18(TYPE&& value,
11250 typename bsl::enable_if<
11251 !bsl::is_same<
11252 SelfType,
11253 typename bsl::remove_const<
11254 typename bsl::remove_reference<TYPE>::type>::type>::value,
11255 bslma::Allocator>::type *basicAllocator)
11256: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
11257#else
11258Variant18(bslmf::MovableRef<TYPE> value,
11259 bslma::Allocator *basicAllocator)
11260: Imp(MoveUtil::move(value), basicAllocator)
11261#endif
11262{
11263}
11264
11265template <class A1, class A2, class A3, class A4, class A5, class A6,
11266 class A7, class A8, class A9, class A10, class A11, class A12,
11267 class A13, class A14, class A15, class A16, class A17, class A18>
11268inline
11269Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11270 A15, A16, A17, A18>::
11271Variant18(const Variant18& original, bslma::Allocator *basicAllocator)
11272: Imp(static_cast<const Imp&>(original), basicAllocator)
11273{
11274}
11275
11276template <class A1, class A2, class A3, class A4, class A5, class A6,
11277 class A7, class A8, class A9, class A10, class A11, class A12,
11278 class A13, class A14, class A15, class A16, class A17, class A18>
11279inline
11280Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11281 A15, A16, A17, A18>::
11282Variant18(bslmf::MovableRef<Variant18> original)
11283: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
11284{
11285}
11286
11287template <class A1, class A2, class A3, class A4, class A5, class A6,
11288 class A7, class A8, class A9, class A10, class A11, class A12,
11289 class A13, class A14, class A15, class A16, class A17, class A18>
11290inline
11291Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11292 A15, A16, A17, A18>::
11293Variant18(bslmf::MovableRef<Variant18> original,
11294 bslma::Allocator *basicAllocator)
11295: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
11296 basicAllocator)
11297{
11298}
11299
11300// MANIPULATORS
11301template <class A1, class A2, class A3, class A4, class A5, class A6,
11302 class A7, class A8, class A9, class A10, class A11, class A12,
11303 class A13, class A14, class A15, class A16, class A17, class A18>
11304template <class TYPE>
11305inline
11306Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11307 A15, A16, A17, A18>&
11308Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11309 A15, A16, A17, A18>::
11310operator=(const TYPE& value)
11311{
11312 Imp::operator=(value);
11313 return *this;
11314}
11315
11316template <class A1, class A2, class A3, class A4, class A5, class A6,
11317 class A7, class A8, class A9, class A10, class A11, class A12,
11318 class A13, class A14, class A15, class A16, class A17, class A18>
11319template <class TYPE>
11320inline
11321#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11322typename bsl::enable_if<
11323 !bsl::is_same<Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
11324 A11, A12, A13, A14, A15, A16, A17, A18>,
11325 typename bsl::remove_cvref<TYPE>::type>::value,
11326Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11327 A16, A17, A18> >::type&
11328Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11329 A16, A17, A18>::operator=(TYPE&& value)
11330#else
11331Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11332 A16, A17, A18>&
11333Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11334 A16, A17, A18>::operator=(bslmf::MovableRef<TYPE> value)
11335#endif
11336{
11337#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11338 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
11339#else
11340 TYPE& lvalue = value;
11341 Imp::operator=(MoveUtil::move(lvalue));
11342#endif
11343
11344 return *this;
11345}
11346
11347template <class A1, class A2, class A3, class A4, class A5, class A6,
11348 class A7, class A8, class A9, class A10, class A11, class A12,
11349 class A13, class A14, class A15, class A16, class A17, class A18>
11350inline
11351Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11352 A15, A16, A17, A18>&
11353Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11354 A15, A16, A17, A18>::
11355operator=(const Variant18& rhs)
11356{
11357 Imp::operator=(static_cast<const Imp&>(rhs));
11358 return *this;
11359}
11360
11361template <class A1, class A2, class A3, class A4, class A5, class A6,
11362 class A7, class A8, class A9, class A10, class A11, class A12,
11363 class A13, class A14, class A15, class A16, class A17, class A18>
11364inline
11365Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11366 A15, A16, A17, A18>&
11367Variant18<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11368 A15, A16, A17, A18>::
11370{
11371 Variant18& lvalue = rhs;
11372
11373 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
11374 return *this;
11375}
11376
11377 // --------------------
11378 // class Variant19<...>
11379 // --------------------
11380
11381// CREATORS
11382template <class A1, class A2, class A3, class A4, class A5, class A6,
11383 class A7, class A8, class A9, class A10, class A11, class A12,
11384 class A13, class A14, class A15, class A16, class A17, class A18,
11385 class A19>
11386inline
11387Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11388 A15, A16, A17, A18, A19>::
11389Variant19()
11390{
11391}
11392
11393template <class A1, class A2, class A3, class A4, class A5, class A6,
11394 class A7, class A8, class A9, class A10, class A11, class A12,
11395 class A13, class A14, class A15, class A16, class A17, class A18,
11396 class A19>
11397template <class TYPE_OR_ALLOCATOR>
11398inline
11399Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11400 A15, A16, A17, A18, A19>::
11401Variant19(const TYPE_OR_ALLOCATOR& valueOrAllocator)
11402: Imp(valueOrAllocator)
11403{
11404}
11405
11406template <class A1, class A2, class A3, class A4, class A5, class A6,
11407 class A7, class A8, class A9, class A10, class A11, class A12,
11408 class A13, class A14, class A15, class A16, class A17, class A18,
11409 class A19>
11410template <class TYPE>
11411inline
11412Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11413 A15, A16, A17, A18, A19>::
11414Variant19(const TYPE& value, bslma::Allocator *basicAllocator)
11415: Imp(value, basicAllocator)
11416{
11417}
11418
11419template <class A1, class A2, class A3, class A4, class A5, class A6,
11420 class A7, class A8, class A9, class A10, class A11, class A12,
11421 class A13, class A14, class A15, class A16, class A17, class A18,
11422 class A19>
11423template <class TYPE>
11424inline
11425Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11426 A15, A16, A17, A18, A19>::
11427#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11428Variant19(TYPE&& value,
11429 typename bsl::enable_if<
11430 !bsl::is_same<
11431 SelfType,
11432 typename bsl::remove_const<
11433 typename bsl::remove_reference<TYPE>::type>::type>::value
11434 &&
11436 void>::type *)
11437: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value))
11438#else
11439Variant19(bslmf::MovableRef<TYPE> value)
11440: Imp(MoveUtil::move(value))
11441#endif
11442{
11443}
11444
11445template <class A1, class A2, class A3, class A4, class A5, class A6,
11446 class A7, class A8, class A9, class A10, class A11, class A12,
11447 class A13, class A14, class A15, class A16, class A17, class A18,
11448 class A19>
11449template <class TYPE>
11450inline
11451Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11452 A15, A16, A17, A18, A19>::
11453#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11454Variant19(TYPE&& value,
11455 typename bsl::enable_if<
11456 !bsl::is_same<
11457 SelfType,
11458 typename bsl::remove_const<
11459 typename bsl::remove_reference<TYPE>::type>::type>::value,
11460 bslma::Allocator>::type *basicAllocator)
11461: Imp(BSLS_COMPILERFEATURES_FORWARD(TYPE, value), basicAllocator)
11462#else
11463Variant19(bslmf::MovableRef<TYPE> value,
11464 bslma::Allocator *basicAllocator)
11465: Imp(MoveUtil::move(value), basicAllocator)
11466#endif
11467{
11468}
11469
11470template <class A1, class A2, class A3, class A4, class A5, class A6,
11471 class A7, class A8, class A9, class A10, class A11, class A12,
11472 class A13, class A14, class A15, class A16, class A17, class A18,
11473 class A19>
11474inline
11475Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11476 A15, A16, A17, A18, A19>::
11477Variant19(const Variant19& original, bslma::Allocator *basicAllocator)
11478: Imp(static_cast<const Imp&>(original), basicAllocator)
11479{
11480}
11481
11482template <class A1, class A2, class A3, class A4, class A5, class A6,
11483 class A7, class A8, class A9, class A10, class A11, class A12,
11484 class A13, class A14, class A15, class A16, class A17, class A18,
11485 class A19>
11486inline
11487Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11488 A15, A16, A17, A18, A19>::
11489Variant19(bslmf::MovableRef<Variant19> original)
11490: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))))
11491{
11492}
11493
11494template <class A1, class A2, class A3, class A4, class A5, class A6,
11495 class A7, class A8, class A9, class A10, class A11, class A12,
11496 class A13, class A14, class A15, class A16, class A17, class A18,
11497 class A19>
11498inline
11499Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11500 A15, A16, A17, A18, A19>::
11501Variant19(bslmf::MovableRef<Variant19> original,
11502 bslma::Allocator *basicAllocator)
11503: Imp(MoveUtil::move(static_cast<Imp&>(MoveUtil::access(original))),
11504 basicAllocator)
11505{
11506}
11507
11508// MANIPULATORS
11509template <class A1, class A2, class A3, class A4, class A5, class A6,
11510 class A7, class A8, class A9, class A10, class A11, class A12,
11511 class A13, class A14, class A15, class A16, class A17, class A18,
11512 class A19>
11513template <class TYPE>
11514inline
11515Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11516 A15, A16, A17, A18, A19>&
11517Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11518 A15, A16, A17, A18, A19>::
11519operator=(const TYPE& value)
11520{
11521 Imp::operator=(value);
11522 return *this;
11523}
11524
11525template <class A1, class A2, class A3, class A4, class A5, class A6,
11526 class A7, class A8, class A9, class A10, class A11, class A12,
11527 class A13, class A14, class A15, class A16, class A17, class A18,
11528 class A19>
11529template <class TYPE>
11530inline
11531#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11532typename bsl::enable_if<
11533 !bsl::is_same<Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
11534 A11, A12, A13, A14, A15, A16, A17, A18, A19>,
11535 typename bsl::remove_cvref<TYPE>::type>::value,
11536Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11537 A16, A17, A18, A19> >::type&
11538Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11539 A16, A17, A18, A19>::operator=(TYPE&& value)
11540#else
11541Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11542 A16, A17, A18, A19>&
11543Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15,
11544 A16, A17, A18, A19>::operator=(bslmf::MovableRef<TYPE> value)
11545#endif
11546{
11547#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
11548 Imp::operator=(BSLS_COMPILERFEATURES_FORWARD(TYPE, value));
11549#else
11550 TYPE& lvalue = value;
11551 Imp::operator=(MoveUtil::move(lvalue));
11552#endif
11553
11554 return *this;
11555}
11556
11557template <class A1, class A2, class A3, class A4, class A5, class A6,
11558 class A7, class A8, class A9, class A10, class A11, class A12,
11559 class A13, class A14, class A15, class A16, class A17, class A18,
11560 class A19>
11561inline
11562Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11563 A15, A16, A17, A18, A19>&
11564Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11565 A15, A16, A17, A18, A19>::
11566operator=(const Variant19& rhs)
11567{
11568 Imp::operator=(static_cast<const Imp&>(rhs));
11569 return *this;
11570}
11571
11572template <class A1, class A2, class A3, class A4, class A5, class A6,
11573 class A7, class A8, class A9, class A10, class A11, class A12,
11574 class A13, class A14, class A15, class A16, class A17, class A18,
11575 class A19>
11576inline
11577Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11578 A15, A16, A17, A18, A19>&
11579Variant19<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
11580 A15, A16, A17, A18, A19>::
11582{
11583 Variant19& lvalue = rhs;
11584
11585 Imp::operator=(MoveUtil::move(static_cast<Imp&>(lvalue)));
11586 return *this;
11587}
11588
11589} // close package namespace
11590
11591
11592#else // if ! defined(DEFINED_BDLB_VARIANT_H)
11593# error Not valid except when included from bdlb_variant.h
11594#endif // ! defined(COMPILING_BDLB_VARIANT_H)
11595
11596#endif // ! defined(INCLUDED_BDLB_VARIANT_CPP03)
11597
11598// ----------------------------------------------------------------------------
11599// Copyright 2015 Bloomberg Finance L.P.
11600//
11601// Licensed under the Apache License, Version 2.0 (the "License");
11602// you may not use this file except in compliance with the License.
11603// You may obtain a copy of the License at
11604//
11605// http://www.apache.org/licenses/LICENSE-2.0
11606//
11607// Unless required by applicable law or agreed to in writing, software
11608// distributed under the License is distributed on an "AS IS" BASIS,
11609// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11610// See the License for the specific language governing permissions and
11611// limitations under the License.
11612// ----------------------------- END-OF-FILE ----------------------------------
11613
11614/** @} */
11615/** @} */
11616/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
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
friend class VariantImp
Definition bdlb_variant.h:896
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
bslma::Allocator * getAllocator() const
Definition bdlb_variant.h:6546
bslmf::TypeListTypeOf< 17, TYPES >::TypeOrDefault Type17
Definition bdlb_variant.h:964
friend class VariantImp
Definition bdlb_variant.h:1006
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
void reset()
Definition bdlb_variant.h:7592
STREAM & bdexStreamIn(STREAM &stream, int version)
DEPRECATED: Do not use.
Definition bdlb_variant.h:7781
bool is() const
Definition bdlb_variant.h:7725
~VariantImp()
Definition bdlb_variant.h:7336
int typeIndex() const
Definition bdlb_variant.h:7766
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)
Definition bdlb_variant.h:1544
TYPE & createInPlace(ARGS &&... arguments)
Definition bdlb_variant.h:7574
VariantImp & operator=(const TYPE &value)
STREAM & bdexStreamOut(STREAM &stream, int version) const
DEPRECATED: Do not use.
Definition bdlb_variant.h:7819
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
bool isUnset() const
Definition bdlb_variant.h:7732
TYPE & the()
Definition bdlb_variant.h:7637
VariantImp & assign(const TYPE &value)
void swap(VariantImp &other)
Definition bdlb_variant.h:7602
VariantImp & assignTo(const SOURCE_TYPE &value)
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlb_variant.h:7739
RESULT_TYPE operator()(ARGUMENT_TYPE &argument)
Definition bdlb_variant.h:6570
Variant_RawVisitorHelper(VISITOR *visitor)
Definition bdlb_variant.h:6559
Variant & operator=(const TYPE &value)
Variant()
Definition bdlb_variant.h:8043
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_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
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
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
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
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
static Variant_ReturnValueHelper_YesType match(typename bsl::remove_reference< typename T::ResultType >::type *)
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