8#ifndef INCLUDED_BSLSTL_SHAREDPTRALLOCATEINPLACEREP
9#define INCLUDED_BSLSTL_SHAREDPTRALLOCATEINPLACEREP
78#include <bslscm_version.h>
113template <
class TYPE,
class ALLOCATOR>
118 template rebind_traits<SharedPtrAllocateInplaceRep>
222template <class TYPE, class ALLOCATOR>
224 : public BloombergLP::
bslma::SharedPtrRep {
229 template rebind_traits<SharedPtrArrayAllocateInplaceRep>
241 char *d_allocated_ptr_p;
255 static size_t offset_of_first_element();
281 const
element_type *get_pointer_to_first_element() const;
295 static
size_t alloc_size(
size_t numElements);
361template <class TYPE, class ALLOCATOR>
365: d_allocator(basicAllocator)
371template <
class TYPE,
class ALLOCATOR>
379template <
class TYPE,
class ALLOCATOR>
381SharedPtrAllocateInplaceRep<TYPE, ALLOCATOR> *
386 ReboundTraits::allocate(basicAllocator, 1);
392template <
class TYPE,
class ALLOCATOR>
396 ReboundTraits::destroy(d_allocator,
ptr());
399template <
class TYPE,
class ALLOCATOR>
404 this->d_allocator.~ReboundAllocator();
405 ReboundTraits::deallocate(alloc,
this, 1);
408template <
class TYPE,
class ALLOCATOR>
416template <
class TYPE,
class ALLOCATOR>
424template <
class TYPE,
class ALLOCATOR>
438template <
class TYPE,
class ALLOCATOR>
444: d_allocator(basicAllocator)
446, d_allocated_ptr_p(allocatedPtr)
452template <
class TYPE,
class ALLOCATOR>
453SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR>::
454~SharedPtrArrayAllocateInplaceRep()
460template <
class TYPE,
class ALLOCATOR>
463SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR>::offset_of_first_element()
465 typedef SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR> ThisType;
469 k_ALIGNMENT_MASK = ~(k_ALIGNMENT - 1)
475 return (
sizeof(ThisType) + k_ALIGNMENT - 1) & k_ALIGNMENT_MASK;
479template <
class TYPE,
class ALLOCATOR>
488 return ThisType::offset_of_first_element() +
490 (
sizeof(ThisType::element_type) * numElements);
493template <
class TYPE,
class ALLOCATOR>
503 template rebind_traits<char> CharATraits;
507 k_ALIGNMENT_MASK = ~(k_ALIGNMENT - 1)
511 typename CharATraits::allocator_type charAlloc(basicAllocator);
513 CharATraits::allocate(charAlloc, alloc_size(numElements));
531template <
class TYPE,
class ALLOCATOR>
538 return reinterpret_cast<element_type *
>(
539 reinterpret_cast<char *
>(
this) + offset_of_first_element());
543template <
class TYPE,
class ALLOCATOR>
548 template rebind_traits<element_type> ElementTraits;
550 typename ElementTraits::allocator_type elementAlloc(d_allocator);
554 for (
size_t i = 0; i < d_size; ++i, --pN) {
555 ElementTraits::destroy(elementAlloc, pN);
559template <
class TYPE,
class ALLOCATOR>
564 template rebind_traits<char> CharATraits;
565 typename CharATraits::allocator_type charAlloc(d_allocator);
567 this->d_allocator.~ReboundAllocator();
568 CharATraits::deallocate(charAlloc, d_allocated_ptr_p, alloc_size(d_size));
571template <
class TYPE,
class ALLOCATOR>
580template <
class TYPE,
class ALLOCATOR>
587 return reinterpret_cast<const element_type *
>(
588 reinterpret_cast<const char *
>(
this) + offset_of_first_element());
591template <
class TYPE,
class ALLOCATOR>
596 return get_pointer_to_first_element();
600template <
class TYPE,
class ALLOCATOR>
616template <
class TYPE,
class ALLOCATOR>
622template <
class TYPE,
class ALLOCATOR>
624 bslstl::SharedPtrArrayAllocateInplaceRep<TYPE, ALLOCATOR> >
Definition bslstl_sharedptrallocateinplacerep.h:114
static SharedPtrAllocateInplaceRep * makeRep(ReboundAllocator basicAllocator)
Definition bslstl_sharedptrallocateinplacerep.h:382
void * getDeleter(const std::type_info &type) BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:411
ReboundTraits::allocator_type ReboundAllocator
Definition bslstl_sharedptrallocateinplacerep.h:123
TYPE * ptr()
Definition bslstl_sharedptrallocateinplacerep.h:418
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:427
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:401
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:394
Definition bslstl_sharedptrallocateinplacerep.h:224
void disposeObject() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:545
element_type * ptr()
Definition bslstl_sharedptrallocateinplacerep.h:594
bsl::remove_extent< TYPE >::type element_type
Definition bslstl_sharedptrallocateinplacerep.h:234
ReboundTraits::allocator_type ReboundAllocator
Definition bslstl_sharedptrallocateinplacerep.h:235
void * originalPtr() const BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:603
static size_t alloc_size(size_t numElements)
Definition bslstl_sharedptrallocateinplacerep.h:482
static SharedPtrArrayAllocateInplaceRep * makeRep(ReboundAllocator basicAllocator, size_t numElements)
Definition bslstl_sharedptrallocateinplacerep.h:496
void disposeRep() BSLS_KEYWORD_OVERRIDE
Definition bslstl_sharedptrallocateinplacerep.h:561
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:2045
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:695
Definition baljsn_encoder_testtypes.h:76
Definition bslstl_algorithm.h:84
Definition bdldfp_decimal.h:5549
Definition bslma_allocatortraits.h:1089
Definition bslmf_integralconstant.h:261
Definition bslmf_isarray.h:168
t_TYPE type
Definition bslmf_removeextent.h:134
static BSLS_KEYWORD_CONSTEXPR void * voidify(TYPE *address) BSLS_KEYWORD_NOEXCEPT
Definition bslma_pointerutil.h:350
Definition bslma_usesbslmaallocator.h:344
Definition bsls_alignmentfromtype.h:378
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:300
std::size_t UintPtr
Definition bsls_types.h:128
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335