4073template <class ELEMENT_TYPE>
4120 template <
class TARGET,
class SOURCE>
4131 template <
class TARGET,
class SOURCE>
4147 template <
class TARGET,
class SOURCE>
4160 template <
class TARGET,
class SOURCE>
4174 template <
class TARGET,
class SOURCE>
4185 template <
class TARGET,
class SOURCE>
4219 template <
class ANY_TYPE>
4235#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
4236 template <
class TYPE,
unsigned DIM = 0>
4239 template <
class TYPE,
unsigned DIM = 0>
4242 template <
class TYPE>
4245 template <
class TYPE,
unsigned DIM>
4246 struct Extent<TYPE[], DIM>
4249 template <
class TYPE,
size_t SIZE>
4250 struct Extent<TYPE[SIZE], 0>
4253 template <
class TYPE,
size_t SIZE,
unsigned DIM>
4254 struct Extent<TYPE[SIZE], DIM>
4273 template<
class SHARED_TYPE,
class ENABLE_TYPE>
4274 static void loadEnableSharedFromThis(
4282 static void loadEnableSharedFromThis(
const volatile void *,
const void *)
4290 template <
class TYPE>
4296 template <
class TYPE>
4350#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
4354#if defined(BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE) && \
4355 defined(BSLS_PLATFORM_CMP_MSVC) && \
4356 BSLS_PLATFORM_CMP_VERSION >= 1936 && BSLS_PLATFORM_CMP_VERSION <= 1937
4362# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) decltype(__VA_ARGS__)
4364# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) (__VA_ARGS__)
4367template <
class FUNCTOR>
4368struct SharedPtr_TestIsCallable {
4371 typedef BloombergLP::bslmf::Util Util;
4401 template <
class ARG>
4402 static FalseType test(...);
4403 template <
class ARG>
4407 sizeof(BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(
4408 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4409 Util::declval<FUNCTOR>()(Util::declval<ARG>())),
4413#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1920
4421template <
class RESULT,
class PARAM>
4422struct SharedPtr_TestIsCallable<RESULT(PARAM)> {
4425 typedef BloombergLP::bslmf::Util Util;
4427 struct TrueType {
char d_padding; };
4428 struct FalseType {
char d_padding[17]; };
4431 static RESULT callMe(PARAM);
4445 template <
class ARG>
4446 static FalseType test(...);
4447 template <
class ARG>
4449 ((
void)callMe(Util::declval<ARG>())), 0
4453template <
class RESULT,
class PARAM>
4454struct SharedPtr_TestIsCallable<RESULT(*)(PARAM)>
4455 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4458template <
class RESULT,
class PARAM>
4459struct SharedPtr_TestIsCallable<RESULT(&)(PARAM)>
4460 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4463#if BSLS_PLATFORM_CMP_VERSION >= 1910
4470template <
class TYPE>
4471struct SharedPtr_TestIsCallable<TYPE *> {
4472 struct TrueType {
char d_padding; };
4473 struct FalseType {
char d_padding[17]; };
4475 template <
class ARG>
4476 static FalseType test(...);
4480struct SharedPtr_TestIsCallable<int> {
4481 struct TrueType {
char d_padding; };
4482 struct FalseType {
char d_padding[17]; };
4484 template <
class ARG>
4485 static FalseType test(...);
4491template <
class FUNCTOR,
class ARG>
4492struct SharedPtr_IsCallable {
4494 sizeof(SharedPtr_TestIsCallable<FUNCTOR>::template test<ARG>(0)) == 1
4499struct SharedPtr_IsFactoryFor_Impl {
4524 template <
class FACTORY,
class ARG>
4525 static FalseType test(...);
4526 template <
class FACTORY,
class ARG>
4527 static TrueType test(
typename bsl::enable_if<
static_cast<bool>(
sizeof(
4528 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4529 (*(FACTORY *)0)->deleteObject((ARG *)0)),
4533template <
class FACTORY,
class ARG>
4534struct SharedPtr_IsFactoryFor {
4536 sizeof(SharedPtr_IsFactoryFor_Impl::test<FACTORY, ARG>(0)) == 1
4541struct SharedPtr_IsNullableFactory_Impl {
4566 template <
class FACTORY>
4567 static FalseType test(...);
4568 template <
class FACTORY>
4569 static TrueType test(
typename bsl::enable_if<
static_cast<bool>(
sizeof(
4570 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4571 (*(FACTORY *)0)->deleteObject(
nullptr)),
4575template <
class FACTORY>
4576struct SharedPtr_IsNullableFactory {
4578 sizeof(SharedPtr_IsNullableFactory_Impl::test<FACTORY>(0)) == 1
4583template <
class SOURCE_TYPE,
class DEST_TYPE>
4584struct SharedPtr_IsPointerConvertible_Impl
4587template <
class SOURCE_TYPE,
class DEST_TYPE>
4588struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[]>
4591template <
class SOURCE_TYPE,
class DEST_TYPE,
size_t DEST_SIZE>
4592struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[DEST_SIZE]>
4594 DEST_TYPE (*)[DEST_SIZE]>::type {};
4597template <
class SOURCE_TYPE,
class DEST_TYPE>
4598struct SharedPtr_IsPointerConvertible
4599: SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4602template <
class SOURCE_TYPE,
class DEST_TYPE>
4603struct SharedPtr_IsPointerCompatible_Impl
4606template <
class TYPE,
size_t SIZE>
4607struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], TYPE[]>
4610template <
class TYPE,
size_t SIZE>
4611struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const TYPE[]>
4614template <
class TYPE,
size_t SIZE>
4615struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], volatile TYPE[]>
4618template <
class TYPE,
size_t SIZE>
4619struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const volatile TYPE[]>
4623template <
class SOURCE_TYPE,
class DEST_TYPE>
4624struct SharedPtr_IsPointerCompatible
4625: SharedPtr_IsPointerCompatible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4637template<
class ELEMENT_TYPE>
4645template<
class ELEMENT_TYPE>
4654template<
class ELEMENT_TYPE>
4661template<
class ELEMENT_TYPE>
4671template<
class ELEMENT_TYPE>
4679template<
class ELEMENT_TYPE>
4687template<
class ELEMENT_TYPE>
4695template<
class ELEMENT_TYPE>
4709template <
class ELEMENT_TYPE>
4710template <
class INPLACE_REP>
4712BloombergLP::bslma::SharedPtrRep *
4716 BloombergLP::bslma::SharedPtrRep *rep)
4721template <
class ELEMENT_TYPE>
4722template <
class COMPATIBLE_TYPE,
class ALLOCATOR>
4724BloombergLP::bslma::SharedPtrRep *
4725shared_ptr<ELEMENT_TYPE>::makeInternalRep(
4726 COMPATIBLE_TYPE *ptr,
4728 BloombergLP::bslma::Allocator *allocator)
4730 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4732 BloombergLP::bslma::Allocator *>
4735 return RepMaker::makeOutofplaceRep(ptr, allocator, allocator);
4738template <
class ELEMENT_TYPE>
4739template <
class COMPATIBLE_TYPE,
class DELETER>
4741BloombergLP::bslma::SharedPtrRep *
4742shared_ptr<ELEMENT_TYPE>::makeInternalRep(COMPATIBLE_TYPE *ptr,
4746 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<COMPATIBLE_TYPE,
4747 DELETER *> RepMaker;
4749 return RepMaker::makeOutofplaceRep(ptr, deleter, 0);
4753template <
class ELEMENT_TYPE>
4762template <
class ELEMENT_TYPE>
4771template <
class ELEMENT_TYPE>
4772template <
class CONVERTIBLE_TYPE
4778 typedef BloombergLP::bslstl::SharedPtr_DefaultDeleter<
4780 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4783 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, Deleter(), 0);
4785 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4790template <
class ELEMENT_TYPE>
4791template <
class CONVERTIBLE_TYPE
4795 CONVERTIBLE_TYPE *ptr,
4796 BloombergLP::bslma::Allocator *basicAllocator)
4799 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4801 BloombergLP::bslma::Allocator *>
4804 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, basicAllocator, basicAllocator);
4806 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4811template <
class ELEMENT_TYPE>
4815 BloombergLP::bslma::SharedPtrRep *rep)
4819 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4823template <
class ELEMENT_TYPE>
4827 BloombergLP::bslma::SharedPtrRep *rep,
4828 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr)
4834template <
class ELEMENT_TYPE>
4835template <
class CONVERTIBLE_TYPE,
4843, d_rep_p(makeInternalRep(ptr, dispatch, dispatch))
4846 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4851template <
class ELEMENT_TYPE>
4852template <
class CONVERTIBLE_TYPE,
4858 CONVERTIBLE_TYPE *ptr,
4860 BloombergLP::bslma::Allocator *basicAllocator)
4863 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4866 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, deleter, basicAllocator);
4868 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4873template <
class ELEMENT_TYPE>
4874template <
class CONVERTIBLE_TYPE,
4882 ALLOCATOR basicAllocator,
4883 typename ALLOCATOR::value_type *)
4886#ifdef BSLS_PLATFORM_CMP_MSVC
4894 DELETER>::type DeleterType;
4896 typedef DELETER DeleterType;
4900 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<CONVERTIBLE_TYPE,
4902 ALLOCATOR> RepMaker;
4904 d_rep_p = RepMaker::makeOutofplaceRep(
ptr, deleter, basicAllocator);
4906 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
ptr,
4911template <
class ELEMENT_TYPE>
4914 BloombergLP::bslma::Allocator *)
4920template <
class ELEMENT_TYPE>
4921template <
class DELETER
4927 BloombergLP::bslma::Allocator *basicAllocator)
4930 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<ELEMENT_TYPE,
4938 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
4944template <
class ELEMENT_TYPE>
4945template <
class DELETER,
class ALLOCATOR
4951 ALLOCATOR basicAllocator,
4952 typename ALLOCATOR::value_type *)
4955#ifdef BSLS_PLATFORM_CMP_MSVC
4963 DELETER>::type DeleterType;
4965 typedef DELETER DeleterType;
4969 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<ELEMENT_TYPE,
4971 ALLOCATOR> RepMaker;
4973 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
4978template <
class ELEMENT_TYPE>
4979template <
class CONVERTIBLE_TYPE
4982 BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE> managedPtr,
4983 BloombergLP::bslma::Allocator *basicAllocator)
4984: d_ptr_p(managedPtr.ptr())
4987 typedef BloombergLP::bslma::SharedPtrInplaceRep<
4988 BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE> > Rep;
4991 ELEMENT_TYPE *pPotentiallyShared =
static_cast<ELEMENT_TYPE *
>(
4994 if (&BloombergLP::bslma::SharedPtrRep::managedPtrDeleter ==
4996 d_rep_p =
static_cast<BloombergLP::bslma::SharedPtrRep *
>
4999 else if (&BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter ==
5006 BloombergLP::bslma::Default::allocator(basicAllocator);
5007 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5012 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5018#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
5019template <
class ELEMENT_TYPE>
5020template <
class CONVERTIBLE_TYPE
5023 std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr,
5024 BloombergLP::bslma::Allocator *basicAllocator)
5025: d_ptr_p(autoPtr.
get())
5028 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5029 std::auto_ptr<CONVERTIBLE_TYPE> > Rep;
5033 BloombergLP::bslma::Default::allocator(basicAllocator);
5034 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5035 (*
rep->ptr()) = autoPtr;
5037 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5043template <
class ELEMENT_TYPE>
5045 std::auto_ptr_ref<ELEMENT_TYPE> autoRef,
5046 BloombergLP::bslma::Allocator *basicAllocator)
5050 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5051 std::auto_ptr<ELEMENT_TYPE> > Rep;
5053 std::auto_ptr<ELEMENT_TYPE> autoPtr(autoRef);
5054 if (autoPtr.get()) {
5056 BloombergLP::bslma::Default::allocator(basicAllocator);
5057 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator);
5058 d_ptr_p = autoPtr.get();
5059 (*
rep->ptr()) = autoPtr;
5065#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
5066# if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
5067template <
class ELEMENT_TYPE>
5068template <
class COMPATIBLE_TYPE,
5069 class UNIQUE_DELETER,
5070 typename enable_if<is_convertible<
5071 typename std::unique_ptr<COMPATIBLE_TYPE,
5072 UNIQUE_DELETER>::pointer,
5073 ELEMENT_TYPE *>::value>::type *>
5075 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee,
5076 BloombergLP::bslma::Allocator *basicAllocator)
5077: d_ptr_p(adoptee.
get())
5080 typedef BloombergLP::bslma::SharedPtrInplaceRep<
5081 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER> > Rep;
5085 BloombergLP::bslma::Default::allocator(basicAllocator);
5086 Rep *
rep =
new (*basicAllocator) Rep(basicAllocator,
5087 BloombergLP::bslmf::MovableRefUtil::move(adoptee));
5089 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
5097template <
class ELEMENT_TYPE>
5098template <
class ANY_TYPE>
5100 ELEMENT_TYPE *
object)
5103, d_rep_p(source.d_rep_p)
5106 d_rep_p->acquireRef();
5110template <
class ELEMENT_TYPE>
5111template <
class COMPATIBLE_TYPE
5115: d_ptr_p(other.d_ptr_p)
5116, d_rep_p(other.d_rep_p)
5119 d_rep_p->acquireRef();
5123template <
class ELEMENT_TYPE>
5126: d_ptr_p(original.d_ptr_p)
5127, d_rep_p(original.d_rep_p)
5130 d_rep_p->acquireRef();
5134template <
class ELEMENT_TYPE>
5136 (BloombergLP::bslmf::MovableRef<shared_ptr> original)
5138: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
5139, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
5141 BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p = 0;
5142 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
5145#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5146template <
class ELEMENT_TYPE>
5147template <
class COMPATIBLE_TYPE
5151: d_ptr_p(other.d_ptr_p)
5152, d_rep_p(other.d_rep_p)
5158template <
class ELEMENT_TYPE>
5159template <
class COMPATIBLE_TYPE
5164: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p)
5165, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p)
5167 BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p = 0;
5168 BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p = 0;
5172template <
class ELEMENT_TYPE>
5173template <
class COMPATIBLE_TYPE
5190 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
5196#if !defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5197template <
class ELEMENT_TYPE>
5198template <
class COMPATIBLE_TYPE
5218 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
5225template <
class ELEMENT_TYPE>
5229 d_rep_p->releaseRef();
5234template <
class ELEMENT_TYPE>
5242 if (rhs.d_rep_p == d_rep_p) {
5243 d_ptr_p = rhs.d_ptr_p;
5252template <
class ELEMENT_TYPE>
5255 BloombergLP::bslmf::MovableRef<shared_ptr> rhs)
5261 shared_ptr(BloombergLP::bslmf::MovableRefUtil::move(rhs)).
swap(*
this);
5266template <
class ELEMENT_TYPE>
5267template <
class COMPATIBLE_TYPE>
5277 if (rhs.d_rep_p == d_rep_p) {
5278 d_ptr_p = rhs.d_ptr_p;
5287#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5288template <
class ELEMENT_TYPE>
5289template <
class COMPATIBLE_TYPE>
5295template <
class ELEMENT_TYPE>
5296template <
class COMPATIBLE_TYPE>
5307 shared_ptr(BloombergLP::bslmf::MovableRefUtil::move(rhs)).
swap(*
this);
5312template <
class ELEMENT_TYPE>
5313template <
class COMPATIBLE_TYPE>
5319 BloombergLP::bslma::ManagedPtr<COMPATIBLE_TYPE> rhs)
5325#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
5326template <
class ELEMENT_TYPE>
5327template <
class COMPATIBLE_TYPE>
5334 SelfType(rhs).
swap(*
this);
5339#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
5340template <
class ELEMENT_TYPE>
5341template <
class COMPATIBLE_TYPE,
class UNIQUE_DELETER>
5345 typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer,
5346 ELEMENT_TYPE *>::value,
5347 shared_ptr<ELEMENT_TYPE>&>::type
5349 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& rhs)
5351 SelfType(BloombergLP::bslmf::MovableRefUtil::move(rhs)).
swap(*
this);
5356template <
class ELEMENT_TYPE>
5360 BloombergLP::bslma::SharedPtrRep *rep = d_rep_p;
5373template <
class ELEMENT_TYPE>
5374template <
class COMPATIBLE_TYPE>
5383template <
class ELEMENT_TYPE>
5384template <
class COMPATIBLE_TYPE,
class DELETER>
5394template <
class ELEMENT_TYPE>
5395template <
class COMPATIBLE_TYPE,
class DELETER,
class ALLOCATOR>
5401 ALLOCATOR basicAllocator)
5406template <
class ELEMENT_TYPE>
5407template <
class ANY_TYPE>
5415 if (source.d_rep_p == d_rep_p && ptr) {
5423template <
class ELEMENT_TYPE>
5437 d_ptr_p = other.d_ptr_p;
5438 other.d_ptr_p = tempPtr_p;
5440 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
5441 d_rep_p = other.d_rep_p;
5442 other.d_rep_p = tempRep_p;
5446template<
class ELEMENT_TYPE>
5450 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5452 BloombergLP::bslma::Allocator *basicAllocator =
5453 BloombergLP::bslma::Default::allocator();
5455 Rep *rep =
new (*basicAllocator) Rep(basicAllocator);
5459#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
5460template <
class ELEMENT_TYPE>
5461template <
class... ARGS>
5464 BloombergLP::bslma::Allocator *basicAllocator,
5467 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5469 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5470 Rep *rep =
new (*basicAllocator) Rep(basicAllocator,
5476template <
class ELEMENT_TYPE>
5477template <
class ANY_TYPE>
5480 ELEMENT_TYPE *
object)
5482 if (source.d_rep_p == d_rep_p &&
object) {
5490template <
class ELEMENT_TYPE>
5501#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5503template <
class ELEMENT_TYPE>
5510template <
class ELEMENT_TYPE>
5511template <
class COMPATIBLE_TYPE>
5518template <
class ELEMENT_TYPE>
5519template <
class COMPATIBLE_TYPE>
5523 BloombergLP::bslma::Allocator *basicAllocator)
5528template <
class ELEMENT_TYPE>
5529template <
class COMPATIBLE_TYPE,
class DELETER>
5533 const DELETER& deleter,
5534 BloombergLP::bslma::Allocator *basicAllocator)
5541template <
class ELEMENT_TYPE>
5543#if defined(BSLS_PLATFORM_CMP_IBM)
5550 return BloombergLP::bsls::UnspecifiedBool<shared_ptr>::makeValue(d_ptr_p);
5553template <
class ELEMENT_TYPE>
5563template <
class ELEMENT_TYPE>
5571template <
class ELEMENT_TYPE>
5579template <
class ELEMENT_TYPE>
5586 return *(d_ptr_p + index);
5589template <
class ELEMENT_TYPE>
5590template<
class ANY_TYPE>
5595 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5598template <
class ELEMENT_TYPE>
5599template<
class ANY_TYPE>
5605 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5608template <
class ELEMENT_TYPE>
5609template<
class ANY_TYPE>
5614 return rep() == other.rep();
5617template <
class ELEMENT_TYPE>
5618template<
class ANY_TYPE>
5624 return rep() == other.rep();
5627template <
class ELEMENT_TYPE>
5635template <
class ELEMENT_TYPE>
5639 return 1 == use_count();
5642template <
class ELEMENT_TYPE>
5646 return d_rep_p ? d_rep_p->numReferences() : 0;
5650template <
class ELEMENT_TYPE>
5651BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>
5654 if (d_rep_p && d_ptr_p) {
5655 d_rep_p->acquireRef();
5656 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(d_ptr_p,
5658 &BloombergLP::bslma::SharedPtrRep::managedPtrDeleter);
5662 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(
5664 (BloombergLP::bslma::SharedPtrRep *)0,
5665 &BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter);
5668template <
class ELEMENT_TYPE>
5676#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5678template <
class ELEMENT_TYPE>
5682 return d_rep_p ? d_rep_p->numReferences() : 0;
5685template <
class ELEMENT_TYPE>
5699template <
class ELEMENT_TYPE>
5708template <
class ELEMENT_TYPE>
5710 BloombergLP::bslmf::MovableRef<weak_ptr> original)
5712: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
5713, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
5715 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
5719#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5720template <
class ELEMENT_TYPE>
5721template <
class COMPATIBLE_TYPE
5725: d_ptr_p(original.d_ptr_p)
5726, d_rep_p(original.d_rep_p)
5728 original.d_rep_p = 0;
5732template <
class ELEMENT_TYPE>
5733template <
class CONVERTIBLE_TYPE
5738: d_ptr_p(original.d_ptr_p)
5739, d_rep_p(original.d_rep_p)
5741 original.d_rep_p = 0;
5746template <
class ELEMENT_TYPE>
5749: d_ptr_p(original.d_ptr_p)
5750, d_rep_p(original.d_rep_p)
5753 d_rep_p->acquireWeakRef();
5757template <
class ELEMENT_TYPE>
5758template <
class COMPATIBLE_TYPE
5762: d_ptr_p(other.get())
5763, d_rep_p(other.rep())
5766 d_rep_p->acquireWeakRef();
5770template <
class ELEMENT_TYPE>
5771template <
class COMPATIBLE_TYPE
5775: d_ptr_p(other.d_ptr_p)
5776, d_rep_p(other.d_rep_p)
5779 d_rep_p->acquireWeakRef();
5783template <
class ELEMENT_TYPE>
5788 d_rep_p->releaseWeakRef();
5793template <
class ELEMENT_TYPE>
5796 BloombergLP::bslma::SharedPtrRep *rep,
5797 ELEMENT_TYPE *target)
5800 d_rep_p->releaseWeakRef();
5805 d_rep_p->acquireWeakRef();
5809template <
class ELEMENT_TYPE>
5811 BloombergLP::bslmf::MovableRef<weak_ptr> rhs)
5814 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
5819#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5820template <
class ELEMENT_TYPE>
5821template <
class COMPATIBLE_TYPE>
5828 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
5833template <
class ELEMENT_TYPE>
5834template <
class COMPATIBLE_TYPE>
5836 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5837 weak_ptr<ELEMENT_TYPE>&>::type
5842 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
5848template <
class ELEMENT_TYPE>
5858 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
5863template <
class ELEMENT_TYPE>
5864template <
class COMPATIBLE_TYPE>
5876 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
5881template <
class ELEMENT_TYPE>
5882template <
class COMPATIBLE_TYPE>
5894 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
5899template <
class ELEMENT_TYPE>
5904 d_rep_p->releaseWeakRef();
5911template <
class ELEMENT_TYPE>
5922 ELEMENT_TYPE *tempPtr_p = d_ptr_p;
5923 d_ptr_p = other.d_ptr_p;
5924 other.d_ptr_p = tempPtr_p;
5926 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
5927 d_rep_p = other.d_rep_p;
5928 other.d_rep_p = tempRep_p;
5932template <
class ELEMENT_TYPE>
5936 return !(d_rep_p && d_rep_p->numReferences());
5939template <
class ELEMENT_TYPE>
5943 if (d_rep_p && d_rep_p->tryAcquireRef()) {
5947 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr());
5953template <
class ELEMENT_TYPE>
5954template <
class ANY_TYPE>
5960 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
5964template <
class ELEMENT_TYPE>
5965template <
class ANY_TYPE>
5971 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
5975template <
class ELEMENT_TYPE>
5976template<
class ANY_TYPE>
5982 return rep() == other.rep();
5985template <
class ELEMENT_TYPE>
5986template<
class ANY_TYPE>
5992 return rep() == other.rep();
5995template <
class ELEMENT_TYPE>
6003template <
class ELEMENT_TYPE>
6011template <
class ELEMENT_TYPE>
6015 return d_rep_p ? d_rep_p->numReferences() : 0;
6018#ifndef BDE_OMIT_INTERNAL_DEPRECATED
6020template <
class ELEMENT_TYPE>
6028template <
class ELEMENT_TYPE>
6032 return d_rep_p ? d_rep_p->numReferences() : 0;
6045template <
class SHARED_TYPE,
class ENABLE_TYPE>
6053 if (0 != result && result->d_weakThis.expired()) {
6054 result->d_weakThis.privateAssign(
6056 const_cast <ENABLE_TYPE *
>(
6057 static_cast<ENABLE_TYPE const*
>(sharedPtr->d_ptr_p)));
6068template <
class TYPE>
6073 return const_cast<TYPE *
>(address);
6076template <
class TYPE>
6080 return static_cast<void *
>(
6089template <
class TARGET,
class SOURCE>
6096 target->
reset(source,
const_cast<TARGET *
>(source.
get()));
6099template <
class TARGET,
class SOURCE>
6106 const_cast<TARGET *
>(source.get()));
6109template <
class TARGET,
class SOURCE>
6116 if (TARGET *castPtr =
dynamic_cast<TARGET *
>(source.
get())) {
6117 target->
reset(source, castPtr);
6124template <
class TARGET,
class SOURCE>
6130 if (TARGET *castPtr =
dynamic_cast<TARGET *
>(source.get())) {
6137template <
class TARGET,
class SOURCE>
6144 target->
reset(source,
static_cast<TARGET *
>(source.
get()));
6147template <
class TARGET,
class SOURCE>
6154 static_cast<TARGET *
>(source.get()));
6174template <
class ANY_TYPE>
6183template <
class ANY_TYPE>
6207 d_rep_p->disposeRep();
6222template <
class LHS_TYPE,
class RHS_TYPE>
6224bool bsl::operator==(
const shared_ptr<LHS_TYPE>& lhs,
6227 return lhs.get() == rhs.get();
6230#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6232template<
class LHS_TYPE,
class RHS_TYPE>
6234bsl::strong_ordering bsl::operator<=>(
const shared_ptr<LHS_TYPE>& lhs,
6235 const shared_ptr<RHS_TYPE>& rhs)
6238 const void *p1 = lhs.get(),
6245template <
class LHS_TYPE,
class RHS_TYPE>
6250 return !(lhs == rhs);
6253template <
class LHS_TYPE,
class RHS_TYPE>
6258 return std::less<const void *>()(lhs.get(), rhs.get());
6261template <
class LHS_TYPE,
class RHS_TYPE>
6269template <
class LHS_TYPE,
class RHS_TYPE>
6274 return !(rhs < lhs);
6277template <
class LHS_TYPE,
class RHS_TYPE>
6282 return !(lhs < rhs);
6287template <
class LHS_TYPE>
6295#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6299bsl::strong_ordering bsl::operator<=>(
const shared_ptr<TYPE>& ptr,
6302 const typename shared_ptr<TYPE>::element_type *null =
nullptr;
6303 return ptr.get() <=> null;
6308template <
class RHS_TYPE>
6316template <
class LHS_TYPE>
6321 return static_cast<bool>(lhs);
6324template <
class RHS_TYPE>
6329 return static_cast<bool>(rhs);
6332template <
class LHS_TYPE>
6337 return std::less<LHS_TYPE *>()(lhs.get(), 0);
6340template <
class RHS_TYPE>
6345 return std::less<RHS_TYPE *>()(0, rhs.get());
6348template <
class LHS_TYPE>
6353 return !std::less<LHS_TYPE *>()(0, lhs.get());
6356template <
class RHS_TYPE>
6361 return !std::less<RHS_TYPE *>()(rhs.get(), 0);
6364template <
class LHS_TYPE>
6369 return std::less<LHS_TYPE *>()(0, lhs.get());
6372template <
class RHS_TYPE>
6377 return std::less<RHS_TYPE *>()(rhs.get(), 0);
6380template <
class LHS_TYPE>
6385 return !std::less<LHS_TYPE *>()(lhs.get(), 0);
6388template <
class RHS_TYPE>
6393 return !std::less<RHS_TYPE *>()(0, rhs.get());
6398template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ELEMENT_TYPE>
6400std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
6402 const shared_ptr<ELEMENT_TYPE>& rhs)
6404 return stream << rhs.get();
6408template <
class HASHALG,
class ELEMENT_TYPE>
6410void bsl::hashAppend(HASHALG& hashAlg,
const shared_ptr<ELEMENT_TYPE>& input)
6415template <
class ELEMENT_TYPE>
6417void bsl::swap(shared_ptr<ELEMENT_TYPE>& a, shared_ptr<ELEMENT_TYPE>& b)
6423template <
class ELEMENT_TYPE>
6425void bsl::swap(weak_ptr<ELEMENT_TYPE>& a, weak_ptr<ELEMENT_TYPE>& b)
6432template<
class DELETER,
class ELEMENT_TYPE>
6437 BloombergLP::bslma::SharedPtrRep *rep = p.rep();
6438 return rep ?
static_cast<DELETER *
>(rep->getDeleter(
typeid(DELETER))) : 0;
6442template<
class TO_TYPE,
class FROM_TYPE>
6448 return shared_ptr<TO_TYPE>(source,
const_cast<TO_TYPE *
>(source.get()));
6451template<
class TO_TYPE,
class FROM_TYPE>
6457 if (TO_TYPE *castPtr =
dynamic_cast<TO_TYPE *
>(source.get())) {
6458 return shared_ptr<TO_TYPE>(source, castPtr);
6461 return shared_ptr<TO_TYPE>();
6464template<
class TO_TYPE,
class FROM_TYPE>
6470 return shared_ptr<TO_TYPE>(source,
static_cast<TO_TYPE *
>(source.get()));
6473template<
class TO_TYPE,
class FROM_TYPE>
6479 return shared_ptr<TO_TYPE>(source,
6480 reinterpret_cast<TO_TYPE *
>(source.get()));
6489#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6492template<
class ELEMENT_TYPE,
class ALLOC,
class... ARGS>
6498 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6500 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<ELEMENT_TYPE,
6502 Rep *rep_p = Rep::makeRep(basicAllocator);
6504 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6507 ImpUtil::unqualify(rep_p->ptr()),
6510 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6514template<
class ARRAY_TYPE,
class ALLOC>
6521 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6524 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6525 typedef BloombergLP::bslstl::
6526 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6528 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6529 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6531 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6532 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
6533 static_cast<Element_type *
> (rep_p->ptr()),
6535 ElementAllocatorType(basicAllocator));
6538 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6539 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6542template<
class ARRAY_TYPE,
class ALLOC>
6548 ALLOC basicAllocator,
6551 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6554 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6555 typedef BloombergLP::bslstl::
6556 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6558 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6559 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6561 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6562 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6563 static_cast<Element_type *
> (rep_p->ptr()),
6566 ElementAllocatorType(basicAllocator));
6569 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6570 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6573template<
class ARRAY_TYPE,
class ALLOC>
6582 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6583 typedef BloombergLP::bslstl::
6584 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6586 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6588 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6589 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
6590 static_cast<Element_type *
> (rep_p->ptr()),
6592 ElementAllocatorType(basicAllocator));
6595 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6596 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6599template<
class ARRAY_TYPE,
class ALLOC>
6605 ALLOC basicAllocator,
6611 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6612 typedef BloombergLP::bslstl::
6613 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6615 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6617 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6618 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6619 static_cast<Element_type *
> (rep_p->ptr()),
6622 ElementAllocatorType(basicAllocator));
6625 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6626 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6633template<
class ELEMENT_TYPE,
class ALLOC>
6640 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6642 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<ELEMENT_TYPE,
6644 Rep *rep_p = Rep::makeRep(basicAllocator);
6646 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6647 ::new (ImpUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
6650 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6653template<class ARRAY_TYPE, class ALLOC>
6655typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value &&
6656 !
bsl::is_pointer<ALLOC>::value,
6657 bsl::shared_ptr<ARRAY_TYPE> >::type
6658bsl::allocate_shared_for_overwrite(ALLOC basicAllocator)
6660 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6661 typedef BloombergLP::bslstl::
6662 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6664 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6665 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6667 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6668 ::new (ImpUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
6671 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6672 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6675template<class ARRAY_TYPE, class ALLOC>
6677typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value &&
6678 !
bsl::is_pointer<ALLOC>::value,
6679 bsl::shared_ptr<ARRAY_TYPE> >::type
6680bsl::allocate_shared_for_overwrite(ALLOC basicAllocator,
size_t numElements)
6682 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6684 typedef BloombergLP::bslstl::
6685 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
6687 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6689 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6690 ::new (ImpUtil::voidify(rep_p->ptr())) Element_type[numElements];
6693 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6694 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6701#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6702template<
class ELEMENT_TYPE,
class ALLOC,
class... ARGS>
6709 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6713 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<
6716 AllocatorType alloc(basicAllocator);
6717 Rep *rep_p = Rep::makeRep(alloc);
6719 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6720 AllocatorTraits::construct(alloc,
6721 ImpUtil::unqualify(rep_p->ptr()),
6724 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6728template<
class ARRAY_TYPE,
class ALLOC>
6734 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6736 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6740 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6741 AllocatorType alloc(basicAllocator);
6742 Rep *rep_p = Rep::makeRep(alloc, numElements);
6744 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6745 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
6750 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6751 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6754template<
class ARRAY_TYPE,
class ALLOC>
6759 ALLOC *basicAllocator,
6762 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6765 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6769 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6770 AllocatorType alloc(basicAllocator);
6771 Rep *rep_p = Rep::makeRep(alloc, numElements);
6773 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6774 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6775 static_cast<Element_type *
> (rep_p->ptr()),
6781 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6782 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6785template<
class ARRAY_TYPE,
class ALLOC>
6792 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6795 AllocatorType alloc(basicAllocator);
6796 Rep *rep_p = Rep::makeRep(alloc, numElements);
6798 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6799 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
6804 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6805 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6808template<
class ARRAY_TYPE,
class ALLOC>
6813 ALLOC *basicAllocator,
6819 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6822 AllocatorType alloc(basicAllocator);
6823 Rep *rep_p = Rep::makeRep(alloc, numElements);
6825 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6826 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6827 static_cast<Element_type *
> (rep_p->ptr()),
6833 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6834 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6841template<
class ELEMENT_TYPE,
class ALLOC>
6847 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6850 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<
6853 AllocatorType alloc(basicAllocator);
6854 Rep *rep_p = Rep::makeRep(alloc);
6856 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6857 ::new (ImpUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
6860 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6864template<class ARRAY_TYPE, class ALLOC>
6866typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value,
6867 bsl::shared_ptr<ARRAY_TYPE> >::type
6868bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator)
6870 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6872 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6876 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6877 AllocatorType alloc(basicAllocator);
6878 Rep *rep_p = Rep::makeRep(alloc, numElements);
6880 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6881 ::new (ImpUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
6884 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6885 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6888template<class ARRAY_TYPE, class ALLOC>
6890typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value,
6891 bsl::shared_ptr<ARRAY_TYPE> >::type
6892bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator,
size_t numElements)
6894 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6897 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6900 AllocatorType alloc(basicAllocator);
6901 Rep *rep_p = Rep::makeRep(alloc, numElements);
6903 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6904 ::new (ImpUtil::voidify(rep_p->ptr())) Element_type[numElements];
6907 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
6908 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6915#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6918template<
class ELEMENT_TYPE,
class... ARGS>
6924 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6927 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<
6931 AllocatorType basicAllocator;
6932 Rep *rep_p = Rep::makeRep(basicAllocator);
6934 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6935 ::new (ImpUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
6939 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6943template<
class ARRAY_TYPE>
6949 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6953 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6954 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6958 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6959 AllocatorType basicAllocator;
6960 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6962 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6963 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
6966 ElementAllocatorType(basicAllocator));
6969 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
6970 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
6973template<
class ARRAY_TYPE>
6979 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
6983 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
6984 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
6988 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
6989 AllocatorType basicAllocator;
6990 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
6992 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6993 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
6997 ElementAllocatorType(basicAllocator));
7000 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7001 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7004template<
class ARRAY_TYPE>
7013 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7014 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7018 AllocatorType basicAllocator;
7019 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7021 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7022 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
7025 ElementAllocatorType(basicAllocator));
7028 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7029 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7032template<
class ARRAY_TYPE>
7043 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7044 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7048 AllocatorType basicAllocator;
7049 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7051 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7052 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
7056 ElementAllocatorType(basicAllocator));
7059 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7060 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7067template<
class ELEMENT_TYPE>
7073 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7076 typedef BloombergLP::bslstl::SharedPtrAllocateInplaceRep<
7080 AllocatorType basicAllocator;
7081 Rep *rep_p = Rep::makeRep(basicAllocator);
7083 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7084 ::new (ImpUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
7087 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7090template<class ARRAY_TYPE>
7092typename
bsl::enable_if<
bsl::is_bounded_array<ARRAY_TYPE>::value,
7093 bsl::shared_ptr<ARRAY_TYPE> >::type
7094bsl::make_shared_for_overwrite()
7096 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7098 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7102 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7103 AllocatorType basicAllocator;
7104 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7106 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7107 ::new (ImpUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
7111 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
7112 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7115template<class ARRAY_TYPE>
7117typename
bsl::enable_if<
bsl::is_unbounded_array<ARRAY_TYPE>::value,
7118 bsl::shared_ptr<ARRAY_TYPE> >::type
7119bsl::make_shared_for_overwrite(
size_t numElements)
7121 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7124 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
7128 AllocatorType basicAllocator;
7129 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7131 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7132 ::new (ImpUtil::voidify(rep_p->ptr())) Element_type[numElements];
7136 BloombergLP::
bslma::SharedPtrRep *upcastRep = rep_p;
7137 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7160template <
class ELEMENT_TYPE>
7169template <
class ELEMENT_TYPE>
7174template <
class ELEMENT_TYPE>
7179template <
class ELEMENT_TYPE>
7188#if defined(BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC)
7189# pragma GCC diagnostic pop
7192#undef BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE
7193#undef BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE
7195#undef BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE
7196#undef BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE
7198#undef BSLSTL_SHAREDPTR_DECLARE_IF_DELETER
7199#undef BSLSTL_SHAREDPTR_DEFINE_IF_DELETER
7201#undef BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER
7202#undef BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER
7204#undef BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND
7206#undef BSLSTL_SHAREDPTR_SFINAE_DISCARD