4154template <class ELEMENT_TYPE>
4205 template <
class TARGET,
class SOURCE>
4217 template <
class TARGET,
class SOURCE>
4234 template <
class TARGET,
class SOURCE>
4248 template <
class TARGET,
class SOURCE>
4263 template <
class TARGET,
class SOURCE>
4275 template <
class TARGET,
class SOURCE>
4313 template <
class ANY_TYPE>
4331#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
4332 template <
class TYPE,
unsigned DIM = 0>
4333 struct Extent : std::extent<TYPE, DIM> {};
4335 template <
class TYPE,
unsigned DIM = 0>
4338 template <
class TYPE>
4341 template <
class TYPE,
unsigned DIM>
4345 template <
class TYPE,
size_t SIZE>
4349 template <
class TYPE,
size_t SIZE,
unsigned DIM>
4370 template<
class SHARED_TYPE,
class ENABLE_TYPE>
4371 static void loadEnableSharedFromThis(
4379 static void loadEnableSharedFromThis(
const volatile void *,
const void *)
4437#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
4441#if defined(BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE) && \
4442 defined(BSLS_PLATFORM_CMP_MSVC) && \
4443 BSLS_PLATFORM_CMP_VERSION >= 1936 && BSLS_PLATFORM_CMP_VERSION <= 1937
4449# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) decltype(__VA_ARGS__)
4451# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) (__VA_ARGS__)
4454template <
class FUNCTOR>
4455struct SharedPtr_TestIsCallable {
4458 typedef BloombergLP::bslmf::Util Util;
4490 template <
class ARG>
4491 static FalseType test(...);
4492 template <
class ARG>
4496 sizeof(BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(
4497 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4498 Util::declval<FUNCTOR>()(Util::declval<ARG>())),
4502#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1920
4510template <
class RESULT,
class PARAM>
4511struct SharedPtr_TestIsCallable<RESULT(PARAM)> {
4514 typedef BloombergLP::bslmf::Util Util;
4516 struct TrueType {
char d_padding; };
4517 struct FalseType {
char d_padding[17]; };
4520 static RESULT callMe(PARAM);
4534 template <
class ARG>
4535 static FalseType test(...);
4536 template <
class ARG>
4538 ((
void)callMe(Util::declval<ARG>())), 0
4542template <
class RESULT,
class PARAM>
4543struct SharedPtr_TestIsCallable<RESULT(*)(PARAM)>
4544 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4547template <
class RESULT,
class PARAM>
4548struct SharedPtr_TestIsCallable<RESULT(&)(PARAM)>
4549 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4552#if BSLS_PLATFORM_CMP_VERSION >= 1910
4559template <
class TYPE>
4560struct SharedPtr_TestIsCallable<TYPE *> {
4561 struct TrueType {
char d_padding; };
4562 struct FalseType {
char d_padding[17]; };
4564 template <
class ARG>
4565 static FalseType test(...);
4569struct SharedPtr_TestIsCallable<int> {
4570 struct TrueType {
char d_padding; };
4571 struct FalseType {
char d_padding[17]; };
4573 template <
class ARG>
4574 static FalseType test(...);
4580template <
class FUNCTOR,
class ARG>
4581struct SharedPtr_IsCallable {
4583 sizeof(SharedPtr_TestIsCallable<FUNCTOR>::template test<ARG>(0)) == 1
4588struct SharedPtr_IsFactoryFor_Impl {
4614 template <
class FACTORY,
class ARG>
4615 static FalseType test(...);
4616 template <
class FACTORY,
class ARG>
4617 static TrueType test(
typename bsl::enable_if<
static_cast<bool>(
sizeof(
4618 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4619 (*(FACTORY *)0)->deleteObject((ARG *)0)),
4623template <
class FACTORY,
class ARG>
4624struct SharedPtr_IsFactoryFor {
4626 sizeof(SharedPtr_IsFactoryFor_Impl::test<FACTORY, ARG>(0)) == 1
4631struct SharedPtr_IsNullableFactory_Impl {
4657 template <
class FACTORY>
4658 static FalseType test(...);
4659 template <
class FACTORY>
4660 static TrueType test(
typename bsl::enable_if<
static_cast<bool>(
sizeof(
4661 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4662 (*(FACTORY *)0)->deleteObject(
nullptr)),
4666template <
class FACTORY>
4667struct SharedPtr_IsNullableFactory {
4669 sizeof(SharedPtr_IsNullableFactory_Impl::test<FACTORY>(0)) == 1
4674template <
class SOURCE_TYPE,
class DEST_TYPE>
4675struct SharedPtr_IsPointerConvertible_Impl
4678template <
class SOURCE_TYPE,
class DEST_TYPE>
4679struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[]>
4682template <
class SOURCE_TYPE,
class DEST_TYPE,
size_t DEST_SIZE>
4683struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[DEST_SIZE]>
4685 DEST_TYPE (*)[DEST_SIZE]>::type {};
4688template <
class SOURCE_TYPE,
class DEST_TYPE>
4689struct SharedPtr_IsPointerConvertible
4690: SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4693template <
class SOURCE_TYPE,
class DEST_TYPE>
4694struct SharedPtr_IsPointerCompatible_Impl
4697template <
class TYPE,
size_t SIZE>
4698struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], TYPE[]>
4701template <
class TYPE,
size_t SIZE>
4702struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const TYPE[]>
4705template <
class TYPE,
size_t SIZE>
4706struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], volatile TYPE[]>
4709template <
class TYPE,
size_t SIZE>
4710struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const volatile TYPE[]>
4714template <
class SOURCE_TYPE,
class DEST_TYPE>
4715struct SharedPtr_IsPointerCompatible
4716: SharedPtr_IsPointerCompatible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4728template<
class ELEMENT_TYPE>
4736template<
class ELEMENT_TYPE>
4745template<
class ELEMENT_TYPE>
4752template<
class ELEMENT_TYPE>
4762template<
class ELEMENT_TYPE>
4770template<
class ELEMENT_TYPE>
4778template<
class ELEMENT_TYPE>
4786template<
class ELEMENT_TYPE>
4800template <
class ELEMENT_TYPE>
4801template <
class INPLACE_REP>
4803BloombergLP::bslma::SharedPtrRep *
4807 BloombergLP::bslma::SharedPtrRep *rep)
4812template <
class ELEMENT_TYPE>
4813template <
class COMPATIBLE_TYPE,
class ALLOCATOR>
4815BloombergLP::bslma::SharedPtrRep *
4816shared_ptr<ELEMENT_TYPE>::makeInternalRep(
4817 COMPATIBLE_TYPE *ptr,
4819 BloombergLP::bslma::Allocator *allocator)
4821 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4823 BloombergLP::bslma::Allocator *>
4826 return RepMaker::makeOutofplaceRep(ptr, allocator, allocator);
4829template <
class ELEMENT_TYPE>
4830template <
class COMPATIBLE_TYPE,
class DELETER>
4832BloombergLP::bslma::SharedPtrRep *
4833shared_ptr<ELEMENT_TYPE>::makeInternalRep(COMPATIBLE_TYPE *ptr,
4837 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<COMPATIBLE_TYPE,
4838 DELETER *> RepMaker;
4840 return RepMaker::makeOutofplaceRep(ptr, deleter, 0);
4844template <
class ELEMENT_TYPE>
4853template <
class ELEMENT_TYPE>
4862template <
class ELEMENT_TYPE>
4863template <
class CONVERTIBLE_TYPE
4869 typedef BloombergLP::bslstl::SharedPtr_DefaultDeleter<
4871 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4874 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, Deleter(), 0);
4876 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4881template <
class ELEMENT_TYPE>
4882template <
class CONVERTIBLE_TYPE
4886 CONVERTIBLE_TYPE *ptr,
4887 BloombergLP::bslma::Allocator *basicAllocator)
4890 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4892 BloombergLP::bslma::Allocator *>
4895 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, basicAllocator, basicAllocator);
4897 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4902template <
class ELEMENT_TYPE>
4906 BloombergLP::bslma::SharedPtrRep *rep)
4910 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4914template <
class ELEMENT_TYPE>
4918 BloombergLP::bslma::SharedPtrRep *rep,
4919 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr)
4925template <
class ELEMENT_TYPE>
4926template <
class CONVERTIBLE_TYPE,
4934, d_rep_p(makeInternalRep(ptr, dispatch, dispatch))
4937 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4942template <
class ELEMENT_TYPE>
4943template <
class CONVERTIBLE_TYPE,
4949 CONVERTIBLE_TYPE *ptr,
4951 BloombergLP::bslma::Allocator *basicAllocator)
4954 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4957 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, deleter, basicAllocator);
4959 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4964template <
class ELEMENT_TYPE>
4965template <
class CONVERTIBLE_TYPE,
4973 ALLOCATOR basicAllocator,
4974 typename ALLOCATOR::value_type *)
4977#ifdef BSLS_PLATFORM_CMP_MSVC
4985 DELETER>::type DeleterType;
4987 typedef DELETER DeleterType;
4991 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<CONVERTIBLE_TYPE,
4993 ALLOCATOR> RepMaker;
4995 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, deleter, basicAllocator);
4997 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
5002template <
class ELEMENT_TYPE>
5005 BloombergLP::bslma::Allocator *)
5011template <
class ELEMENT_TYPE>
5012template <
class DELETER
5018 BloombergLP::bslma::Allocator *basicAllocator)
5021 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<ELEMENT_TYPE,
5029 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
5035template <
class ELEMENT_TYPE>
5036template <
class DELETER,
class ALLOCATOR
5042 ALLOCATOR basicAllocator,
5043 typename ALLOCATOR::value_type *)
5046#ifdef BSLS_PLATFORM_CMP_MSVC
5054 DELETER>::type DeleterType;
5056 typedef DELETER DeleterType;
5060 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<ELEMENT_TYPE,
5062 ALLOCATOR> RepMaker;
5064 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
5069template <
class ELEMENT_TYPE>
5070template <
class CONVERTIBLE_TYPE
5073 BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE> managedPtr,
5074 BloombergLP::bslma::Allocator *basicAllocator)
5075: d_ptr_p(managedPtr.ptr())
5078 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5079 BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE> > Rep;
5082 ELEMENT_TYPE *pPotentiallyShared =
static_cast<ELEMENT_TYPE *
>(
5085 if (&BloombergLP::bslma::SharedPtrRep::managedPtrDeleter ==
5087 d_rep_p =
static_cast<BloombergLP::bslma::SharedPtrRep *
>
5090 else if (&BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter ==
5097 BloombergLP::bslma::Default::allocator(basicAllocator);
5098 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5103 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5109#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
5110template <
class ELEMENT_TYPE>
5111template <
class CONVERTIBLE_TYPE
5114 std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr,
5115 BloombergLP::bslma::Allocator *basicAllocator)
5116: d_ptr_p(autoPtr.
get())
5119 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5120 std::auto_ptr<CONVERTIBLE_TYPE> > Rep;
5124 BloombergLP::bslma::Default::allocator(basicAllocator);
5125 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5126 (*
rep->ptr()) = autoPtr;
5128 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5134template <
class ELEMENT_TYPE>
5136 std::auto_ptr_ref<ELEMENT_TYPE> autoRef,
5137 BloombergLP::bslma::Allocator *basicAllocator)
5141 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5142 std::auto_ptr<ELEMENT_TYPE> > Rep;
5144 std::auto_ptr<ELEMENT_TYPE> autoPtr(autoRef);
5145 if (autoPtr.get()) {
5147 BloombergLP::bslma::Default::allocator(basicAllocator);
5148 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5149 d_ptr_p = autoPtr.get();
5150 (*
rep->ptr()) = autoPtr;
5156#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
5157# if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
5158template <
class ELEMENT_TYPE>
5159template <
class COMPATIBLE_TYPE,
5160 class UNIQUE_DELETER,
5161 typename enable_if<is_convertible<
5162 typename std::unique_ptr<COMPATIBLE_TYPE,
5163 UNIQUE_DELETER>::pointer,
5164 ELEMENT_TYPE *>::value>::type *>
5166 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee,
5167 BloombergLP::bslma::Allocator *basicAllocator)
5168: d_ptr_p(adoptee.
get())
5171 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5172 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER> > Rep;
5176 BloombergLP::bslma::Default::allocator(basicAllocator);
5177 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator,
5178 BloombergLP::bslmf::MovableRefUtil::move(adoptee));
5180 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5188template <
class ELEMENT_TYPE>
5189template <
class ANY_TYPE>
5191 ELEMENT_TYPE *
object)
5194, d_rep_p(source.d_rep_p)
5197 d_rep_p->acquireRef();
5201template <
class ELEMENT_TYPE>
5202template <
class COMPATIBLE_TYPE
5206: d_ptr_p(other.d_ptr_p)
5207, d_rep_p(other.d_rep_p)
5210 d_rep_p->acquireRef();
5214template <
class ELEMENT_TYPE>
5217: d_ptr_p(original.d_ptr_p)
5218, d_rep_p(original.d_rep_p)
5221 d_rep_p->acquireRef();
5225template <
class ELEMENT_TYPE>
5227 (BloombergLP::bslmf::MovableRef<shared_ptr> original)
5229: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
5230, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
5232 BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p = 0;
5233 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
5236#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5237template <
class ELEMENT_TYPE>
5238template <
class COMPATIBLE_TYPE
5242: d_ptr_p(other.d_ptr_p)
5243, d_rep_p(other.d_rep_p)
5249template <
class ELEMENT_TYPE>
5250template <
class COMPATIBLE_TYPE
5255: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p)
5256, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p)
5258 BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p = 0;
5259 BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p = 0;
5263template <
class ELEMENT_TYPE>
5264template <
class COMPATIBLE_TYPE
5276 SelfType value = other.
lock();
5281 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
5287#if !defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5288template <
class ELEMENT_TYPE>
5289template <
class COMPATIBLE_TYPE
5304 SelfType value = other.
lock();
5309 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
5316template <
class ELEMENT_TYPE>
5320 d_rep_p->releaseRef();
5325template <
class ELEMENT_TYPE>
5333 if (
rhs.d_rep_p == d_rep_p) {
5334 d_ptr_p =
rhs.d_ptr_p;
5337 SelfType(
rhs).swap(*
this);
5343template <
class ELEMENT_TYPE>
5346 BloombergLP::bslmf::MovableRef<shared_ptr>
rhs)
5357template <
class ELEMENT_TYPE>
5358template <
class COMPATIBLE_TYPE>
5368 if (
rhs.d_rep_p == d_rep_p) {
5369 d_ptr_p =
rhs.d_ptr_p;
5372 SelfType(
rhs).swap(*
this);
5378#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5379template <
class ELEMENT_TYPE>
5380template <
class COMPATIBLE_TYPE>
5386template <
class ELEMENT_TYPE>
5387template <
class COMPATIBLE_TYPE>
5403template <
class ELEMENT_TYPE>
5404template <
class COMPATIBLE_TYPE>
5410 BloombergLP::bslma::ManagedPtr<COMPATIBLE_TYPE>
rhs)
5416#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
5417template <
class ELEMENT_TYPE>
5418template <
class COMPATIBLE_TYPE>
5430#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
5431template <
class ELEMENT_TYPE>
5432template <
class COMPATIBLE_TYPE,
class UNIQUE_DELETER>
5436 typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer,
5437 ELEMENT_TYPE *>::value,
5438 shared_ptr<ELEMENT_TYPE>&>::type
5440 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&&
rhs)
5442 SelfType(BloombergLP::bslmf::MovableRefUtil::move(
rhs)).
swap(*
this);
5447template <
class ELEMENT_TYPE>
5451 BloombergLP::bslma::SharedPtrRep *rep = d_rep_p;
5464template <
class ELEMENT_TYPE>
5465template <
class COMPATIBLE_TYPE>
5471 SelfType(ptr).swap(*
this);
5474template <
class ELEMENT_TYPE>
5475template <
class COMPATIBLE_TYPE,
class DELETER>
5482 SelfType(ptr, deleter).swap(*
this);
5485template <
class ELEMENT_TYPE>
5486template <
class COMPATIBLE_TYPE,
class DELETER,
class ALLOCATOR>
5492 ALLOCATOR basicAllocator)
5494 SelfType(ptr, deleter, basicAllocator).swap(*
this);
5497template <
class ELEMENT_TYPE>
5498template <
class ANY_TYPE>
5506 if (source.d_rep_p == d_rep_p && ptr) {
5510 SelfType(source, ptr).swap(*
this);
5514template <
class ELEMENT_TYPE>
5528 d_ptr_p = other.d_ptr_p;
5529 other.d_ptr_p = tempPtr_p;
5531 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
5532 d_rep_p = other.d_rep_p;
5533 other.d_rep_p = tempRep_p;
5537template<
class ELEMENT_TYPE>
5541 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5543 BloombergLP::bslma::Allocator *basicAllocator =
5544 BloombergLP::bslma::Default::allocator();
5546 Rep *rep =
new (*basicAllocator) Rep(basicAllocator);
5547 SelfType(rep->ptr(), rep).swap(*
this);
5550#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
5551template <
class ELEMENT_TYPE>
5552template <
class... ARGS>
5555 BloombergLP::bslma::Allocator *basicAllocator,
5558 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5560 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5561 Rep *rep =
new (*basicAllocator) Rep(basicAllocator,
5563 SelfType(rep->ptr(), rep).swap(*
this);
5567template <
class ELEMENT_TYPE>
5568template <
class ANY_TYPE>
5571 ELEMENT_TYPE *
object)
5573 if (source.d_rep_p == d_rep_p &&
object) {
5577 SelfType(source,
object).swap(*
this);
5581template <
class ELEMENT_TYPE>
5592#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5594template <
class ELEMENT_TYPE>
5601template <
class ELEMENT_TYPE>
5602template <
class COMPATIBLE_TYPE>
5606 SelfType(ptr).swap(*
this);
5609template <
class ELEMENT_TYPE>
5610template <
class COMPATIBLE_TYPE>
5614 BloombergLP::bslma::Allocator *basicAllocator)
5616 SelfType(ptr, basicAllocator).swap(*
this);
5619template <
class ELEMENT_TYPE>
5620template <
class COMPATIBLE_TYPE,
class DELETER>
5624 const DELETER& deleter,
5625 BloombergLP::bslma::Allocator *basicAllocator)
5627 SelfType(ptr, deleter, basicAllocator).swap(*
this);
5632template <
class ELEMENT_TYPE>
5634#if defined(BSLS_PLATFORM_CMP_IBM)
5641 return BloombergLP::bsls::UnspecifiedBool<shared_ptr>::makeValue(d_ptr_p);
5644template <
class ELEMENT_TYPE>
5654template <
class ELEMENT_TYPE>
5662template <
class ELEMENT_TYPE>
5670template <
class ELEMENT_TYPE>
5677 return *(d_ptr_p + index);
5680template <
class ELEMENT_TYPE>
5681template<
class ANY_TYPE>
5686 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5689template <
class ELEMENT_TYPE>
5690template<
class ANY_TYPE>
5696 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5699template <
class ELEMENT_TYPE>
5700template<
class ANY_TYPE>
5705 return rep() == other.rep();
5708template <
class ELEMENT_TYPE>
5709template<
class ANY_TYPE>
5715 return rep() == other.rep();
5718template <
class ELEMENT_TYPE>
5726template <
class ELEMENT_TYPE>
5730 return 1 == use_count();
5733template <
class ELEMENT_TYPE>
5737 return d_rep_p ? d_rep_p->numReferences() : 0;
5741template <
class ELEMENT_TYPE>
5742BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>
5745 if (d_rep_p && d_ptr_p) {
5746 d_rep_p->acquireRef();
5747 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(d_ptr_p,
5749 &BloombergLP::bslma::SharedPtrRep::managedPtrDeleter);
5753 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(
5755 (BloombergLP::bslma::SharedPtrRep *)0,
5756 &BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter);
5759template <
class ELEMENT_TYPE>
5767#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5769template <
class ELEMENT_TYPE>
5773 return d_rep_p ? d_rep_p->numReferences() : 0;
5776template <
class ELEMENT_TYPE>
5790template <
class ELEMENT_TYPE>
5799template <
class ELEMENT_TYPE>
5801 BloombergLP::bslmf::MovableRef<weak_ptr> original)
5803: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
5804, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
5806 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
5810#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5811template <
class ELEMENT_TYPE>
5812template <
class COMPATIBLE_TYPE
5816: d_ptr_p(original.d_ptr_p)
5817, d_rep_p(original.d_rep_p)
5819 original.d_rep_p = 0;
5823template <
class ELEMENT_TYPE>
5824template <
class CONVERTIBLE_TYPE
5829: d_ptr_p(original.d_ptr_p)
5830, d_rep_p(original.d_rep_p)
5832 original.d_rep_p = 0;
5837template <
class ELEMENT_TYPE>
5840: d_ptr_p(original.d_ptr_p)
5841, d_rep_p(original.d_rep_p)
5844 d_rep_p->acquireWeakRef();
5848template <
class ELEMENT_TYPE>
5849template <
class COMPATIBLE_TYPE
5853: d_ptr_p(other.get())
5854, d_rep_p(other.rep())
5857 d_rep_p->acquireWeakRef();
5861template <
class ELEMENT_TYPE>
5862template <
class COMPATIBLE_TYPE
5866: d_ptr_p(other.d_ptr_p)
5867, d_rep_p(other.d_rep_p)
5870 d_rep_p->acquireWeakRef();
5874template <
class ELEMENT_TYPE>
5879 d_rep_p->releaseWeakRef();
5884template <
class ELEMENT_TYPE>
5887 BloombergLP::bslma::SharedPtrRep *rep,
5888 ELEMENT_TYPE *target)
5891 d_rep_p->releaseWeakRef();
5896 d_rep_p->acquireWeakRef();
5900template <
class ELEMENT_TYPE>
5902 BloombergLP::bslmf::MovableRef<weak_ptr>
rhs)
5905 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(
rhs));
5910#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5911template <
class ELEMENT_TYPE>
5912template <
class COMPATIBLE_TYPE>
5919 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(
rhs));
5924template <
class ELEMENT_TYPE>
5925template <
class COMPATIBLE_TYPE>
5927 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5928 weak_ptr<ELEMENT_TYPE>&>::type
5933 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(
rhs));
5939template <
class ELEMENT_TYPE>
5949 privateAssign(
rhs.d_rep_p,
rhs.d_ptr_p);
5954template <
class ELEMENT_TYPE>
5955template <
class COMPATIBLE_TYPE>
5967 privateAssign(
rhs.d_rep_p,
rhs.d_ptr_p);
5972template <
class ELEMENT_TYPE>
5973template <
class COMPATIBLE_TYPE>
5985 privateAssign(
rhs.d_rep_p,
rhs.d_ptr_p);
5990template <
class ELEMENT_TYPE>
5995 d_rep_p->releaseWeakRef();
6002template <
class ELEMENT_TYPE>
6013 ELEMENT_TYPE *tempPtr_p = d_ptr_p;
6014 d_ptr_p = other.d_ptr_p;
6015 other.d_ptr_p = tempPtr_p;
6017 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
6018 d_rep_p = other.d_rep_p;
6019 other.d_rep_p = tempRep_p;
6023template <
class ELEMENT_TYPE>
6027 return !(d_rep_p && d_rep_p->numReferences());
6030template <
class ELEMENT_TYPE>
6034 if (d_rep_p && d_rep_p->tryAcquireRef()) {
6038 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr());
6044template <
class ELEMENT_TYPE>
6045template <
class ANY_TYPE>
6051 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
6055template <
class ELEMENT_TYPE>
6056template <
class ANY_TYPE>
6062 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
6066template <
class ELEMENT_TYPE>
6067template<
class ANY_TYPE>
6073 return rep() == other.rep();
6076template <
class ELEMENT_TYPE>
6077template<
class ANY_TYPE>
6083 return rep() == other.rep();
6086template <
class ELEMENT_TYPE>
6094template <
class ELEMENT_TYPE>
6102template <
class ELEMENT_TYPE>
6106 return d_rep_p ? d_rep_p->numReferences() : 0;
6109#ifndef BDE_OMIT_INTERNAL_DEPRECATED
6111template <
class ELEMENT_TYPE>
6119template <
class ELEMENT_TYPE>
6123 return d_rep_p ? d_rep_p->numReferences() : 0;
6136template <
class SHARED_TYPE,
class ENABLE_TYPE>
6144 if (0 != result && result->d_weakThis.expired()) {
6145 result->d_weakThis.privateAssign(
6147 const_cast <ENABLE_TYPE *
>(
6148 static_cast<ENABLE_TYPE const*
>(sharedPtr->d_ptr_p)));
6164template <
class TARGET,
class SOURCE>
6171 target->
reset(source,
const_cast<TARGET *
>(source.
get()));
6174template <
class TARGET,
class SOURCE>
6181 const_cast<TARGET *
>(source.get()));
6184template <
class TARGET,
class SOURCE>
6191 if (TARGET *castPtr =
dynamic_cast<TARGET *
>(source.
get())) {
6192 target->
reset(source, castPtr);
6199template <
class TARGET,
class SOURCE>
6205 if (TARGET *castPtr =
dynamic_cast<TARGET *
>(source.get())) {
6212template <
class TARGET,
class SOURCE>
6219 target->
reset(source,
static_cast<TARGET *
>(source.
get()));
6222template <
class TARGET,
class SOURCE>
6229 static_cast<TARGET *
>(source.get()));
6249template <
class ANY_TYPE>
6258template <
class ANY_TYPE>
6282 d_rep_p->disposeRep();
6297template <
class LHS_TYPE,
class RHS_TYPE>
6299bool bsl::operator==(
const shared_ptr<LHS_TYPE>& lhs,
6302 return lhs.get() == rhs.get();
6305#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6307template<
class LHS_TYPE,
class RHS_TYPE>
6309bsl::strong_ordering bsl::operator<=>(
const shared_ptr<LHS_TYPE>& lhs,
6310 const shared_ptr<RHS_TYPE>& rhs)
6313 const void *p1 =
lhs.get(),
6320template <
class LHS_TYPE,
class RHS_TYPE>
6328template <
class LHS_TYPE,
class RHS_TYPE>
6333 return std::less<const void *>()(
lhs.get(),
rhs.get());
6336template <
class LHS_TYPE,
class RHS_TYPE>
6344template <
class LHS_TYPE,
class RHS_TYPE>
6352template <
class LHS_TYPE,
class RHS_TYPE>
6362template <
class LHS_TYPE>
6370#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6374bsl::strong_ordering bsl::operator<=>(
const shared_ptr<TYPE>& ptr,
6377 const typename shared_ptr<TYPE>::element_type *null =
nullptr;
6378 return ptr.get() <=> null;
6383template <
class RHS_TYPE>
6391template <
class LHS_TYPE>
6396 return static_cast<bool>(
lhs);
6399template <
class RHS_TYPE>
6404 return static_cast<bool>(
rhs);
6407template <
class LHS_TYPE>
6412 return std::less<LHS_TYPE *>()(
lhs.get(), 0);
6415template <
class RHS_TYPE>
6420 return std::less<RHS_TYPE *>()(0,
rhs.get());
6423template <
class LHS_TYPE>
6428 return !std::less<LHS_TYPE *>()(0,
lhs.get());
6431template <
class RHS_TYPE>
6436 return !std::less<RHS_TYPE *>()(
rhs.get(), 0);
6439template <
class LHS_TYPE>
6444 return std::less<LHS_TYPE *>()(0,
lhs.get());
6447template <
class RHS_TYPE>
6452 return std::less<RHS_TYPE *>()(
rhs.get(), 0);
6455template <
class LHS_TYPE>
6460 return !std::less<LHS_TYPE *>()(
lhs.get(), 0);
6463template <
class RHS_TYPE>
6468 return !std::less<RHS_TYPE *>()(0,
rhs.get());
6473template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ELEMENT_TYPE>
6475std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
6477 const shared_ptr<ELEMENT_TYPE>& rhs)
6479 return stream <<
rhs.get();
6483template <
class HASHALG,
class ELEMENT_TYPE>
6485void bsl::hashAppend(HASHALG& hashAlg,
const shared_ptr<ELEMENT_TYPE>& input)
6490template <
class ELEMENT_TYPE>
6492void bsl::swap(shared_ptr<ELEMENT_TYPE>& a, shared_ptr<ELEMENT_TYPE>& b)
6498template <
class ELEMENT_TYPE>
6500void bsl::swap(weak_ptr<ELEMENT_TYPE>& a, weak_ptr<ELEMENT_TYPE>& b)
6507template<
class DELETER,
class ELEMENT_TYPE>
6512 BloombergLP::bslma::SharedPtrRep *rep = p.rep();
6513 return rep ?
static_cast<DELETER *
>(rep->getDeleter(
typeid(DELETER))) : 0;
6517template<
class TO_TYPE,
class FROM_TYPE>
6523 return shared_ptr<TO_TYPE>(source,
const_cast<TO_TYPE *
>(source.get()));
6526template<
class TO_TYPE,
class FROM_TYPE>
6532 if (TO_TYPE *castPtr =
dynamic_cast<TO_TYPE *
>(source.get())) {
6533 return shared_ptr<TO_TYPE>(source, castPtr);
6536 return shared_ptr<TO_TYPE>();
6539template<
class TO_TYPE,
class FROM_TYPE>
6545 return shared_ptr<TO_TYPE>(source,
static_cast<TO_TYPE *
>(source.get()));
6548template<
class TO_TYPE,
class FROM_TYPE>
6554 return shared_ptr<TO_TYPE>(source,
6555 reinterpret_cast<TO_TYPE *
>(source.get()));
6564#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6567template<
class ELEMENT_TYPE,
class ALLOC,
class... ARGS>
6573 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6575 typedef BloombergLP::bslstl::
6576 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6577 Rep *rep_p = Rep::makeRep(basicAllocator);
6579 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6582 PtrUtil::unqualify(rep_p->ptr()),
6585 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6589template<
class ARRAY_TYPE,
class ALLOC>
6596 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6599 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6600 typedef BloombergLP::bslstl::
6601 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6603 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6604 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6606 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6607 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
6608 static_cast<Element_type *
> (rep_p->ptr()),
6610 ElementAllocatorType(basicAllocator));
6613 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6614 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6617template<
class ARRAY_TYPE,
class ALLOC>
6623 ALLOC basicAllocator,
6626 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6629 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6630 typedef BloombergLP::bslstl::
6631 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6633 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6634 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6636 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6637 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6638 static_cast<Element_type *
> (rep_p->ptr()),
6641 ElementAllocatorType(basicAllocator));
6644 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6645 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6648template<
class ARRAY_TYPE,
class ALLOC>
6657 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6658 typedef BloombergLP::bslstl::
6659 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6661 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6663 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6664 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
6665 static_cast<Element_type *
> (rep_p->ptr()),
6667 ElementAllocatorType(basicAllocator));
6670 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6671 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6674template<
class ARRAY_TYPE,
class ALLOC>
6680 ALLOC basicAllocator,
6686 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6687 typedef BloombergLP::bslstl::
6688 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6690 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6692 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6693 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6694 static_cast<Element_type *
> (rep_p->ptr()),
6697 ElementAllocatorType(basicAllocator));
6700 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6701 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6708template<
class ELEMENT_TYPE,
class ALLOC>
6715 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6717 typedef BloombergLP::bslstl::
6718 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6719 Rep *rep_p = Rep::makeRep(basicAllocator);
6721 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6722 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
6725 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6728template<class ARRAY_TYPE, class ALLOC>
6730typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value &&
6731 !
bsl::is_pointer<ALLOC>::value,
6732 bsl::shared_ptr<ARRAY_TYPE> >::type
6733bsl::allocate_shared_for_overwrite(ALLOC basicAllocator)
6735 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6736 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6738 typedef BloombergLP::bslstl::
6739 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6741 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6742 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6744 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6745 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
6748 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6749 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6752template<class ARRAY_TYPE, class ALLOC>
6754typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value &&
6755 !
bsl::is_pointer<ALLOC>::value,
6756 bsl::shared_ptr<ARRAY_TYPE> >::type
6757bsl::allocate_shared_for_overwrite(ALLOC basicAllocator,
size_t numElements)
6760 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6762 typedef BloombergLP::bslstl::
6763 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6765 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6767 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6768 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
6771 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6772 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6779#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6780template<
class ELEMENT_TYPE,
class ALLOC,
class... ARGS>
6789 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6791 typedef BloombergLP::bslstl::
6792 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
6793 AllocatorType alloc(basicAllocator);
6794 Rep *rep_p = Rep::makeRep(alloc);
6796 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6797 AllocatorTraits::construct(alloc,
6798 PtrUtil::unqualify(rep_p->ptr()),
6801 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6805template<
class ARRAY_TYPE,
class ALLOC>
6811 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6813 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6817 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6818 AllocatorType alloc(basicAllocator);
6819 Rep *rep_p = Rep::makeRep(alloc, numElements);
6821 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6822 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
6827 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6828 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6831template<
class ARRAY_TYPE,
class ALLOC>
6836 ALLOC *basicAllocator,
6839 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6842 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6846 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6847 AllocatorType alloc(basicAllocator);
6848 Rep *rep_p = Rep::makeRep(alloc, numElements);
6850 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6851 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6852 static_cast<Element_type *
> (rep_p->ptr()),
6858 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6859 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6862template<
class ARRAY_TYPE,
class ALLOC>
6869 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6872 AllocatorType alloc(basicAllocator);
6873 Rep *rep_p = Rep::makeRep(alloc, numElements);
6875 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6876 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
6881 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6882 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6885template<
class ARRAY_TYPE,
class ALLOC>
6890 ALLOC *basicAllocator,
6896 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6899 AllocatorType alloc(basicAllocator);
6900 Rep *rep_p = Rep::makeRep(alloc, numElements);
6902 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6903 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6904 static_cast<Element_type *
> (rep_p->ptr()),
6910 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6911 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6918template<
class ELEMENT_TYPE,
class ALLOC>
6925 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6927 typedef BloombergLP::bslstl::
6928 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
6929 AllocatorType alloc(basicAllocator);
6930 Rep *rep_p = Rep::makeRep(alloc);
6932 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6933 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
6936 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6940template<class ARRAY_TYPE, class ALLOC>
6942typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value,
6943 bsl::shared_ptr<ARRAY_TYPE> >::type
6944bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator)
6947 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6948 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6950 typedef BloombergLP::bslstl::
6951 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
6953 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6954 AllocatorType alloc(basicAllocator);
6955 Rep *rep_p = Rep::makeRep(alloc, numElements);
6957 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6958 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
6961 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6962 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6965template<class ARRAY_TYPE, class ALLOC>
6967typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value,
6968 bsl::shared_ptr<ARRAY_TYPE> >::type
6969bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator,
size_t numElements)
6973 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6975 typedef BloombergLP::bslstl::
6976 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
6977 AllocatorType alloc(basicAllocator);
6978 Rep *rep_p = Rep::makeRep(alloc, numElements);
6980 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6981 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
6984 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6985 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6992#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6995template<
class ELEMENT_TYPE,
class... ARGS>
7002 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7004 typedef BloombergLP::bslstl::
7005 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7007 AllocatorType basicAllocator;
7008 Rep *rep_p = Rep::makeRep(basicAllocator);
7010 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7011 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
7015 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7019template<
class ARRAY_TYPE>
7025 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7029 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7030 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7034 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7035 AllocatorType basicAllocator;
7036 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7038 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7039 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
7042 ElementAllocatorType(basicAllocator));
7045 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7046 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7049template<
class ARRAY_TYPE>
7055 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7059 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7060 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7064 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7065 AllocatorType basicAllocator;
7066 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7068 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7069 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
7073 ElementAllocatorType(basicAllocator));
7076 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7077 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7080template<
class ARRAY_TYPE>
7089 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7090 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7094 AllocatorType basicAllocator;
7095 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7097 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7098 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
7101 ElementAllocatorType(basicAllocator));
7104 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7105 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7108template<
class ARRAY_TYPE>
7119 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7120 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7124 AllocatorType basicAllocator;
7125 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7127 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7128 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
7132 ElementAllocatorType(basicAllocator));
7135 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7136 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7143template<
class ELEMENT_TYPE>
7150 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7152 typedef BloombergLP::bslstl::
7153 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7155 AllocatorType basicAllocator;
7156 Rep *rep_p = Rep::makeRep(basicAllocator);
7158 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7159 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
7162 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7165template<class ARRAY_TYPE>
7167typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value,
7168 bsl::shared_ptr<ARRAY_TYPE> >::type
7169bsl::make_shared_for_overwrite()
7172 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7173 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7175 typedef BloombergLP::bslstl::
7176 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
7178 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7179 AllocatorType basicAllocator;
7180 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7182 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7183 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
7187 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
7188 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7191template<class ARRAY_TYPE>
7193typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value,
7194 bsl::shared_ptr<ARRAY_TYPE> >::type
7195bsl::make_shared_for_overwrite(
size_t numElements)
7199 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7201 typedef BloombergLP::bslstl::
7202 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
7204 AllocatorType basicAllocator;
7205 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7207 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7208 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
7212 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
7213 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7236template <
class ELEMENT_TYPE>
7245template <
class ELEMENT_TYPE>
7250template <
class ELEMENT_TYPE>
7255template <
class ELEMENT_TYPE>
7264#if defined(BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC)
7265# pragma GCC diagnostic pop
7268#undef BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE
7269#undef BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE
7271#undef BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE
7272#undef BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE
7274#undef BSLSTL_SHAREDPTR_DECLARE_IF_DELETER
7275#undef BSLSTL_SHAREDPTR_DEFINE_IF_DELETER
7277#undef BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER
7278#undef BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER
7280#undef BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND
7282#undef BSLSTL_SHAREDPTR_SFINAE_DISCARD