BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::Variant2< A1, A2 > Class Template Reference

#include <bdlb_variant.h>

Inheritance diagram for bdlb::Variant2< A1, A2 >:
bdlb::VariantImp< bslmf::TypeList2< A1, A2 >::ListType >

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION_IF (Variant2, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (Variant2, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (Variant2, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
 
 BSLMF_NESTED_TRAIT_DECLARATION (Variant2, HasPrintMethod)
 
 Variant2 ()
 
template<class TYPE_OR_ALLOCATOR >
 Variant2 (const TYPE_OR_ALLOCATOR &valueOrAllocator)
 
template<class TYPE >
 Variant2 (const TYPE &value, bslma::Allocator *basicAllocator)
 
template<class TYPE >
 Variant2 (bslmf::MovableRef< TYPE > value)
 
template<class TYPE >
 Variant2 (bslmf::MovableRef< TYPE > value, bslma::Allocator *basicAllocator)
 
 Variant2 (const Variant2 &original, bslma::Allocator *basicAllocator=0)
 
 Variant2 (bslmf::MovableRef< Variant2 > original)
 
 Variant2 (bslmf::MovableRef< Variant2 > original, bslma::Allocator *basicAllocator)
 
template<class TYPE >
Variant2operator= (const TYPE &value)
 
template<class TYPE >
Variant2operator= (bslmf::MovableRef< TYPE > value)
 
Variant2operator= (const Variant2 &rhs)
 
Variant2operator= (bslmf::MovableRef< Variant2 > rhs)
 
template<class TYPE >
Variant2< A1, A2 > & operator= (const TYPE &value)
 
template<class TYPE >
Variant2< A1, A2 > & operator= (bslmf::MovableRef< TYPE > value)
 
- Public Member Functions inherited from bdlb::VariantImp< bslmf::TypeList2< A1, A2 >::ListType >
 BSLMF_NESTED_TRAIT_DECLARATION_IF (VariantImp, bslma::UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (VariantImp, bslmf::IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (VariantImp, bslmf::IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE)
 
 BSLMF_NESTED_TRAIT_DECLARATION (VariantImp, HasPrintMethod)
 
 VariantImp ()
 
 VariantImp (const TYPE_OR_ALLOCATOR &valueOrAllocator)
 
 VariantImp (const TYPE &value, bslma::Allocator *basicAllocator)
 
 VariantImp (bslmf::MovableRef< TYPE > value)
 
 VariantImp (bslmf::MovableRef< TYPE > value, bslma::Allocator *basicAllocator)
 
 VariantImp (const VariantImp &original, bslma::Allocator *basicAllocator=0)
 
 VariantImp (bslmf::MovableRef< VariantImp > original)
 
 VariantImp (bslmf::MovableRef< VariantImp > original, bslma::Allocator *basicAllocator)
 
 ~VariantImp ()
 
VariantImpoperator= (const TYPE &value)
 
VariantImpoperator= (bslmf::MovableRef< TYPE > value)
 
VariantImpoperator= (const VariantImp &rhs)
 
VariantImpoperator= (bslmf::MovableRef< VariantImp > rhs)
 
VariantImp< bslmf::TypeList2< A1, A2 >::ListType > & operator= (const TYPE &value)
 
VariantImp< bslmf::TypeList2< A1, A2 >::ListType > & operator= (bslmf::MovableRef< TYPE > value)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (const VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (VISITOR &visitor, const TYPE &defaultValue)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (const VISITOR &visitor, const TYPE &defaultValue)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (const VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (VISITOR &visitor, const TYPE &defaultValue)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (const VISITOR &visitor, const TYPE &defaultValue)
 
RET_TYPE apply (VISITOR &visitor)
 
RET_TYPE apply (const VISITOR &visitor)
 
RET_TYPE apply (VISITOR &visitor, const TYPE &defaultValue)
 
RET_TYPE apply (const VISITOR &visitor, const TYPE &defaultValue)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (const VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (VISITOR &visitor, const TYPE &defaultValue) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type apply (const VISITOR &visitor, const TYPE &defaultValue) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (const VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (VISITOR &visitor, const TYPE &defaultValue) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type apply (const VISITOR &visitor, const TYPE &defaultValue) const
 
RET_TYPE apply (VISITOR &visitor) const
 
RET_TYPE apply (const VISITOR &visitor) const
 
RET_TYPE apply (VISITOR &visitor, const TYPE &defaultValue) const
 
RET_TYPE apply (const VISITOR &visitor, const TYPE &defaultValue) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw (VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw (const VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw (VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw (const VISITOR &visitor)
 
RET_TYPE applyRaw (VISITOR &visitor)
 
RET_TYPE applyRaw (const VISITOR &visitor)
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw (VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==1, typenameVISITOR::ResultType >::type applyRaw (const VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw (VISITOR &visitor) const
 
bsl::enable_if< Variant_ReturnValueHelper< VISITOR >::value==0, void >::type applyRaw (const VISITOR &visitor) const
 
RET_TYPE applyRaw (VISITOR &visitor) const
 
RET_TYPE applyRaw (const VISITOR &visitor) const
 
VariantImpassign (const TYPE &value)
 
VariantImpassign (bslmf::MovableRef< TYPE > value)
 
VariantImp< bslmf::TypeList2< A1, A2 >::ListType > & assign (const TYPE &value)
 
VariantImp< bslmf::TypeList2< A1, A2 >::ListType > & assign (bslmf::MovableRef< TYPE > value)
 
VariantImpassignTo (const SOURCE_TYPE &value)
 
VariantImp< bslmf::TypeList2< A1, A2 >::ListType > & assignTo (const SOURCE_TYPE &value)
 
TYPE & createInPlace (ARGS &&... arguments)
 
void reset ()
 
void swap (VariantImp &other)
 
TYPE & the ()
 
const TYPE & the () const
 
bool is () const
 
bool isUnset () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 
int typeIndex () const
 
const bsl::type_info & typeInfo () const
 
STREAM & bdexStreamIn (STREAM &stream, int version)
 DEPRECATED: Do not use.
 
int maxSupportedBdexVersion () const
 DEPRECATED: Do not use.
 
STREAM & bdexStreamOut (STREAM &stream, int version) const
 DEPRECATED: Do not use.
 

Detailed Description

template<class A1, class A2>
class bdlb::Variant2< A1, A2 >

This class is a "specialization" of Variant for a fixed number (2) of types. Its 2 template arguments must all be specified (none are defaulted to bslmf::Nil). It provides the same functionality as Variant<A1, A2>.

Constructor & Destructor Documentation

◆ Variant2() [1/8]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::Variant2 ( )
inline

Create a variant object in the unset state that uses the currently installed default allocator to supply memory.

◆ Variant2() [2/8]

template<class A1 , class A2 >
template<class TYPE_OR_ALLOCATOR >
bdlb::Variant2< A1, A2 >::Variant2 ( const TYPE_OR_ALLOCATOR &  valueOrAllocator)
inlineexplicit

Create a variant object with the specified valueOrAllocator that can be either a value of a type that the variant can hold or an allocator to supply memory. If valueOrAllocator is not a bslma::Allocator *, then the variant will hold the value and type of valueOrAllocator, and use the currently installed default allocator to supply memory. Otherwise, the variant will be unset and use valueOrAllocator to supply memory. TYPE_OR_ALLOCATOR must be the same as one of the types that this variant can hold or be convertible to bslma::Allocator *. Note that this parameterized constructor is defined instead of two constructors (one taking a bslma::Allocator * and the other not) because template parameter arguments are always a better match than derived-to-base conversion (a concrete allocator pointer converted to bslma::Allocator *).

◆ Variant2() [3/8]

template<class A1 , class A2 >
template<class TYPE >
bdlb::Variant2< A1, A2 >::Variant2 ( const TYPE &  value,
bslma::Allocator basicAllocator 
)
inline

Create a variant object having the specified value of template parameter TYPE and that uses the specified basicAllocator to supply memory. If basicAllocator is 0, the currently installed default allocator is used. TYPE must be the same as one of the types that this variant can hold.

◆ Variant2() [4/8]

template<class A1 , class A2 >
template<class TYPE >
bdlb::Variant2< A1, A2 >::Variant2 ( bslmf::MovableRef< TYPE >  value)
inlineexplicit

◆ Variant2() [5/8]

template<class A1 , class A2 >
template<class TYPE >
bdlb::Variant2< A1, A2 >::Variant2 ( bslmf::MovableRef< TYPE >  value,
bslma::Allocator basicAllocator 
)
inline

◆ Variant2() [6/8]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::Variant2 ( const Variant2< A1, A2 > &  original,
bslma::Allocator basicAllocator = 0 
)
inline

Create a variant object having the type and value of the specified original variant. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ Variant2() [7/8]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::Variant2 ( bslmf::MovableRef< Variant2< A1, A2 > >  original)
inline

Create a variant object having the type and value of the specified original object by moving the contents of original to the newly-created object. The allocator associated with original (if any) is propagated for use in the newly-created object. original is left in a valid but unspecified state.

◆ Variant2() [8/8]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::Variant2 ( bslmf::MovableRef< Variant2< A1, A2 > >  original,
bslma::Allocator basicAllocator 
)
inline

Create a variant object having the type and value of the specified original object that uses the specified basicAllocator to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The contents of original are moved to the newly-created object with original left in a valid but unspecified state.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::BSLMF_NESTED_TRAIT_DECLARATION ( Variant2< A1, A2 >  ,
HasPrintMethod   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [1/3]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( Variant2< A1, A2 >  ,
bslma::UsesBslmaAllocator  ,
Traits::k_VARIANT_USES_BSLMA_ALLOCATOR   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [2/3]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( Variant2< A1, A2 >  ,
bslmf::IsBitwiseCopyable  ,
Traits::k_VARIANT_IS_BITWISE_COPYABLE   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [3/3]

template<class A1 , class A2 >
bdlb::Variant2< A1, A2 >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( Variant2< A1, A2 >  ,
bslmf::IsBitwiseMoveable  ,
Traits::k_VARIANT_IS_BITWISE_MOVEABLE   
)

◆ operator=() [1/6]

template<class A1 , class A2 >
template<class TYPE >
Variant2 & bdlb::Variant2< A1, A2 >::operator= ( bslmf::MovableRef< TYPE >  value)

◆ operator=() [2/6]

template<class A1 , class A2 >
template<class TYPE >
Variant2< A1, A2 > & bdlb::Variant2< A1, A2 >::operator= ( bslmf::MovableRef< TYPE >  value)
inline

◆ operator=() [3/6]

template<class A1 , class A2 >
Variant2< A1, A2 > & bdlb::Variant2< A1, A2 >::operator= ( bslmf::MovableRef< Variant2< A1, A2 > >  rhs)
inline

Assign to this object the type and value currently held by the specified rhs object, and return a reference providing modifiable access to this object. The value currently held by this variant (if any) is destroyed if that value's type is not the same as the type held by the rhs object. The contents of rhs are either move-inserted into or move-assigned to this object with rhs left in a valid but unspecified state.

◆ operator=() [4/6]

template<class A1 , class A2 >
template<class TYPE >
Variant2 & bdlb::Variant2< A1, A2 >::operator= ( const TYPE &  value)

Assign to this object the specified value of template parameter TYPE, and return a reference providing modifiable access to this object. The value currently held by this variant (if any) is destroyed if that value's type is not the same as TYPE. TYPE must be the same as one of the types that this variant can hold.

◆ operator=() [5/6]

template<class A1 , class A2 >
template<class TYPE >
Variant2< A1, A2 > & bdlb::Variant2< A1, A2 >::operator= ( const TYPE &  value)
inline

◆ operator=() [6/6]

template<class A1 , class A2 >
Variant2< A1, A2 > & bdlb::Variant2< A1, A2 >::operator= ( const Variant2< A1, A2 > &  rhs)
inline

Assign to this object the type and value currently held by the specified rhs object, and return a reference providing modifiable access to this object. The value currently held by this variant (if any) is destroyed if that value's type is not the same as the type held by the rhs object.


The documentation for this class was generated from the following file: