8#ifndef INCLUDED_BSLSTL_SHAREDPTRALLOCATEINPLACEREP
9#define INCLUDED_BSLSTL_SHAREDPTRALLOCATEINPLACEREP
76#include <bslscm_version.h>
110template <
class TYPE,
class ALLOCATOR>
115 template rebind_traits<SharedPtrAllocateInplaceRep>
214template <class TYPE, class ALLOCATOR>
216 : public BloombergLP::
bslma::SharedPtrRep {
221 template rebind_traits<SharedPtrArrayAllocateInplaceRep>
233 char *d_allocated_ptr_p;
246 static size_t offset_of_first_element();
272 const
element_type *get_pointer_to_first_element() const;
286 static
size_t alloc_size(
size_t numElements);
347template <class TYPE, class ALLOCATOR>
351: d_allocator(basicAllocator)
357template <
class TYPE,
class ALLOCATOR>
365template <
class TYPE,
class ALLOCATOR>
367SharedPtrAllocateInplaceRep<TYPE, ALLOCATOR> *
372 ReboundTraits::allocate(basicAllocator, 1);
378template <
class TYPE,
class ALLOCATOR>
382 ReboundTraits::destroy(d_allocator,
ptr());
385template <
class TYPE,
class ALLOCATOR>
390 this->d_allocator.~ReboundAllocator();
391 ReboundTraits::deallocate(alloc,
this, 1);
394template <
class TYPE,
class ALLOCATOR>
402template <
class TYPE,
class ALLOCATOR>
410template <
class TYPE,
class ALLOCATOR>
415 return const_cast<void *
>(
static_cast<const void *
>(
416 const_cast<const TYPE *
>(d_instance.
address())));
425template <
class TYPE,
class ALLOCATOR>
431: d_allocator(basicAllocator)
433, d_allocated_ptr_p(allocatedPtr)
439template <
class TYPE,
class ALLOCATOR>
440SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR>::
441~SharedPtrArrayAllocateInplaceRep()
447template <
class TYPE,
class ALLOCATOR>
450SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR>::offset_of_first_element()
452 typedef SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR> ThisType;
456 k_ALIGNMENT_MASK = ~(k_ALIGNMENT - 1)
462 return (
sizeof(ThisType) + k_ALIGNMENT - 1) & k_ALIGNMENT_MASK;
466template <
class TYPE,
class ALLOCATOR>
475 return ThisType::offset_of_first_element() +
477 (
sizeof(ThisType::element_type) * numElements);
480template <
class TYPE,
class ALLOCATOR>
490 template rebind_traits<char> CharATraits;
494 k_ALIGNMENT_MASK = ~(k_ALIGNMENT - 1)
498 typename CharATraits::allocator_type charAlloc(basicAllocator);
500 CharATraits::allocate(charAlloc, alloc_size(numElements));
518template <
class TYPE,
class ALLOCATOR>
525 return reinterpret_cast<element_type *
>(
526 reinterpret_cast<char *
>(
this) + offset_of_first_element());
530template <
class TYPE,
class ALLOCATOR>
535 template rebind_traits<element_type> ElementTraits;
537 typename ElementTraits::allocator_type elementAlloc(d_allocator);
541 for (
size_t i = 0; i < d_size; ++i, --pN) {
542 ElementTraits::destroy(elementAlloc, pN);
546template <
class TYPE,
class ALLOCATOR>
551 template rebind_traits<char> CharATraits;
552 typename CharATraits::allocator_type charAlloc(d_allocator);
554 this->d_allocator.~ReboundAllocator();
555 CharATraits::deallocate(charAlloc, d_allocated_ptr_p, alloc_size(d_size));
558template <
class TYPE,
class ALLOCATOR>
567template <
class TYPE,
class ALLOCATOR>
574 return reinterpret_cast<const element_type *
>(
575 reinterpret_cast<const char *
>(
this) + offset_of_first_element());
578template <
class TYPE,
class ALLOCATOR>
583 return get_pointer_to_first_element();
587template <
class TYPE,
class ALLOCATOR>
592 return const_cast<void *
>(
593 static_cast<const void *
>(
594 get_pointer_to_first_element()));
605template <
class TYPE,
class ALLOCATOR>
611template <
class TYPE,
class ALLOCATOR>
613 bslstl::SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR> >
Definition bslstl_sharedptrallocateinplacerep.h:111
static SharedPtrAllocateInplaceRep * makeRep(ReboundAllocator basicAllocator)
Definition bslstl_sharedptrallocateinplacerep.h:368
void * getDeleter(const std::type_info &type) BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:397
ReboundTraits::allocator_type ReboundAllocator
Definition bslstl_sharedptrallocateinplacerep.h:120
TYPE * ptr()
Definition bslstl_sharedptrallocateinplacerep.h:404
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:413
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:387
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:380
Definition bslstl_sharedptrallocateinplacerep.h:216
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:532
element_type * ptr()
Definition bslstl_sharedptrallocateinplacerep.h:581
bsl::remove_extent< TYPE >::type element_type
Definition bslstl_sharedptrallocateinplacerep.h:226
ReboundTraits::allocator_type ReboundAllocator
Definition bslstl_sharedptrallocateinplacerep.h:227
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:590
static size_t alloc_size(size_t numElements)
Definition bslstl_sharedptrallocateinplacerep.h:469
static SharedPtrArrayAllocateInplaceRep * makeRep(ReboundAllocator basicAllocator, size_t numElements)
Definition bslstl_sharedptrallocateinplacerep.h:483
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:548
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition balxml_encoderoptions.h:68
Definition bslstl_algorithm.h:82
Definition bdldfp_decimal.h:5188
Definition bslma_allocatortraits.h:1061
Definition bslmf_integralconstant.h:244
Definition bslmf_isarray.h:168
t_TYPE type
Definition bslmf_removeextent.h:132
Definition bslma_usesbslmaallocator.h:343
Definition bsls_alignmentfromtype.h:376
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:275
std::size_t UintPtr
Definition bsls_types.h:126
Definition bsls_objectbuffer.h:276
TYPE * address()
Definition bsls_objectbuffer.h:334