|
BDE 4.14.0 Production release
|
Provide a meta-function to determine if a type uses an allocator.
bsl::uses_allocatorThis component defines a meta-function, bsl::uses_allocator, that may be used to query whether a given type uses a given allocator type.
bsl::uses_allocator meets the requirements of the uses_allocator template defined in the C++11 standard [allocator.uses.trait], in addition to providing a welcome availability in both C++03 and C++11 compilation environments.
A type T uses an allocator type A if A has a nested alias named allocator_type and A is convertible to allocator_type (as defined in the bslmf_isconvertible component). If a type T uses an allocator type A, then T has a constructor that takes either 1) allocator_arg_t as a first argument and A as a second argument, or 2) A as the last argument. Alternatively, the uses_allocator template may be specialized for a type T that does not have a nested alias named allocator_type, where T can be constructed with A as detailed above.
Note that the template variable uses_allocator_v is defined in the C++17 standard as an inline variable. If the current compiler supports the inline variable C++17 compiler feature, bsl::uses_allocator_v is defined as an inline constexpr bool variable. Otherwise, if the compiler supports the variable templates C++14 compiler feature, bsl::uses_allocator_v is defined as a non-inline constexpr bool variable. See BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES and BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES macros in bsls_compilerfeatures component for details.
In this section we show intended use of this component.
TBD: finish up usage example, add to test driver.