BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma::ConstructionUtil_ConstructionTrait< TARGET_TYPE, ALLOCATOR > Struct Template Reference

#include <bslma_constructionutil.h>

Public Types

enum  { value }
 
typedef bsl::integral_constant< int, valuetype
 

Detailed Description

template<class TARGET_TYPE, class ALLOCATOR>
struct bslma::ConstructionUtil_ConstructionTrait< TARGET_TYPE, ALLOCATOR >

Metafunction yielding one of the following three value constants:

: e_USES_ALLOCATOR_ARG_T_TRAITS TARGET_TYPE supports an allocator as : its second constructor argument, after : bsl::allocator_arg. : : e_USES_ALLOCATOR_TRAITS TARGET_TYPE supports an allocator as : its last constructor argument. : : e_NIL_TRAITS TARGET_TYPE does not support an : allocator and/or ALLOCATOR is void* : int, or any other non-allocator : scalar. The allocator argument to : construct will be ignored.

ALLOCATOR is compatible with an AA TARGET_TYPE if ALLOCATOR is convertible to the allocator type expected by TARGET_TYPE's constructors. There are three special cases of incompatible ALLOCATOR types:

  1. If TARGET_TYPE expects an allocator of type bslma::Allocator * this metafunction yields either e_USES_ALLOCATOR_ARG_T_TRAITS or e_USES_ALLOCATOR_TRAITS, even if ALLOCATOR is not compatible with TARGET_TYPE. The construct method will attempt to extract the bslma::Allocator * from the allocator using its mechanism accessor. If there is no mechanism accessor, compilation will fail.
  2. Otherwise, if bslma::UsesBslmaAllocator<TARGET_TYPE>::value is true, this metafunction yields either e_USES_ALLOCATOR_ARG_T_TRAITS or e_USES_ALLOCATOR_TRAITS, even if ALLOCATOR is not compatible with TARGET_TYPE, resulting in a compilation error within construct.
  3. Otherwise, if ALLOCATOR is incompatible with TARGET_TYPE, then ALLOCATOR is ignored and this metafunction yields e_NIL_TRAITS, as though TARGET_TYPE were not AA.

The first two special cases allow mixing and matching between bsl::allocator and bslma::Allocator * in both directions, but will fail for other allocator types. The failure is desirable to prevent code accidentally passing an incorrect allocator type.

The third special case is inconsistent with the other two so as to allow third-party classes that use third-party allocators to be treated as non-AA within containers that use BDE allocators.

This metafunction also yields a type of 'bsl::integral_constant<value, int>'.

Member Typedef Documentation

◆ type

template<class TARGET_TYPE , class ALLOCATOR >
typedef bsl::integral_constant<int, value> bslma::ConstructionUtil_ConstructionTrait< TARGET_TYPE, ALLOCATOR >::type

Member Enumeration Documentation

◆ anonymous enum

template<class TARGET_TYPE , class ALLOCATOR >
anonymous enum
Enumerator
value 

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