11#ifndef INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
12#define INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
63#ifdef COMPILING_BSLTF_STDTESTALLOCATOR_H
78struct StdTestAllocatorConfiguration {
106class StdTestAllocatorConfigurationGuard {
112 StdTestAllocatorConfigurationGuard(
113 const StdTestAllocatorConfigurationGuard&);
114 StdTestAllocatorConfigurationGuard& operator=(
115 const StdTestAllocatorConfigurationGuard&);
144class StdTestAllocator {
169 template <
class BDE_OTHER_TYPE>
173 typedef StdTestAllocator<BDE_OTHER_TYPE>
other;
189 template <
class BDE_OTHER_TYPE>
214#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
217#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
218#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
220#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A
221#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
224#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 0
225 template <
class ELEMENT_TYPE>
229#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 1
230 template <
class ELEMENT_TYPE,
class Args_01>
235#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 2
236 template <
class ELEMENT_TYPE,
class Args_01,
243#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 3
244 template <
class ELEMENT_TYPE,
class Args_01,
253#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 4
254 template <
class ELEMENT_TYPE,
class Args_01,
265#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 5
266 template <
class ELEMENT_TYPE,
class Args_01,
279#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 6
280 template <
class ELEMENT_TYPE,
class Args_01,
295#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 7
296 template <
class ELEMENT_TYPE,
class Args_01,
313#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 8
314 template <
class ELEMENT_TYPE,
class Args_01,
333#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 9
334 template <
class ELEMENT_TYPE,
class Args_01,
355#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 10
356 template <
class ELEMENT_TYPE,
class Args_01,
379#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 11
380 template <
class ELEMENT_TYPE,
class Args_01,
405#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 12
406 template <
class ELEMENT_TYPE,
class Args_01,
433#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 13
434 template <
class ELEMENT_TYPE,
class Args_01,
463#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 14
464 template <
class ELEMENT_TYPE,
class Args_01,
499 template <
class ELEMENT_TYPE,
class... Args>
507 template <
class ELEMENT_TYPE>
533class StdTestAllocator<void> {
554 template <
class BDE_OTHER_TYPE>
558 typedef StdTestAllocator<BDE_OTHER_TYPE>
other;
574 template <
class BDE_OTHER_TYPE>
590template <
class TYPE1,
class TYPE2>
591bool operator==(
const StdTestAllocator<TYPE1>& lhs,
592 const StdTestAllocator<TYPE2>& rhs);
595template <
class TYPE1,
class TYPE2>
596bool operator!=(
const StdTestAllocator<TYPE1>& lhs,
597 const StdTestAllocator<TYPE2>& rhs);
606struct StdTestAllocator_CommonUtil {
616 static size_t maxSize(
size_t elementSize);
629StdTestAllocatorConfigurationGuard::StdTestAllocatorConfigurationGuard(
631: d_original_p(StdTestAllocatorConfiguration::delegateAllocator())
635 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(temporaryAllocator);
639StdTestAllocatorConfigurationGuard::~StdTestAllocatorConfigurationGuard()
643 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(d_original_p);
653StdTestAllocator<TYPE>::StdTestAllocator()
658template <
class BDE_OTHER_TYPE>
659StdTestAllocator<TYPE>::StdTestAllocator(
660 const StdTestAllocator<BDE_OTHER_TYPE>&)
667typename StdTestAllocator<TYPE>::pointer
668StdTestAllocator<TYPE>::allocate(
typename StdTestAllocator<TYPE>::size_type
671 if (numElements > this->max_size()) {
672 BloombergLP::bsls::BslExceptionUtil::throwBadAlloc();
676 static_cast<pointer
>(StdTestAllocatorConfiguration::delegateAllocator()->
682void StdTestAllocator<TYPE>::deallocate(pointer address, size_type)
684 StdTestAllocatorConfiguration::delegateAllocator()->deallocate(address);
687#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
690#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
691#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
693#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B
694#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
696#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 0
698template <
class ELEMENT_TYPE>
700StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address)
702 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
707#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 1
709template <
class ELEMENT_TYPE,
class Args_01>
711StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
714 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
719#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 2
721template <
class ELEMENT_TYPE,
class Args_01,
724StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
728 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
734#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 3
736template <
class ELEMENT_TYPE,
class Args_01,
740StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
745 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
752#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 4
754template <
class ELEMENT_TYPE,
class Args_01,
759StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
765 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
773#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 5
775template <
class ELEMENT_TYPE,
class Args_01,
781StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
788 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
797#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 6
799template <
class ELEMENT_TYPE,
class Args_01,
806StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
814 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
824#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 7
826template <
class ELEMENT_TYPE,
class Args_01,
834StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
843 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
854#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 8
856template <
class ELEMENT_TYPE,
class Args_01,
865StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
875 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
887#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 9
889template <
class ELEMENT_TYPE,
class Args_01,
899StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
910 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
923#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 10
925template <
class ELEMENT_TYPE,
class Args_01,
936StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
948 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
962#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 11
964template <
class ELEMENT_TYPE,
class Args_01,
976StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
989 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1004#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 12
1005template <
class TYPE>
1006template <
class ELEMENT_TYPE,
class Args_01,
1019StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1033 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1049#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 13
1050template <
class TYPE>
1051template <
class ELEMENT_TYPE,
class Args_01,
1065StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1080 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1097#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 14
1098template <
class TYPE>
1099template <
class ELEMENT_TYPE,
class Args_01,
1114StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1130 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1151template <
class TYPE>
1152template <
class ELEMENT_TYPE,
class... Args>
1154StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1157 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
1163template <
class TYPE>
1164template <
class ELEMENT_TYPE>
1166void StdTestAllocator<TYPE>::destroy(ELEMENT_TYPE *address)
1168 address->~ELEMENT_TYPE();
1171template <
class TYPE>
1173typename StdTestAllocator<TYPE>::pointer
1174StdTestAllocator<TYPE>::address(reference
object)
const
1179template <
class TYPE>
1181typename StdTestAllocator<TYPE>::const_pointer
1182StdTestAllocator<TYPE>::address(const_reference
object)
const
1187template <
class TYPE>
1189typename StdTestAllocator<TYPE>::size_type
1190StdTestAllocator<TYPE>::max_size()
const
1192 return StdTestAllocator_CommonUtil::maxSize(
sizeof(TYPE));
1201StdTestAllocator<void>::StdTestAllocator()
1205template <
class BDE_OTHER_TYPE>
1206StdTestAllocator<void>::StdTestAllocator(
1207 const StdTestAllocator<BDE_OTHER_TYPE>&)
1212template <
class TYPE1,
class TYPE2>
1220template <
class TYPE1,
class TYPE2>
1232# 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:457
std::size_t size_type
Definition bslma_allocator.h:499
~StdTestAllocatorConfigurationGuard()
Definition bsltf_stdtestallocator.h:484
Definition bsltf_stdtestallocator.h:267
const TYPE * const_pointer
Definition bsltf_stdtestallocator.h:281
pointer address(reference object) const
Return the address providing modifiable access to object.
Definition bsltf_stdtestallocator.h:554
pointer allocate(size_type numElements)
bsls::Types::UintPtr size_type
Definition bsltf_stdtestallocator.h:278
StdTestAllocator()
Create a StdTestAllocator object.
Definition bsltf_stdtestallocator.h:498
bsls::Types::IntPtr difference_type
Definition bsltf_stdtestallocator.h:279
const TYPE & const_reference
Definition bsltf_stdtestallocator.h:283
TYPE * pointer
Definition bsltf_stdtestallocator.h:280
void construct(ELEMENT_TYPE *address, Args &&... arguments)
Definition bsltf_stdtestallocator.h:536
size_type max_size() const
Definition bsltf_stdtestallocator.h:570
TYPE value_type
Definition bsltf_stdtestallocator.h:284
void deallocate(pointer address, size_type numElements=1)
Definition bsltf_stdtestallocator.h:527
TYPE & reference
Definition bsltf_stdtestallocator.h:282
void destroy(ELEMENT_TYPE *address)
Definition bsltf_stdtestallocator.h:546
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
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:201
std::size_t UintPtr
Definition bsls_types.h:126
std::ptrdiff_t IntPtr
Definition bsls_types.h:130
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:305
static void setDelegateAllocatorRaw(bslma::Allocator *basicAllocator)
static bslma::Allocator * delegateAllocator()
StdTestAllocator< BDE_OTHER_TYPE > other
Definition bsltf_stdtestallocator.h:296
static size_t maxSize(size_t elementSize)