BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl::Variant_ImpUtil Struct Reference

#include <bslstl_variant.h>

Detailed Description

This struct provides a namespace for utility functions used implement various operations on bsl::variant.

See bslstl_variant

Static Public Member Functions

template<class t_HEAD , class... t_TAIL>
static bsl::variant< t_HEAD, t_TAIL... > & asVariant (bsl::variant< t_HEAD, t_TAIL... > &v)
 
template<class t_HEAD , class... t_TAIL>
static const bsl::variant< t_HEAD, t_TAIL... > & asVariant (const bsl::variant< t_HEAD, t_TAIL... > &v)
 
template<class t_RET , size_t t_INDEX, class t_VARIANT >
static t_RET & get (t_VARIANT &variant)
 
template<class t_RET , size_t t_INDEX, class t_VARIANT >
static t_RET & get (const t_VARIANT &variant)
 
template<class t_RET , class t_VISITOR , class t_VARIANT >
static t_RET visit (t_VISITOR &visitor, t_VARIANT &variant)
 
template<class t_RET , class t_VISITOR , class t_VARIANT >
static t_RET visit (t_VISITOR &visitor, const t_VARIANT &variant)
 
template<class t_RET , class t_VISITOR , class t_VARIANT >
static t_RET moveVisit (t_VISITOR &visitor, t_VARIANT &variant)
 
template<class t_RET , class t_VISITOR , class t_VARIANT >
static t_RET visitId (t_VISITOR &visitor, t_VARIANT &variant)
 
template<class t_RET , class t_VISITOR , class t_VARIANT >
static t_RET visitId (t_VISITOR &visitor, const t_VARIANT &variant)
 
template<class t_RET , size_t t_INDEX, class t_VARIANT >
static t_RET & unsafeGet (t_VARIANT &variant)
 
template<class t_RET , size_t t_INDEX, class t_VARIANT >
static t_RET & unsafeGet (const t_VARIANT &variant)
 
template<class t_TYPE , class t_VARIANT >
static t_TYPE & unsafeGet (t_VARIANT &obj)
 
template<class t_TYPE , class t_VARIANT >
static const t_TYPE & unsafeGet (const t_VARIANT &obj)
 
template<class t_RET , class t_VARIANT_UNION >
static t_RET & getAlternative (bsl::in_place_index_t< 0 >, t_VARIANT_UNION &variantUnion) BSLS_KEYWORD_NOEXCEPT
 
template<class t_RET , size_t t_INDEX, class t_VARIANT_UNION >
static t_RET & getAlternative (bsl::in_place_index_t< t_INDEX >, t_VARIANT_UNION &variantUnion) BSLS_KEYWORD_NOEXCEPT
 
template<class t_VARIANT >
static bool Equal (const t_VARIANT &lhs, const t_VARIANT &rhs)
 
template<class t_VARIANT >
static bool NotEqual (const t_VARIANT &lhs, const t_VARIANT &rhs)
 
template<class t_VARIANT >
static bool LessThan (const t_VARIANT &lhs, const t_VARIANT &rhs)
 
template<class t_VARIANT >
static bool GreaterThan (const t_VARIANT &lhs, const t_VARIANT &rhs)
 
template<class t_VARIANT >
static bool LessOrEqual (const t_VARIANT &lhs, const t_VARIANT &rhs)
 
template<class t_VARIANT >
static bool GreaterOrEqual (const t_VARIANT &lhs, const t_VARIANT &rhs)
 

Member Function Documentation

◆ asVariant() [1/2]

template<class t_HEAD , class... t_TAIL>
static bsl::variant< t_HEAD, t_TAIL... > & bslstl::Variant_ImpUtil::asVariant ( bsl::variant< t_HEAD, t_TAIL... > &  v)
inlinestatic

Returns a reference to the specified v.

◆ asVariant() [2/2]

template<class t_HEAD , class... t_TAIL>
static const bsl::variant< t_HEAD, t_TAIL... > & bslstl::Variant_ImpUtil::asVariant ( const bsl::variant< t_HEAD, t_TAIL... > &  v)
inlinestatic

◆ Equal()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::Equal ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

◆ get() [1/2]

template<class t_RET , size_t t_INDEX, class t_VARIANT >
t_RET & bslstl::Variant_ImpUtil::get ( const t_VARIANT &  variant)
static

◆ get() [2/2]

template<class t_RET , size_t t_INDEX, class t_VARIANT >
t_RET & bslstl::Variant_ImpUtil::get ( t_VARIANT &  variant)
static

Return a reference to the alternative with index (template parameter) t_INDEX in the specified variant. If t_INDEX is not the index of the currently active alternative, throw an exception of type bad_variant_access.

Note
Note that the return type must be explicitly specified.

◆ getAlternative() [1/2]

template<class t_RET , class t_VARIANT_UNION >
t_RET & bslstl::Variant_ImpUtil::getAlternative ( bsl::in_place_index_t< 0 >  ,
t_VARIANT_UNION &  variantUnion 
)
static

Return a reference to the object managed by the first member of the specified variantUnion. It is the base case for the overload of getAlternative below. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

◆ getAlternative() [2/2]

template<class t_RET , size_t t_INDEX, class t_VARIANT_UNION >
t_RET & bslstl::Variant_ImpUtil::getAlternative ( bsl::in_place_index_t< t_INDEX >  ,
t_VARIANT_UNION &  variantUnion 
)
static

Return a reference to the alternative with index (template parameter) t_INDEX in the specified variantUnion by recursively unravelling variantUnion until the desired alternative is at the head. t_INDEX shall be a valid alternative index.

Precondition
The behavior is undefined unless the alternative with index t_INDEX has the same type as the active alternative of variantUnion. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

◆ GreaterOrEqual()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::GreaterOrEqual ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

Return the result of comparing the specified lhs with the specified rhs.

Precondition
The behavior is undefined unless both lhs and rhs hold the same alternative.
Note
Note that the capitalization of the names of these methods has been chosen so that their definitions can be generated using a macro.

◆ GreaterThan()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::GreaterThan ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

◆ LessOrEqual()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::LessOrEqual ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

◆ LessThan()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::LessThan ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

◆ moveVisit()

template<class t_RET , class t_VISITOR , class t_VARIANT >
t_RET bslstl::Variant_ImpUtil::moveVisit ( t_VISITOR &  visitor,
t_VARIANT &  variant 
)
static

Invoke the specified visitor on a bslmf::MovableRef referring to the active alternative of the specified variant, implicitly converting the return type to the explicitly specified (template parameter) t_RET.

Precondition
The behavior is undefined if variant does not hold a value. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

◆ NotEqual()

template<class t_VARIANT >
static bool bslstl::Variant_ImpUtil::NotEqual ( const t_VARIANT &  lhs,
const t_VARIANT &  rhs 
)
static

◆ unsafeGet() [1/4]

template<class t_TYPE , class t_VARIANT >
const t_TYPE & bslstl::Variant_ImpUtil::unsafeGet ( const t_VARIANT &  obj)
static

◆ unsafeGet() [2/4]

template<class t_RET , size_t t_INDEX, class t_VARIANT >
t_RET & bslstl::Variant_ImpUtil::unsafeGet ( const t_VARIANT &  variant)
static

◆ unsafeGet() [3/4]

template<class t_TYPE , class t_VARIANT >
t_TYPE & bslstl::Variant_ImpUtil::unsafeGet ( t_VARIANT &  obj)
static

Return a reference to const-qualified (template parameter) t_TYPE to the first alternative of the specified obj that has type t_TYPE, regardless of whether that is the active alternative.

Precondition
The behavior is undefined unless the active alternative of variant is of type t_TYPE. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

◆ unsafeGet() [4/4]

template<class t_RET , size_t t_INDEX, class t_VARIANT >
t_RET & bslstl::Variant_ImpUtil::unsafeGet ( t_VARIANT &  variant)
static

Return a reference to type (template parameter) 't_RET' to the alternative at (template parameter) 't_INDEX' in the specified 'variant', regardless of whether that is the active alternative.

Precondition
The behavior is undefined unless the active alternative of 'variant' has the same type as the alternative with index 't_INDEX'.
Note
Note that the return type must be explicitly specified.

◆ visit() [1/2]

template<class t_RET , class t_VISITOR , class t_VARIANT >
t_RET bslstl::Variant_ImpUtil::visit ( t_VISITOR &  visitor,
const t_VARIANT &  variant 
)
static

◆ visit() [2/2]

template<class t_RET , class t_VISITOR , class t_VARIANT >
t_RET bslstl::Variant_ImpUtil::visit ( t_VISITOR &  visitor,
t_VARIANT &  variant 
)
static

Invoke the specified visitor on the active alternative of the specified variant, implicitly converting the return type to the explicitly specified (template parameter) t_RET.

Precondition
The behavior is undefined if variant does not hold a value. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

◆ visitId() [1/2]

template<class t_RET , class t_VISITOR , class t_VARIANT >
t_RET bslstl::Variant_ImpUtil::visitId ( t_VISITOR &  visitor,
const t_VARIANT &  variant 
)
static

◆ visitId() [2/2]

template<class t_RET , class t_VISITOR , class t_VARIANT >
t_RET bslstl::Variant_ImpUtil::visitId ( t_VISITOR &  visitor,
t_VARIANT &  variant 
)
static

Invoke the specified visitor with a bsl::in_place_index_t<t_INDEX> tag (where t_INDEX is the index of the first alternative that has the same type as the active alternative of the specified variant) and the active alternative of variant, implicitly converting the return type to the explicitly specified (template parameter) t_RET.

Precondition
The behavior is undefined if variant does not hold a value. This function does not require friend access to Variant and has been added to Variant_ImpUtil for the purposes of avoiding free functions.

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