11#ifndef INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
12#define INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
63#ifdef COMPILING_BSLTF_STDTESTALLOCATOR_H
81struct StdTestAllocatorConfiguration {
110class StdTestAllocatorConfigurationGuard {
116 StdTestAllocatorConfigurationGuard(
117 const StdTestAllocatorConfigurationGuard&);
118 StdTestAllocatorConfigurationGuard& operator=(
119 const StdTestAllocatorConfigurationGuard&);
148class StdTestAllocator {
174 template <
class BDE_OTHER_TYPE>
178 typedef StdTestAllocator<BDE_OTHER_TYPE>
other;
195 template <
class BDE_OTHER_TYPE>
222#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
225#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
226#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
228#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A
229#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
232#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 0
233 template <
class ELEMENT_TYPE>
237#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 1
238 template <
class ELEMENT_TYPE,
class Args_01>
243#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 2
244 template <
class ELEMENT_TYPE,
class Args_01,
251#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 3
252 template <
class ELEMENT_TYPE,
class Args_01,
261#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 4
262 template <
class ELEMENT_TYPE,
class Args_01,
273#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 5
274 template <
class ELEMENT_TYPE,
class Args_01,
287#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 6
288 template <
class ELEMENT_TYPE,
class Args_01,
303#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 7
304 template <
class ELEMENT_TYPE,
class Args_01,
321#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 8
322 template <
class ELEMENT_TYPE,
class Args_01,
341#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 9
342 template <
class ELEMENT_TYPE,
class Args_01,
363#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 10
364 template <
class ELEMENT_TYPE,
class Args_01,
387#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 11
388 template <
class ELEMENT_TYPE,
class Args_01,
413#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 12
414 template <
class ELEMENT_TYPE,
class Args_01,
441#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 13
442 template <
class ELEMENT_TYPE,
class Args_01,
471#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 14
472 template <
class ELEMENT_TYPE,
class Args_01,
507 template <
class ELEMENT_TYPE,
class... Args>
515 template <
class ELEMENT_TYPE>
542class StdTestAllocator<void> {
564 template <
class BDE_OTHER_TYPE>
568 typedef StdTestAllocator<BDE_OTHER_TYPE>
other;
585 template <
class BDE_OTHER_TYPE>
601template <
class TYPE1,
class TYPE2>
602bool operator==(
const StdTestAllocator<TYPE1>& lhs,
603 const StdTestAllocator<TYPE2>& rhs);
606template <
class TYPE1,
class TYPE2>
607bool operator!=(
const StdTestAllocator<TYPE1>& lhs,
608 const StdTestAllocator<TYPE2>& rhs);
619struct StdTestAllocator_CommonUtil {
630 static size_t maxSize(
size_t elementSize);
643StdTestAllocatorConfigurationGuard::StdTestAllocatorConfigurationGuard(
645: d_original_p(StdTestAllocatorConfiguration::delegateAllocator())
649 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(temporaryAllocator);
653StdTestAllocatorConfigurationGuard::~StdTestAllocatorConfigurationGuard()
657 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(d_original_p);
667StdTestAllocator<TYPE>::StdTestAllocator()
672template <
class BDE_OTHER_TYPE>
673StdTestAllocator<TYPE>::StdTestAllocator(
674 const StdTestAllocator<BDE_OTHER_TYPE>&)
681typename StdTestAllocator<TYPE>::pointer
682StdTestAllocator<TYPE>::allocate(
typename StdTestAllocator<TYPE>::size_type
685 if (numElements > this->max_size()) {
686 BloombergLP::bsls::BslExceptionUtil::throwBadAlloc();
690 static_cast<pointer
>(StdTestAllocatorConfiguration::delegateAllocator()->
696void StdTestAllocator<TYPE>::deallocate(pointer address, size_type)
698 StdTestAllocatorConfiguration::delegateAllocator()->deallocate(address);
701#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
704#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
705#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
707#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B
708#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
710#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 0
712template <
class ELEMENT_TYPE>
714StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address)
716 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
721#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 1
723template <
class ELEMENT_TYPE,
class Args_01>
725StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
728 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
733#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 2
735template <
class ELEMENT_TYPE,
class Args_01,
738StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
742 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
748#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 3
750template <
class ELEMENT_TYPE,
class Args_01,
754StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
759 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
766#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 4
768template <
class ELEMENT_TYPE,
class Args_01,
773StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
779 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
787#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 5
789template <
class ELEMENT_TYPE,
class Args_01,
795StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
802 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
811#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 6
813template <
class ELEMENT_TYPE,
class Args_01,
820StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
828 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
838#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 7
840template <
class ELEMENT_TYPE,
class Args_01,
848StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
857 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
868#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 8
870template <
class ELEMENT_TYPE,
class Args_01,
879StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
889 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
901#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 9
903template <
class ELEMENT_TYPE,
class Args_01,
913StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
924 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
937#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 10
939template <
class ELEMENT_TYPE,
class Args_01,
950StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
962 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
976#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 11
978template <
class ELEMENT_TYPE,
class Args_01,
990StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1003 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1018#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 12
1019template <
class TYPE>
1020template <
class ELEMENT_TYPE,
class Args_01,
1033StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1047 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1063#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 13
1064template <
class TYPE>
1065template <
class ELEMENT_TYPE,
class Args_01,
1079StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1094 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1111#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 14
1112template <
class TYPE>
1113template <
class ELEMENT_TYPE,
class Args_01,
1128StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1144 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1165template <
class TYPE>
1166template <
class ELEMENT_TYPE,
class... Args>
1168StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1171 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1177template <
class TYPE>
1178template <
class ELEMENT_TYPE>
1180void StdTestAllocator<TYPE>::destroy(ELEMENT_TYPE *address)
1182 address->~ELEMENT_TYPE();
1185template <
class TYPE>
1187typename StdTestAllocator<TYPE>::pointer
1188StdTestAllocator<TYPE>::address(reference
object)
const
1193template <
class TYPE>
1195typename StdTestAllocator<TYPE>::const_pointer
1196StdTestAllocator<TYPE>::address(const_reference
object)
const
1201template <
class TYPE>
1203typename StdTestAllocator<TYPE>::size_type
1204StdTestAllocator<TYPE>::max_size()
const
1206 return StdTestAllocator_CommonUtil::maxSize(
sizeof(TYPE));
1215StdTestAllocator<void>::StdTestAllocator()
1219template <
class BDE_OTHER_TYPE>
1220StdTestAllocator<void>::StdTestAllocator(
1221 const StdTestAllocator<BDE_OTHER_TYPE>&)
1226template <
class TYPE1,
class TYPE2>
1234template <
class TYPE1,
class TYPE2>
1246# error Not valid except when included from bsltf_stdtestallocator.h
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
Definition bslma_allocator.h:545
std::size_t size_type
Definition bslma_allocator.h:593
~StdTestAllocatorConfigurationGuard()
Definition bsltf_stdtestallocator.h:503
Definition bsltf_stdtestallocator.h:275
const TYPE * const_pointer
Definition bsltf_stdtestallocator.h:289
pointer address(reference object) const
Return the address providing modifiable access to object.
Definition bsltf_stdtestallocator.h:573
pointer allocate(size_type numElements)
bsls::Types::UintPtr size_type
Definition bsltf_stdtestallocator.h:286
StdTestAllocator()
Create a StdTestAllocator object.
Definition bsltf_stdtestallocator.h:517
bsls::Types::IntPtr difference_type
Definition bsltf_stdtestallocator.h:287
const TYPE & const_reference
Definition bsltf_stdtestallocator.h:291
TYPE * pointer
Definition bsltf_stdtestallocator.h:288
void construct(ELEMENT_TYPE *address, Args &&... arguments)
Definition bsltf_stdtestallocator.h:555
size_type max_size() const
Definition bsltf_stdtestallocator.h:589
TYPE value_type
Definition bsltf_stdtestallocator.h:292
void deallocate(pointer address, size_type numElements=1)
Definition bsltf_stdtestallocator.h:546
TYPE & reference
Definition bsltf_stdtestallocator.h:290
void destroy(ELEMENT_TYPE *address)
Definition bsltf_stdtestallocator.h:565
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#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)
Definition bsltf_allocargumenttype.h:92
Definition bslma_isstdallocator.h:202
std::size_t UintPtr
Definition bsls_types.h:128
std::ptrdiff_t IntPtr
Definition bsls_types.h:132
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:312
static void setDelegateAllocatorRaw(bslma::Allocator *basicAllocator)
static bslma::Allocator * delegateAllocator()
StdTestAllocator< BDE_OTHER_TYPE > other
Definition bsltf_stdtestallocator.h:305
static size_t maxSize(size_t elementSize)