BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_sharedptr_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_sharedptr_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_sharedptr_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_SHAREDPTR_CPP03
12#define INCLUDED_BSLSTL_SHAREDPTR_CPP03
13
14/// @defgroup bslstl_sharedptr_cpp03 bslstl_sharedptr_cpp03
15/// @brief Provide C++03 implementation for bslstl_sharedptr.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_sharedptr_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_sharedptr_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_sharedptr_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_sharedptr_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_sharedptr_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_sharedptr.h
30///
31/// # Classes {#bslstl_sharedptr_cpp03-classes}
32/// See bslstl_sharedptr.h for list of classes
33///
34/// @see bslstl_sharedptr
35///
36/// # Description {#bslstl_sharedptr_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Tue Jun 2 21:32:21 2026
48/// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_sharedptr_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_SHAREDPTR_H
64
65#if defined(BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC)
66 // Here and throughout the file wherever `auto_ptr` is used, suspend
67 // GCC reporting of deprecated declarations since the use of `auto_ptr`
68 // in this standard interface is required.
69# pragma GCC diagnostic push
70# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
71#endif
72
73#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS)
74# define BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS 1
75
76# if BSLS_PLATFORM_CMP_VERSION >= 1910 && \
77 BSLS_PLATFORM_CMP_VERSION < 1920 && \
78 BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
79// Visual Studio 2017 in C++17 mode crashes with an internal compiler error on
80// the shared pointer SFINAE code. See {DRQS 148281696}.
81# undef BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS
82# endif
83
84// If the macro `BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS` is defined, then a
85// conforming C++11 compiler will define the constructors in this component in
86// such a way that they will not be selected during overload resolution unless
87// they would instantiate correctly. This means that code depending on the
88// result of `is_constructible` and similar traits will have the expected
89// behavior. There is no attempt to support this feature in C++03.
90//
91// Support for SFINAE-queries on the constructability of a `shared_ptr` depend
92// on a variety of C++11 language features, including "expression-SFINAE".
93// However, the main language feature that enables SFINAE elimination of a
94// constructor is the ability to use default template arguments in a function
95// template. It is significantly preferred to use the template parameter list,
96// rather than add additional default arguments to the constructor signatures,
97// as there are so many constructor overloads in this component that there is a
98// real risk of introducing ambiguities that would need to be worked around.
99// Therefore, the `BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS` macro
100// serves as our proxy for whether SFINAE-constructors are enabled in this
101// component. Note that the MSVC 2015 compiler almost supported
102// "expression-SFINAE", to the extent that it works for this component, unlike
103// earlier versions of that compiler. We therefore make a special version-test
104// on Microsoft in addition to the feature testing.
105#endif
106
107#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
108// Note the intentional comma in the first line of the definition of each
109// macro, which allows these macros to be applied incrementally, even when the
110// alternate definition is empty. This avoids the problem of introducing new
111// template parameters along with the macros in the non-SFINAE-supporting case
112// below.
113# define BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE , \
114 typename enable_if< \
115 BloombergLP::bslstl::SharedPtr_IsPointerConvertible< \
116 CONVERTIBLE_TYPE, \
117 ELEMENT_TYPE>::value>::type * \
118 = nullptr
119
120# define BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE , \
121 typename enable_if< \
122 BloombergLP::bslstl::SharedPtr_IsPointerConvertible< \
123 CONVERTIBLE_TYPE, \
124 ELEMENT_TYPE>::value>::type *
125
126
127# define BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE , \
128 typename enable_if< \
129 BloombergLP::bslstl::SharedPtr_IsPointerCompatible< \
130 COMPATIBLE_TYPE, \
131 ELEMENT_TYPE>::value>::type * \
132 = nullptr
133
134# define BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE , \
135 typename enable_if< \
136 BloombergLP::bslstl::SharedPtr_IsPointerCompatible< \
137 COMPATIBLE_TYPE, \
138 ELEMENT_TYPE>::value>::type *
139
140
141# define BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(FUNCTOR, ARGUMENT) , \
142 typename enable_if< \
143 BloombergLP::bslstl::SharedPtr_IsCallable <FUNCTOR, \
144 ARGUMENT *>::k_VALUE || \
145 BloombergLP::bslstl::SharedPtr_IsFactoryFor<FUNCTOR, \
146 ARGUMENT>::k_VALUE>::type * \
147 = nullptr
148
149# define BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(FUNCTOR, ARGUMENT) , \
150 typename enable_if< \
151 BloombergLP::bslstl::SharedPtr_IsCallable <FUNCTOR, \
152 ARGUMENT *>::k_VALUE || \
153 BloombergLP::bslstl::SharedPtr_IsFactoryFor<FUNCTOR, \
154 ARGUMENT >::k_VALUE>::type *
155
156
157# define BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER(FUNCTOR) , \
158 typename enable_if< \
159 BloombergLP::bslstl::SharedPtr_IsCallable <FUNCTOR, \
160 nullptr_t>::k_VALUE || \
161 BloombergLP::bslstl::SharedPtr_IsNullableFactory< \
162 FUNCTOR>::k_VALUE>::type * = nullptr
163
164# define BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER(FUNCTOR) , \
165 typename enable_if< \
166 BloombergLP::bslstl::SharedPtr_IsCallable <FUNCTOR, \
167 nullptr_t>::k_VALUE || \
168 BloombergLP::bslstl::SharedPtr_IsNullableFactory< \
169 FUNCTOR>::k_VALUE>::type *
170#else
171// Do not attempt to support SFINAE in constructors in a C++03 compiler
172# define BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE
173# define BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE
174
175# define BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE
176# define BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE
177
178# define BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(FUNCTOR, ARGUMENT)
179# define BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(FUNCTOR, ARGUMENT)
180
181# define BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER(FUNCTOR)
182# define BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER(FUNCTOR)
183#endif // BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS
184
185// Some SFINAE checks, when enabled, make use of discarded-value expressions
186// (as the left-hand side of a comma operator). Clang compilers based on
187// versions of LLVM earlier than 12 contain a bug in which substitution
188// failures are not caught in discarded-value expressions when used in SFINAE
189// contexts (this includes Clang 11 and earlier, and Apple Clang 13 and
190// earlier). In order to ensure that these compilers catch substitution
191// failures in such expressions, this component does not discard them. Note
192// that this is dangerous, because not discarding the expression allows the
193// possibility that the comma operator will be overloaded on the type of the
194// expression, and so it is preferable to discard the expression where
195// possible.
196#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
197#if !defined(BSLS_PLATFORM_CMP_CLANG) || \
198 !defined(__apple_build_version__) && BSLS_PLATFORM_CMP_VERSION >= \
199 120000 || \
200 defined(__apple_build_version__) && BSLS_PLATFORM_CMP_VERSION > 130000
201# define BSLSTL_SHAREDPTR_SFINAE_DISCARD(EXPRESSION) \
202 static_cast<void>(EXPRESSION)
203# else
204# define BSLSTL_SHAREDPTR_SFINAE_DISCARD(EXPRESSION) \
205 (EXPRESSION)
206# endif
207#endif
208
209
210namespace bslstl {
211
212/// This `struct` is for internal use only, providing a tag for `shared_ptr`
213/// constructors to recognize that a passed `SharedPtrRep` was obtained from
214/// an existing `shared_ptr` object.
215///
216/// See @ref bslstl_sharedptr_cpp03
217struct SharedPtr_RepFromExistingSharedPtr {
218};
219
220/// Forward declaration of `SharedPtr_ImpUtil`. This is needed because this
221/// struct is a friend of @ref enable_shared_from_this in the `bsl` namespace.
222struct SharedPtr_ImpUtil;
223
224#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
225/// Forward declaration of component-private type trait to indicate whether
226/// an object of (template parameter) type `FUNCTOR` can be called as a
227/// function with an argument of (template parameter) type `ARG`
228template <class FUNCTOR, class ARG>
229struct SharedPtr_IsCallable;
230
231/// Forward declaration of component-private type trait to indicate whether
232/// a pointer to a `FACTORY` has a `deleteObject` member that can be called
233/// as `factory->deleteObject((ARG *)p)`.
234template <class FACTORY, class ARG>
235struct SharedPtr_IsFactoryFor;
236
237/// Forward declaration of component-private type trait to indicate whether
238/// a pointer to a `FACTORY` has a `deleteObject` member that can be called
239/// as `factory->deleteObject((ARG *)p)`.
240template <class FACTORY>
241struct SharedPtr_IsNullableFactory;
242
243/// Forward declaration of component-private type trait to indicate whether
244/// a pointer to a `SOURCE_TYPE` can be converted to a pointer to a
245/// `DEST_TYPE`. [util.smartptr.shared.const]/8 says "either DEST_TYPE is
246/// U[N] and SOURCE_TYPE(*)[N] is convertible to DEST_TYPE*, or DEST_TYPE is
247/// U[] and SOURCE_TYPE(*)[] is convertible to DEST_TYPE*".
248template <class SOURCE_TYPE, class DEST_TYPE>
249struct SharedPtr_IsPointerConvertible;
250
251/// Forward declaration of component-private type trait to indicate whether
252/// a pointer to a `SOURCE_TYPE` is compatible with a pointer to
253/// `DEST_TYPE`. [util.smartptr.shared]/5 says: "for the purposes of ...,
254/// a pointer type SOURCE_TYPE* is said to be compatible with a pointer type
255/// DEST_TYPE* when either SOURCE_TYPE* is convertible to DEST_TYPE* or
256/// SOURCE_TYPE is U[N] and DEST_TYPE is cv U[]."
257template <class SOURCE_TYPE, class DEST_TYPE>
258struct SharedPtr_IsPointerCompatible;
259
260#endif
261
262} // close package namespace
263
264
265namespace bsl {
266
267template<class ELEMENT_TYPE>
268class enable_shared_from_this;
269
270template <class ELEMENT_TYPE>
271class shared_ptr;
272
273template <class ELEMENT_TYPE>
274class weak_ptr;
275
276 // ================
277 // class shared_ptr
278 // ================
279
280/// This class provides a thread-safe reference-counted "smart pointer" to
281/// support "shared ownership" of objects: a shared pointer ensures that the
282/// shared object is destroyed, using the appropriate deletion method, only
283/// when there are no shared references to it. The object (of template
284/// parameter type `ELEMENT_TYPE`) referred to by a shared pointer may be
285/// accessed directly using the `->` operator, or the dereference operator
286/// (operator `*`) can be used to obtain a reference to that object.
287///
288///
289/// \note Note that the object referred to by a shared pointer representation is
290/// usually the same as the object referred to by that shared pointer (of
291/// the same `ELEMENT_TYPE`), but this need not always be true in the
292/// presence of conversions or "aliasing": the object referred to (of
293/// template parameter type `ELEMENT_TYPE`) by the shared pointer may differ
294/// from the object of type `COMPATIBLE_TYPE` (see the "Aliasing" section in
295/// the component-level documentation) referred to by the shared pointer
296/// representation.
297///
298/// More generally, this class supports a complete set of *in*-*core*
299/// pointer semantic operations.
300///
301/// See @ref bslstl_sharedptr_cpp03
302template <class ELEMENT_TYPE>
303class shared_ptr {
304
305 public:
306 // TRAITS
307 BSLMF_NESTED_TRAIT_DECLARATION(shared_ptr<ELEMENT_TYPE>,
309
310 // TYPES
311
312 /// For shared pointers to non-array types, @ref element_type is an alias
313 /// to the `ELEMENT_TYPE` template parameter. Otherwise, it is an alias
314 /// to the type contained in the array.
316
317 /// @ref weak_type is an alias to a weak pointer with the same element type
318 /// as this `shared_ptr`.
319 typedef weak_ptr<ELEMENT_TYPE> weak_type;
320
321 private:
322 // DATA
323 element_type *d_ptr_p; // pointer to the shared object
324
325 BloombergLP::bslma::SharedPtrRep *d_rep_p; // pointer to the representation
326 // object that manages the
327 // shared object
328
329 // PRIVATE TYPES
330
331 /// `SelfType` is an alias to this `class`, for compilers that do not
332 /// recognize plain `shared_ptr`.
333 typedef shared_ptr<ELEMENT_TYPE> SelfType;
334
335 typedef typename BloombergLP::bsls::UnspecifiedBool<shared_ptr>::BoolType
336 BoolType;
337
338 // FRIENDS
339 template <class COMPATIBLE_TYPE>
340 friend class shared_ptr;
341
343
344 private:
345 // PRIVATE CLASS METHODS
346
347 /// Return the specified `rep`.
348 template <class INPLACE_REP>
349 static BloombergLP::bslma::SharedPtrRep *makeInternalRep(
350 ELEMENT_TYPE *,
351 INPLACE_REP *,
352 BloombergLP::bslma::SharedPtrRep *rep);
353
354 /// Return the address of a new out-of-place representation for a shared
355 /// pointer that manages the specified `ptr` and uses the specified
356 /// `allocator` to destroy the object pointed to by `ptr`. Use
357 /// `allocator` to supply memory.
358 template <class COMPATIBLE_TYPE, class ALLOCATOR>
359 static BloombergLP::bslma::SharedPtrRep *makeInternalRep(
360 COMPATIBLE_TYPE *ptr,
361 ALLOCATOR *,
362 BloombergLP::bslma::Allocator *allocator);
363
364 /// Return the address of a new out-of-place representation for a shared
365 /// pointer that manages the specified `ptr` and uses the specified
366 /// `deleter` to destroy the object pointed to by `ptr`. Use the
367 /// currently installed default allocator to supply memory.
368 template <class COMPATIBLE_TYPE, class DELETER>
369 static BloombergLP::bslma::SharedPtrRep *makeInternalRep(
370 COMPATIBLE_TYPE *ptr,
371 DELETER *deleter,
372 ...);
373
374 public:
375 // CREATORS
376
377 /// Create an empty shared pointer, i.e., a shared pointer with no
378 /// representation that does not refer to any object and has no
379 /// deleter.
382
383 /// Create an empty shared pointer, i.e., a shared pointer with no
384 /// representation that does not refer to any object and has no
385 /// deleter.
388
389 /// Create a shared pointer that manages a modifiable object of
390 /// (template parameter) type `CONVERTIBLE_TYPE` and refers to the
391 /// specified `(ELEMENT_TYPE *)ptr`. The currently installed default
392 /// allocator is used to allocate and deallocate the internal
393 /// representation of the shared pointer. When all references have been
394 /// released, the object pointed to by the managed pointer will be
395 /// destroyed by a call to `delete ptr`. If `CONVERTIBLE_TYPE *` is not
396 /// implicitly convertible to `ELEMENT_TYPE *`, then a compiler
397 /// diagnostic will be emitted indicating the error. If `ptr` is 0,
398 /// then this shared pointer will still allocate an internal
399 /// representation to share ownership of that empty state, which will be
400 /// reclaimed when the last reference is destroyed. If an exception is
401 /// thrown allocating storage for the representation, then `delete ptr` will be called.
402 ///
403 /// \note Note that if `ptr` is a null-pointer constant, the
404 /// compiler will actually select the `shared_ptr(bsl::nullptr_t)`
405 /// constructor, resulting in an empty shared pointer.
406 template <class CONVERTIBLE_TYPE
408 explicit shared_ptr(CONVERTIBLE_TYPE *ptr);
409
410 /// Create a shared pointer that manages a modifiable object of
411 /// (template parameter) type `CONVERTIBLE_TYPE` and refers to the
412 /// specified `ptr` cast to a pointer to the (template parameter) type
413 /// `ELEMENT_TYPE`. If the specified `basicAllocator` is not 0, then
414 /// `basicAllocator` is used to allocate and deallocate the internal
415 /// representation of the shared pointer and to destroy the shared
416 /// object when all references have been released; otherwise, the
417 /// currently installed default allocator is used. If
418 /// `CONVERTIBLE_TYPE *` is not implicitly convertible to
419 /// `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted
420 /// indicating the error. If `ptr` is 0, then this shared pointer will
421 /// still allocate an internal representation to share ownership of that
422 /// empty state, which will be reclaimed when the last reference is destroyed.
423 ///
424 /// \note Note that if `ptr` is a null-pointer constant, the
425 /// compiler will actually select the
426 /// `shared_ptr(bsl::nullptr_t, BloombergLP::bslma::Allocator *)` constructor, resulting in an empty shared pointer.
427 ///
428 /// \note Note that if
429 /// `basicAllocator` is a pointer to a class derived from
430 /// `bslma::Allocator`, the compiler will actually select the following
431 /// (more general) constructor that has the same behavior:
432 /// @code
433 /// template <class CONVERTIBLE_TYPE, class DELETER>
434 /// shared_ptr(CONVERTIBLE_TYPE *ptr, DELETER * deleter);
435 /// @endcode
436 template <class CONVERTIBLE_TYPE
438 shared_ptr(CONVERTIBLE_TYPE *ptr,
439 BloombergLP::bslma::Allocator *basicAllocator);
440
441 /// Create a shared pointer that takes ownership of the specified `rep`
442 /// and refers to the modifiable object at the specified `ptr` address.
443 /// The number of references to `rep` is *NOT* incremented.
444 ///
445 /// \note Note that if `rep` is a pointer to a class derived from
446 /// `BloombergLP::bslma::SharedPtrRep`, the compiler will actually
447 /// select the following (more general) constructor that has the same
448 /// behavior:
449 /// @code
450 /// template <class COMPATIBLE_TYPE, class DELETER>
451 /// shared_ptr(COMPATIBLE_TYPE *ptr, DELETER * deleter);
452 /// @endcode
453 shared_ptr(element_type *ptr, BloombergLP::bslma::SharedPtrRep *rep);
454
455 /// Create a shared pointer that takes ownership of the specified `rep`
456 /// and refers to the modifiable object at the specified `ptr` address.
457 /// The number of references to `rep` is *NOT* incremented.
458 ///
459 /// \pre The behavior is undefined unless `rep` was previously obtained from an
460 /// existing `shared_ptr`, `rep->disposeObject` has not been called, and `rep->numReferences() > 0`.
461 ///
462 /// \note Note that this constructor is intended
463 /// for use by `weak_ptr::lock`, and it would be surprising to find
464 /// another client. This solves an obscure problem that arises from
465 /// unusual use of classes derived from @ref enable_shared_from_this .
466 /// Further note that the caller is responsible for incrementing the
467 /// `numReferences` count prior to calling this constructor, in order to
468 /// maintain a consistent reference count when this `shared_ptr` object
469 /// releases the shared object from its management.
470 shared_ptr(ELEMENT_TYPE *ptr,
471 BloombergLP::bslma::SharedPtrRep *rep,
472 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr);
473
474 /// Create a shared pointer that manages a modifiable object of
475 /// (template parameter) type `CONVERTIBLE_TYPE`, refers to the
476 /// specified `ptr` cast to a pointer to the (template parameter) type
477 /// `ELEMENT_TYPE`, and uses the specified `deleter` to delete the
478 /// shared object when all references have been released. Use the
479 /// currently installed default allocator to allocate and deallocate the
480 /// internal representation of the shared pointer, unless `DELETER` is a
481 /// class derived from either `bslma::Allocator` or
482 /// `bslma::SharedPtrRep`; if `DELETER` is a class derived from
483 /// `bslma::allocator`, create a shared pointer as if calling the
484 /// constructor:
485 /// @code
486 /// template <class CONVERTIBLE_TYPE>
487 /// shared_ptr(CONVERTIBLE_TYPE *ptr,
488 /// BloombergLP::bslma::Allocator *basicAllocator);
489 /// @endcode
490 /// If `DELETER` is a class derived from `bslma::SharedPtrRep`, create a
491 /// shared pointer as if calling the constructor:
492 /// @code
493 /// shared_ptr(ELEMENT_TYPE *ptr,
494 /// BloombergLP::bslma::SharedPtrRep *rep);
495 /// @endcode
496 /// If `DELETER` does not derive from either `bslma::Allocator` or
497 /// `BloombergLP::bslma::SharedPtrRep`, then `deleter` shall be a
498 /// pointer to a factory object that exposes a member function that can
499 /// be invoked as `deleteObject(ptr)` that will be called to destroy the
500 /// object at the `ptr` address (i.e., `deleter->deleteObject(ptr)` will
501 /// be called to delete the shared object). (See the "Deleters" section
502 /// in the component-level documentation.) If `CONVERTIBLE_TYPE *` is
503 /// not implicitly convertible to `ELEMENT_TYPE *`, then a compiler
504 /// diagnostic will be emitted indicating the error. If `ptr` is 0,
505 /// then the null pointer will be reference counted, and the deleter
506 /// will be called when the last reference is destroyed. If an
507 /// exception is thrown when allocating storage for the internal representation, then `deleter(ptr)` will be called.
508 ///
509 /// \note Note that this
510 /// method is a BDE extension and not part of the C++ standard
511 /// interface.
512 template <class CONVERTIBLE_TYPE,
513 class DELETER
515 BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(DELETER *, CONVERTIBLE_TYPE)>
516 shared_ptr(CONVERTIBLE_TYPE *ptr, DELETER *deleter);
517
518 /// Create a shared pointer that manages a modifiable object of
519 /// (template parameter) type `CONVERTIBLE_TYPE`, refers to the
520 /// specified `(ELEMENT_TYPE *)ptr`, and uses the specified `deleter` to
521 /// delete the shared object when all references have been released.
522 /// Optionally specify a `basicAllocator` to allocate and deallocate the
523 /// internal representation of the shared pointer (including a copy of
524 /// `deleter`). If `basicAllocator` is 0, the currently installed
525 /// default allocator is used. `DELETER` shall be either a function
526 /// pointer or a "factory" deleter that may be invoked to destroy the
527 /// object referred to by a single argument of type `CONVERTIBLE_TYPE *`
528 /// (i.e., `deleter(ptr)` or `deleter->deleteObject(ptr)` will be called
529 /// to destroy the shared object). (See the "Deleters" section in the
530 /// component-level documentation.) If `CONVERTIBLE_TYPE *` is not
531 /// implicitly convertible to `ELEMENT_TYPE *`, then this constructor
532 /// will not be selected by overload resolution. If `ptr` is 0, then
533 /// the null pointer will be reference counted, and `deleter(ptr)` will
534 /// be called when the last reference is destroyed. If an exception is
535 /// thrown when allocating storage for the internal representation, then `deleter(ptr)` will be called.
536 ///
537 /// \pre The behavior is undefined unless the
538 /// constructor making a copy of `deleter` does not throw an exception.
539 template <class CONVERTIBLE_TYPE,
540 class DELETER
542 BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(DELETER, CONVERTIBLE_TYPE)>
543 shared_ptr(CONVERTIBLE_TYPE *ptr,
544 DELETER deleter,
545 BloombergLP::bslma::Allocator *basicAllocator = 0);
546
547 /// Create a shared pointer that manages a modifiable object of
548 /// (template parameter) type `CONVERTIBLE_TYPE`, refers to the
549 /// specified `ptr` cast to a pointer to the (template parameter) type
550 /// `ELEMENT_TYPE`, and uses the specified `deleter` to delete the
551 /// shared object when all references have been released. Use the
552 /// specified `basicAllocator` to allocate and deallocate the internal
553 /// representation of the shared pointer (including a copy of the
554 /// `deleter`). The (template parameter) type `DELETER` shall be either
555 /// a function pointer or a function-like deleter that may be invoked to
556 /// destroy the object referred to by a single argument of type
557 /// `CONVERTIBLE_TYPE *` (i.e., `deleter(ptr)` will be called to destroy
558 /// the shared object). (See the "Deleters" section in the component-
559 /// level documentation.) The (template parameter) type `ALLOCATOR`
560 /// shall satisfy the Allocator requirements of the C++ standard (C++11
561 /// 17.6.3.5, [allocator.requirements]). If `CONVERTIBLE_TYPE *` is not
562 /// implicitly convertible to `ELEMENT_TYPE *`, then a compiler
563 /// diagnostic will be emitted indicating the error. If `ptr` is 0,
564 /// then the null pointer will be reference counted, and `deleter(ptr)`
565 /// will be called when the last reference is destroyed. If an
566 /// exception is thrown when allocating storage for the internal
567 /// representation, then `deleter(ptr)` will be called.
568 ///
569 /// \pre The behavior is undefined unless the constructor making a copy of `deleter` does not throw an exception.
570 ///
571 /// \note Note that the final dummy parameter is a simple
572 /// SFINAE check that the (template parameter) `ALLOCATOR` type probably
573 /// satisfies the standard allocator requirements; in particular, it
574 /// will not match pointer types, so any pointers to `bslma::Allocator`
575 /// derived classes will dispatch to the constructor above this, and not
576 /// be greedily matched to a generic type parameter.
577 template <class CONVERTIBLE_TYPE,
578 class DELETER,
579 class ALLOCATOR
581 BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(DELETER, CONVERTIBLE_TYPE)>
582 shared_ptr(CONVERTIBLE_TYPE *ptr,
583 DELETER deleter,
584 ALLOCATOR basicAllocator,
585 typename ALLOCATOR::value_type * = 0);
586
587 /// Create an empty shared pointer. The specified `nullPointerLiteral` and `basicAllocator` are not used.
588 ///
589 /// \note Note that use of this
590 /// constructor is equivalent to calling the default constructor.
591 shared_ptr(nullptr_t nullPointerLiteral,
592 BloombergLP::bslma::Allocator *basicAllocator);
593
594 /// Create a shared pointer that reference-counts the null pointer, and
595 /// calls the specified `deleter` with a null pointer (i.e., invokes
596 /// `deleter((ELEMENT_TYPE *)0)`) when the last shared reference is
597 /// destroyed. The specified `nullPointerLiteral` is not used.
598 /// Optionally specify a `basicAllocator` to allocate and deallocate the
599 /// internal representation of the shared pointer (including a copy of
600 /// `deleter`). If `basicAllocator` is 0, the currently installed
601 /// default allocator is used. If an exception is thrown when
602 /// allocating storage for the internal representation, then
603 /// `deleter((ELEMENT_TYPE *)0)` will be called.
604 ///
605 /// \pre The behavior is undefined unless `deleter` can be called with a null pointer, and
606 /// unless the constructor making a copy of `deleter` does not throw an
607 /// exception.
608 template <class DELETER
610 shared_ptr(nullptr_t nullPointerLiteral,
611 DELETER deleter,
612 BloombergLP::bslma::Allocator *basicAllocator = 0);
613
614 /// Create a shared pointer that reference-counts the null pointer,
615 /// calls the specified `deleter` with a null pointer (i.e., invokes
616 /// `deleter((ELEMENT_TYPE *)0)`) when the last shared reference is
617 /// destroyed, and uses the specified `basicAllocator` to allocate and
618 /// deallocate the internal representation of the shared pointer
619 /// (including a copy of the `deleter`). The (template parameter) type
620 /// `DELETER` shall be either a function pointer or a function-like
621 /// deleter (See the "Deleters" section in the component- level
622 /// documentation). The (template parameter) type `ALLOCATOR` shall
623 /// satisfy the Allocator requirements of the C++ standard (C++11
624 /// 17.6.3.5, [allocator.requirements]). The specified
625 /// `nullPointerLiteral` is not used. If an exception is thrown when
626 /// allocating storage for the internal representation, then
627 /// `deleter((ELEMENT_TYPE *)0)` will be called.
628 ///
629 /// \pre The behavior is undefined unless `deleter` can be called with a null pointer, and
630 /// unless the constructor making a copy of `deleter` does not throw an exception.
631 ///
632 /// \note Note that the final dummy parameter is a simple SFINAE
633 /// check that the `ALLOCATOR` type probably satisfies the standard
634 /// allocator requirements; in particular, it will not match pointer
635 /// types, so any pointers to `bslma::Allocator` derived classes will
636 /// dispatch to the constructor above this, and not be greedily matched
637 /// to a generic type parameter.
638 template <class DELETER, class ALLOCATOR
640 shared_ptr(nullptr_t nullPointerLiteral,
641 DELETER deleter,
642 ALLOCATOR basicAllocator,
643 typename ALLOCATOR::value_type * = 0);
644
645 /// Create a shared pointer that takes over the management of the
646 /// modifiable object (if any) previously managed by the specified
647 /// `managedPtr` to the (template parameter) type `CONVERTIBLE_TYPE`,
648 /// and that refers to `(ELEMENT_TYPE *)managedPtr.ptr()`. The deleter
649 /// used in the `managedPtr` will be used to destroy the shared object
650 /// when all references have been released. Optionally specify a
651 /// `basicAllocator` used to allocate and deallocate the internal
652 /// representation of the shared pointer. If `basicAllocator` is 0, the
653 /// currently installed default allocator is used. If
654 /// `CONVERTIBLE_TYPE *` is not implicitly convertible to
655 /// `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
656 ///
657 /// \note Note that if `managedPtr` is empty, then an
658 /// empty shared pointer is created and `basicAllocator` is ignored.
659 /// Also note that if `managedPtr` owns a reference to another shared
660 /// object (due to a previous call to `shared_ptr<T>::managedPtr`) then
661 /// no memory will be allocated, and this `shared_ptr` will adopt the
662 /// `ManagedPtr`s ownership of that shared object.
663 template <class CONVERTIBLE_TYPE
666 BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE> managedPtr,
667 BloombergLP::bslma::Allocator *basicAllocator = 0);
668 // IMPLICIT
669
670#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
671 /// Create a shared pointer that takes over the management of the
672 /// modifiable object previously managed by the specified `autoPtr` to
673 /// the (template parameter) type `CONVERTIBLE_TYPE`, and that refers to
674 /// `(ELEMENT_TYPE *)autoPtr.get()`. `delete(autoPtr.release())` will
675 /// be called to destroy the shared object when all references have been
676 /// released. Optionally specify a `basicAllocator` used to allocate
677 /// and deallocate the internal representation of the shared pointer.
678 /// If `basicAllocator` is 0, the currently installed default allocator
679 /// is used. If `CONVERTIBLE_TYPE *` is not implicitly convertible to
680 /// `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted
681 /// indicating the error.
682 template <class CONVERTIBLE_TYPE
684 explicit shared_ptr(std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr,
685 BloombergLP::bslma::Allocator *basicAllocator = 0);
686
687 /// Create a shared pointer that takes over the management of the
688 /// modifiable object of (template parameter) type `COMPATIBLE_TYPE`
689 /// previously managed by the auto pointer object that the specified
690 /// `autoRef` refers to; this shared pointer refers to the same object
691 /// that it manages, and `delete(get())` will be called to destroy the
692 /// shared object when all references have been released. Optionally
693 /// specify a `basicAllocator` used to allocate and deallocate the
694 /// internal representation of the shared pointer. If `basicAllocator`
695 /// is 0, the currently installed default allocator is used. This
696 /// function does not exist unless `COMPATIBLE_TYPE *` is convertible to
697 /// `ELEMENT_TYPE *`.
698 explicit shared_ptr(std::auto_ptr_ref<ELEMENT_TYPE> autoRef,
699 BloombergLP::bslma::Allocator *basicAllocator = 0);
700#endif
701
702#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
703# if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
704 /// Create a shared pointer that takes over the management of the
705 /// modifiable object previously managed by the specified `adoptee` to
706 /// the (template parameter) type `COMPATIBLE_TYPE`, and that refers to
707 /// `(ELEMENT_TYPE *)autoPtr.get()`. `delete(autoPtr.release())` will
708 /// be called to destroy the shared object when all references have been
709 /// released. Optionally specify a `basicAllocator` used to allocate
710 /// and deallocate the internal representation of the shared pointer.
711 /// If `basicAllocator` is 0, the currently installed default allocator
712 /// is used. This function does not exist unless
713 /// `unique_ptr<COMPATIBLE_TYPE, DELETER>::pointer` is convertible to `ELEMENT_TYPE *`.
714 ///
715 /// \note Note that this function creates a `shared_ptr`
716 /// with an unspecified deleter type that has satisfies this contract,
717 /// which might not be the deleter of `rhs`, which is specified by the
718 /// C++ standard.
719 template <class COMPATIBLE_TYPE,
720 class UNIQUE_DELETER,
721 typename enable_if<is_convertible<
722 typename std::unique_ptr<COMPATIBLE_TYPE,
723 UNIQUE_DELETER>::pointer,
724 ELEMENT_TYPE *>::value>::type * = nullptr>
725 shared_ptr(std::unique_ptr<COMPATIBLE_TYPE,
726 UNIQUE_DELETER>&& adoptee,
727 BloombergLP::bslma::Allocator *basicAllocator = 0);
728 // IMPLICIT
729# else
730 /// Create a shared pointer that takes over the management of the
731 /// modifiable object previously managed by the specified `adoptee` to
732 /// the (template parameter) type `COMPATIBLE_TYPE`, and that refers to
733 /// `(ELEMENT_TYPE *)autoPtr.get()`. `delete(autoPtr.release())` will
734 /// be called to destroy the shared object when all references have been
735 /// released. Optionally specify a `basicAllocator` used to allocate
736 /// and deallocate the internal representation of the shared pointer.
737 /// If `basicAllocator` is 0, the currently installed default allocator
738 /// is used. This function does not exist unless
739 /// `unique_ptr<COMPATIBLE_TYPE, DELETER>::pointer` is convertible to `ELEMENT_TYPE *`.
740 ///
741 /// \note Note that this function creates a `shared_ptr`
742 /// with an unspecified deleter type that has satisfies this contract,
743 /// which might not be the deleter of `rhs`, which is specified by the
744 /// C++ standard.
745 template <class COMPATIBLE_TYPE, class UNIQUE_DELETER>
746 shared_ptr(std::unique_ptr<COMPATIBLE_TYPE,
747 UNIQUE_DELETER>&& adoptee,
748 BloombergLP::bslma::Allocator *basicAllocator = 0,
749 typename enable_if<is_convertible<
750 typename std::unique_ptr<COMPATIBLE_TYPE,
751 UNIQUE_DELETER>::pointer,
752 ELEMENT_TYPE *>::value,
753 BloombergLP::bslstl::SharedPtr_ImpUtil>::type =
754 BloombergLP::bslstl::SharedPtr_ImpUtil())
755 // IMPLICIT
756 : d_ptr_p(adoptee.get())
757 , d_rep_p(0)
758 {
759 // This constructor template must be defined inline inside the class
760 // definition, as Microsoft Visual C++ does not recognize the
761 // definition as matching this signature when placed out-of-line.
762
763 typedef BloombergLP::bslma::SharedPtrInplaceRep<
764 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER> > Rep;
765
766 if (d_ptr_p) {
767 basicAllocator =
768 BloombergLP::bslma::Default::allocator(basicAllocator);
769 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
770 BloombergLP::bslmf::MovableRefUtil::move(adoptee));
771 d_rep_p = rep;
772 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
773 d_ptr_p,
774 this);
775 }
776 }
777# endif // BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS
778#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR
779
780 /// Create a shared pointer that manages the same modifiable object (if
781 /// any) as the specified `source` shared pointer to the (template
782 /// parameter) type `ANY_TYPE`, and that refers to the modifiable object
783 /// at the specified `object` address. The resulting shared pointer is known as an "alias" of `source`.
784 ///
785 /// \note Note that typically the objects
786 /// referred to by `source` and `object` have identical lifetimes (e.g.,
787 /// one might be a part of the other), so that the deleter for `source`
788 /// will destroy them both, but they do not necessarily have the same
789 /// type. Also note that if `source` is empty, then an empty shared
790 /// pointer is created, even if `object` is not null (in which case this
791 /// empty shared pointer will refer to the same object as `object`).
792 /// Also note that if `object` is null and `source` is not empty, then a
793 /// reference-counted null pointer alias will be created.
794 template <class ANY_TYPE>
795 shared_ptr(const shared_ptr<ANY_TYPE>& source,
796 ELEMENT_TYPE *object) BSLS_KEYWORD_NOEXCEPT;
797
798 /// Create a shared pointer that manages the same modifiable object (if
799 /// any) as the specified `other` shared pointer to the (template
800 /// parameter) type `COMPATIBLE_TYPE`, uses the same deleter as `other`
801 /// to destroy the shared object, and refers to
802 /// `(ELEMENT_TYPE*)other.get()`. If `COMPATIBLE_TYPE *` is not
803 /// implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
804 ///
805 /// \note Note that if
806 /// `other` is empty, then an empty shared pointer is created, which may
807 /// still point to an un-managed object if `other` were constructed
808 /// through an aliasing constructor.
809 template <class COMPATIBLE_TYPE
811 shared_ptr(const shared_ptr<COMPATIBLE_TYPE>& other) BSLS_KEYWORD_NOEXCEPT;
812
813 /// Create a shared pointer that refers to and manages the same object
814 /// (if any) as the specified `original` shared pointer, and uses the
815 /// same deleter as `original` to destroy the shared object.
816 ///
817 /// \note Note that if `original` is empty, then an empty shared pointer is created,
818 /// which may still point to an un-managed object if `original` were
819 /// constructed through an aliasing constructor.
821
822 /// Create a shared pointer that refers to and assumes management of the
823 /// same object (if any) as the specified `original` shared pointer,
824 /// using the same deleter as `original` to destroy the shared object,
825 /// and reset `original` to an empty state, not pointing to any object.
826 ///
827 /// \note Note that if `original` is empty, then an empty shared pointer is
828 /// created, which may still point to an un-managed object if `original`
829 /// were constructed through an aliasing constructor.
830 shared_ptr(BloombergLP::bslmf::MovableRef<shared_ptr> original)
832
833#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
834 /// Create a shared pointer that refers to and assumes management of the
835 /// same object (if any) as the specified `other` shared pointer to the
836 /// (template parameter) type `COMPATIBLE_TYPE`, using the same deleter
837 /// as `other` to destroy the shared object, and refers to
838 /// `(ELEMENT_TYPE*)other.get()`. If `COMPATIBLE_TYPE *` is not
839 /// implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
840 ///
841 /// \note Note that if
842 /// `other` is empty, then an empty shared pointer is created, which may
843 /// still point to an un-managed object if `other` were constructed
844 /// through an aliasing constructor.
845 template <class COMPATIBLE_TYPE
847 shared_ptr(shared_ptr<COMPATIBLE_TYPE>&& other) BSLS_KEYWORD_NOEXCEPT;
848#else
849 /// Create a shared pointer that refers to and assumes management of the
850 /// same object (if any) as the specified `other` shared pointer to the
851 /// (template parameter) type `COMPATIBLE_TYPE`, using the same deleter
852 /// as `other` to destroy the shared object, and refers to
853 /// `(ELEMENT_TYPE*)other.get()`. If `COMPATIBLE_TYPE *` is not
854 /// implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
855 ///
856 /// \note Note that if
857 /// `other` is empty, then an empty shared pointer is created, which may
858 /// still point to an un-managed object if `other` were constructed
859 /// through an aliasing constructor.
860 template <class COMPATIBLE_TYPE
863 BloombergLP::bslmf::MovableRef<shared_ptr<COMPATIBLE_TYPE> > other)
865#endif
866
867 /// Create a shared pointer that refers to and manages the same object
868 /// as the specified `ptr` if `ptr.expired()` is `false`; otherwise, create a shared pointer in the empty state.
869 ///
870 /// \note Note that the
871 /// referenced and managed objects may be different if `ptr` was created
872 /// from a `shared_ptr` in an aliasing state.
873 template<class COMPATIBLE_TYPE
875 explicit shared_ptr(const weak_ptr<COMPATIBLE_TYPE>& ptr);
876
877#if !defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
878 /// Create a shared pointer that refers to and manages the same object
879 /// as the specified `ptr` if `ptr.expired()` is `false`; otherwise, create a shared pointer in the empty state.
880 ///
881 /// \note Note that the
882 /// referenced and managed objects may be different if `ptr` was created
883 /// from a `shared_ptr` in an aliasing state. Also note that this
884 /// overloaded constructor is necessary only for C++03 compilers that
885 /// rely on the BDE move-emulation type, `bslmf::MovableRef`; a C++11
886 /// compiler will pass rvalues directly to the constructor taking a
887 /// `const weak_ptr&`, rendering this constructor redundant.
888 template<class COMPATIBLE_TYPE
890 explicit shared_ptr(
891 BloombergLP::bslmf::MovableRef<weak_ptr<COMPATIBLE_TYPE> > ptr);
892#endif
893
894 /// Destroy this shared pointer. If this shared pointer refers to a
895 /// (possibly shared) object, then release the reference to that object,
896 /// and destroy the shared object using its associated deleter if this
897 /// shared pointer is the last reference to that object.
898 ~shared_ptr();
899
900 // MANIPULATORS
901
902 /// Make this shared pointer manage the same modifiable object as the
903 /// specified `rhs` shared pointer to the (template parameter) type
904 /// `COMPATIBLE_TYPE`, use the same deleter as `rhs`, and refer to
905 /// `(ELEMENT_TYPE *)rhs.get()`; return a reference providing modifiable access to this shared pointer.
906 ///
907 /// \note Note that if `rhs` is empty, then
908 /// this shared pointer will also be empty after the assignment. Also
909 /// note that if `*this` is the same object as `rhs`, then this method
910 /// has no effect.
912
913 /// Make this shared pointer manage the same modifiable object as the
914 /// specified `rhs` shared pointer to the (template parameter) type
915 /// `COMPATIBLE_TYPE`, use the same deleter as `rhs`, and refer to
916 /// `rhs.get()`; return a reference providing modifiable access to this
917 /// shared pointer. Reset `rhs` to an empty state, not pointing to any object, unless `*this` is the same object as `rhs`.
918 ///
919 /// \note Note that if
920 /// `rhs` is empty, then this shared pointer will also be empty after
921 /// the assignment.
922 shared_ptr& operator=(BloombergLP::bslmf::MovableRef<shared_ptr> rhs)
924
925 /// Make this shared pointer refer to and manage the same modifiable
926 /// object as the specified `rhs` shared pointer to the (template
927 /// parameter) type `COMPATIBLE_TYPE`, using the same deleter as `rhs`
928 /// and referring to `(ELEMENT_TYPE *)rhs.get()`, and return a reference
929 /// to this modifiable shared pointer. If this shared pointer is
930 /// already managing a (possibly shared) object, then release the shared
931 /// reference to that object, and destroy it using its associated
932 /// deleter if this shared pointer held the last shared reference to that object.
933 ///
934 /// \note Note that if `rhs` is empty, then this shared pointer
935 /// will also be empty after the assignment.
936 template <class COMPATIBLE_TYPE>
937 typename enable_if<
938 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
939 shared_ptr&>::type
940 operator=(const shared_ptr<COMPATIBLE_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
941
942#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
943 /// Make this shared pointer refer to and manage the same modifiable
944 /// object as the specified `rhs` shared pointer to the (template
945 /// parameter) type `COMPATIBLE_TYPE`, using the same deleter as `rhs`
946 /// and referring to `(ELEMENT_TYPE *)rhs.get()`, and return a reference
947 /// to this modifiable shared pointer. If this shared pointer is
948 /// already managing a (possibly shared) object, then release the shared
949 /// reference to that object, and destroy it using its associated
950 /// deleter if this shared pointer held the last shared reference to
951 /// that object. Reset `rhs` to an empty state, not pointing to any
952 /// object, unless `*this` is the same object as `rhs`. This function
953 /// does not exist unless a pointer to (template parameter)
954 /// `COMPATIBLE_TYPE` is convertible to a pointer to the (template parameter) `ELEMENT_TYPE` of this `shared_ptr`.
955 ///
956 /// \note Note that if `rhs`
957 /// is empty, then this shared pointer will also be empty after the
958 /// assignment.
959 template <class COMPATIBLE_TYPE>
960 typename
961 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
962 shared_ptr&>::type
963 operator=(shared_ptr<COMPATIBLE_TYPE>&& rhs) BSLS_KEYWORD_NOEXCEPT;
964#else
965 /// Make this shared pointer refer to and manage the same modifiable
966 /// object as the specified `rhs` shared pointer to the (template
967 /// parameter) type `COMPATIBLE_TYPE`, using the same deleter as `rhs`
968 /// and referring to `(ELEMENT_TYPE *)rhs.get()`, and return a reference
969 /// to this modifiable shared pointer. If this shared pointer is
970 /// already managing a (possibly shared) object, then release the shared
971 /// reference to that object, and destroy it using its associated
972 /// deleter if this shared pointer held the last shared reference to
973 /// that object. Reset `rhs` to an empty state, not pointing to any
974 /// object, unless `*this` is the same object as `rhs`. This function
975 /// does not exist unless a pointer to (template parameter)
976 /// `COMPATIBLE_TYPE` is convertible to a pointer to the (template parameter) `ELEMENT_TYPE` of this `shared_ptr`.
977 ///
978 /// \note Note that if `rhs`
979 /// is empty, then this shared pointer will also be empty after the
980 /// assignment.
981 template <class COMPATIBLE_TYPE>
982 typename
983 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
984 shared_ptr&>::type
985 operator=(BloombergLP::bslmf::MovableRef<shared_ptr<COMPATIBLE_TYPE> > rhs)
987#endif
988
989 /// Transfer, to this shared pointer, ownership of the modifiable object
990 /// managed by the specified `rhs` managed pointer to the (template
991 /// parameter) type `COMPATIBLE_TYPE`, and make this shared pointer
992 /// refer to `(ELEMENT_TYPE *)rhs.ptr()`. The deleter used in the `rhs`
993 /// will be used to destroy the shared object when all references have
994 /// been released. The *default* *allocator* is used to allocate a
995 /// `SharedPtrRep`, if needed (users must use the copy-constructor and
996 /// swap instead of using this operator to supply an alternative
997 /// allocator). If this shared pointer is already managing a (possibly
998 /// shared) object, then release the reference to that shared object,
999 /// and destroy it using its associated deleter if this shared pointer held the last shared reference to that object.
1000 ///
1001 /// \note Note that if `rhs`
1002 /// is empty, then this shared pointer will be empty after the
1003 /// assignment. Also note that if `rhs` owns a reference to another
1004 /// shared object (due to a previous call to
1005 /// `shared_ptr<T>::managedPtr`) then this `shared_ptr` will adopt the
1006 /// `ManagedPtr`s ownership of that shared object.
1007 template <class COMPATIBLE_TYPE>
1008 typename enable_if<
1009 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
1010 shared_ptr&>::type
1011 operator=(BloombergLP::bslma::ManagedPtr<COMPATIBLE_TYPE> rhs);
1012
1013#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
1014 /// Transfer, to this shared pointer, ownership of the modifiable object
1015 /// managed by the specified `rhs` auto pointer to the (template
1016 /// parameter) type `COMPATIBLE_TYPE`, and make this shared pointer
1017 /// refer to `(ELEMENT_TYPE *)rhs.get()`. `delete(autoPtr.release())`
1018 /// will be called to destroy the shared object when all references have
1019 /// been released. If this shared pointer is already managing a
1020 /// (possibly shared) object, then release the reference to that shared
1021 /// object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object.
1022 ///
1023 /// \note Note that if
1024 /// `rhs` is empty, then this shared pointer will be empty after the
1025 /// assignment.
1026 template <class COMPATIBLE_TYPE>
1027 typename enable_if<
1028 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
1029 shared_ptr&>::type
1030 operator=(std::auto_ptr<COMPATIBLE_TYPE> rhs);
1031#endif
1032
1033#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
1034 /// Transfer, to this shared pointer, ownership of the object managed by
1035 /// the specified `rhs` unique pointer to the (template parameter) type
1036 /// `COMPATIBLE_TYPE`, and make this shared pointer refer to
1037 /// `(ELEMENT_TYPE *)rhs.get()`. The deleter of `rhs` will be called to
1038 /// destroy the shared object when all references have been released.
1039 /// If this shared pointer is already managing a (possibly shared)
1040 /// object, then release the reference to that shared object, and
1041 /// destroy it using its associated deleter if this shared pointer held
1042 /// the last shared reference to that object. This function does not
1043 /// exist unless `unique_ptr<COMPATIBLE_TYPE, DELETER>::pointer` is convertible to `ELEMENT_TYPE *`.
1044 ///
1045 /// \note Note that if `rhs` is empty, then
1046 /// this shared pointer will be empty after the assignment. Also note
1047 /// that this function creates a `shared_ptr` with an unspecified
1048 /// deleter type that satisfies this contract; the C++11 standard
1049 /// specifies the exact deleter that should be in use after assignment,
1050 /// so this implementation may be non-conforming.
1051 template <class COMPATIBLE_TYPE, class UNIQUE_DELETER>
1052 typename enable_if<
1053 is_convertible<
1054 typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer,
1055 ELEMENT_TYPE *>::value,
1056 shared_ptr&>::type
1057 operator=(std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& rhs);
1058#endif
1059
1060 /// Reset this shared pointer to the empty state. If this shared
1061 /// pointer is managing a (possibly shared) object, then release the
1062 /// reference to the shared object, calling the associated deleter to
1063 /// destroy the shared object if this shared pointer is the last shared
1064 /// reference.
1066
1067 /// Modify this shared pointer to manage the modifiable object of the
1068 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1069 /// address and to refer to `(ELEMENT_TYPE *)ptr`. If this shared
1070 /// pointer is already managing a (possibly shared) object, then, unless
1071 /// an exception is thrown allocating memory to manage `ptr`, release
1072 /// the reference to the shared object, calling the associated deleter
1073 /// to destroy the shared object if this shared pointer is the last
1074 /// reference. The currently installed default allocator is used to
1075 /// allocate the internal representation of this shared pointer, and the
1076 /// shared object will be destroyed by a call to `delete ptr` when all
1077 /// references have been released. If an exception is thrown allocating
1078 /// the internal representation, then `delete ptr` is called and this
1079 /// shared pointer retains ownership of its original object. If
1080 /// `COMPATIBLE_TYPE*` is not implicitly convertible to `ELEMENT_TYPE*`,
1081 /// then a compiler diagnostic will be emitted indicating the error.
1082 ///
1083 /// \note Note that if `ptr` is 0, then this shared pointer will still
1084 /// allocate an internal representation to share ownership of that empty
1085 /// state, which will be reclaimed when the last reference is destroyed.
1086 template <class COMPATIBLE_TYPE>
1087 typename
1088 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
1089 reset(COMPATIBLE_TYPE *ptr);
1090
1091 /// Modify this shared pointer to manage the modifiable object of the
1092 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1093 /// address, refer to `(ELEMENT_TYPE *)ptr`, and use the specified
1094 /// `deleter` to delete the shared object when all references have been
1095 /// released. If this shared pointer is already managing a (possibly
1096 /// shared) object, then unless an exception is thrown allocating memory
1097 /// to manage `ptr`, release the reference to the shared object, calling
1098 /// the associated deleter to destroy the shared object if this shared
1099 /// pointer is the last reference. If `DELETER` is an object type, then
1100 /// `deleter` is assumed to be a function-like deleter that may be
1101 /// invoked to destroy the object referred to by a single argument of
1102 /// type `COMPATIBLE_TYPE *` (i.e., `deleter(ptr)` will be called to
1103 /// destroy the shared object). If `DELETER` is a pointer type that is
1104 /// not a function pointer, then `deleter` shall be a pointer to a
1105 /// factory object that exposes a member function that can be invoked as
1106 /// `deleteObject(ptr)` that will be called to destroy the object at the
1107 /// `ptr` address (i.e., `deleter->deleteObject(ptr)` will be called to
1108 /// delete the shared object). (See the "Deleters" section in the
1109 /// component-level documentation.) If `DELETER` is also a pointer to
1110 /// `bslma::Allocator` or to a class derived from `bslma::Allocator`,
1111 /// then that allocator will also be used to allocate and destroy the
1112 /// internal representation of this shared pointer when all references
1113 /// have been released; otherwise, the currently installed default
1114 /// allocator is used to allocate and destroy the internal
1115 /// representation of this shared pointer when all references have been
1116 /// released. If an exception is thrown allocating the internal
1117 /// representation, then `deleter(ptr)` is called (or
1118 /// `deleter->deleteObject(ptr)` for factory-type deleters) and this
1119 /// shared pointer retains ownership of its original object. If
1120 /// `COMPATIBLE_TYPE*` is not implicitly convertible to `ELEMENT_TYPE*`,
1121 /// then a compiler diagnostic will be emitted indicating the error.
1122 ///
1123 /// \note Note that, for factory deleters, `deleter` must remain valid until
1124 /// all references to `ptr` have been released. If `ptr` is 0, then an
1125 /// internal representation will still be allocated, and this shared
1126 /// pointer will share ownership of a copy of `deleter`. Further note
1127 /// that this function is logically equivalent to:
1128 /// @code
1129 /// *this = shared_ptr<ELEMENT_TYPE>(ptr, deleter);
1130 /// @endcode
1131 template <class COMPATIBLE_TYPE, class DELETER>
1132 typename
1133 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
1134 reset(COMPATIBLE_TYPE *ptr, DELETER deleter);
1135
1136
1137 /// Modify this shared pointer to manage the modifiable object of the
1138 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1139 /// address, refer to `(ELEMENT_TYPE *)ptr` and use the specified
1140 /// `deleter` to delete the shared object when all references have been
1141 /// released. Use the specified `basicAllocator` to allocate and
1142 /// deallocate the internal representation of the shared pointer. If
1143 /// this shared pointer is already managing a (possibly shared) object,
1144 /// then, unless an exception is thrown allocating memory to manage
1145 /// `ptr`, release the shared reference to that shared object, and
1146 /// destroy it using its associated deleter if this shared pointer held
1147 /// the last shared reference to that object. If `DELETER` is a
1148 /// reference type, then `deleter` is assumed to be a function-like
1149 /// deleter that may be invoked to destroy the object referred to by a
1150 /// single argument of type `COMPATIBLE_TYPE *` (i.e., `deleter(ptr)`
1151 /// will be called to destroy the shared object). If `DELETER` is a
1152 /// pointer type, then `deleter` is assumed to be a pointer to a factory
1153 /// object that exposes a member function that can be invoked as
1154 /// `deleteObject(ptr)` that will be called to destroy the object at the
1155 /// `ptr` address (i.e., `deleter->deleteObject(ptr)` will be called to
1156 /// delete the shared object). (See the "Deleters" section in the
1157 /// component-level documentation.) If an exception is thrown
1158 /// allocating the internal representation, then `deleter(ptr)` is
1159 /// called (or `deleter->deleteObject(ptr)` for factory-type deleters)
1160 /// and this shared pointer retains ownership of its original object.
1161 ///
1162 /// \pre The behavior is undefined unless `deleter(ptr)` is a well-defined
1163 /// expression (or `deleter->deleteObject(ptr)` for factory-type
1164 /// deleters), and unless the copy constructor for `deleter` does not
1165 /// throw an exception. If `COMPATIBLE_TYPE *` is not implicitly
1166 /// convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
1167 ///
1168 /// \note Note that, for factory deleters, the
1169 /// `deleter` must remain valid until all references to `ptr` have been
1170 /// released. Also note that if `ptr` is 0, then an internal
1171 /// representation will still be allocated, and this shared pointer will
1172 /// share ownership of a copy of `deleter`. Further note that this
1173 /// function is logically equivalent to:
1174 /// @code
1175 /// *this = shared_ptr<ELEMENT_TYPE>(ptr, deleter, basicAllocator);
1176 /// @endcode
1177 template <class COMPATIBLE_TYPE, class DELETER, class ALLOCATOR>
1178 typename
1179 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
1180 reset(COMPATIBLE_TYPE *ptr,
1181 DELETER deleter,
1182 ALLOCATOR basicAllocator);
1183
1184 /// Modify this shared pointer to manage the same modifiable object (if
1185 /// any) as the specified `source` shared pointer to the (template
1186 /// parameter) type `ANY_TYPE`, and refer to the modifiable object at
1187 /// the specified `ptr` address (i.e., make this shared pointer an
1188 /// "alias" of `source`). If this shared pointer is already managing a
1189 /// (possibly shared) object, then release the reference to the shared
1190 /// object, calling the associated deleter to destroy the shared object if this shared pointer is the last reference.
1191 ///
1192 /// \note Note that typically
1193 /// the objects referred to by `source` and `ptr` have identical
1194 /// lifetimes (e.g., one might be a part of the other), so that the
1195 /// deleter for `source` will destroy them both, but do not necessarily
1196 /// have the same type. Also note that if `source` is empty, then this
1197 /// shared pointer will be reset to an empty state, even if `ptr` is not
1198 /// null (in which case this empty shared pointer will refer to the same
1199 /// object as `ptr`). Also note that if `ptr` is null and `source` is
1200 /// not empty, then this shared pointer will be reset to a
1201 /// (reference-counted) null pointer alias. Further note that the
1202 /// behavior of this method is the same as `loadAlias(source, ptr)`.
1203 /// Finally note that this is a non-standard BDE extension to the C++
1204 /// Standard `shared_ptr` interface, which does not provide an alias
1205 /// overload for the `reset` function.
1206 template <class ANY_TYPE>
1207 void reset(const shared_ptr<ANY_TYPE>& source, ELEMENT_TYPE *ptr);
1208
1209 /// Efficiently exchange the states of this shared pointer and the
1210 /// specified `other` shared pointer such that each will refer to the
1211 /// object formerly referred to by the other and each will manage the
1212 /// object formerly managed by the other.
1213 void swap(shared_ptr& other) BSLS_KEYWORD_NOEXCEPT;
1214
1215 // ADDITIONAL BSL MANIPULATORS
1216
1217 /// Create "in-place" in a large enough contiguous memory region both an
1218 /// internal representation for this shared pointer and a
1219 /// default-constructed object of `ELEMENT_TYPE`, and make this shared
1220 /// pointer refer to the newly-created `ELEMENT_TYPE` object. The
1221 /// currently installed default allocator is used to supply memory. If
1222 /// an exception is thrown during allocation or construction of the
1223 /// `ELEMENT_TYPE` object, this shared pointer will be unchanged.
1224 /// Otherwise, if this shared pointer is already managing a (possibly
1225 /// shared) object, then release the shared reference to that shared
1226 /// object, and destroy it using its associated deleter if this shared
1227 /// pointer held the last shared reference to that object.
1228 void createInplace();
1229
1230#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1231// {{{ BEGIN GENERATED CODE
1232// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
1233#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
1234#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
1235#endif
1236#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A
1237#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A BSLSTL_SHAREDPTR_VARIADIC_LIMIT
1238#endif
1239
1240#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 0
1241 void createInplace(BloombergLP::bslma::Allocator *basicAllocator);
1242#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 0
1243
1244#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 1
1245 template <class ARGS_01>
1246 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1247 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
1248#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 1
1249
1250#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 2
1251 template <class ARGS_01,
1252 class ARGS_02>
1253 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1254 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1255 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
1256#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 2
1257
1258#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 3
1259 template <class ARGS_01,
1260 class ARGS_02,
1261 class ARGS_03>
1262 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1263 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1264 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1265 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
1266#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 3
1267
1268#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 4
1269 template <class ARGS_01,
1270 class ARGS_02,
1271 class ARGS_03,
1272 class ARGS_04>
1273 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1275 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
1278#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 4
1279
1280#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 5
1281 template <class ARGS_01,
1282 class ARGS_02,
1283 class ARGS_03,
1284 class ARGS_04,
1285 class ARGS_05>
1286 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1287 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1288 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1289 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1290 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1291 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
1292#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 5
1293
1294#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 6
1295 template <class ARGS_01,
1296 class ARGS_02,
1297 class ARGS_03,
1298 class ARGS_04,
1299 class ARGS_05,
1300 class ARGS_06>
1301 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1302 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1303 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1304 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1305 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1306 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
1308#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 6
1309
1310#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 7
1311 template <class ARGS_01,
1312 class ARGS_02,
1313 class ARGS_03,
1314 class ARGS_04,
1315 class ARGS_05,
1316 class ARGS_06,
1317 class ARGS_07>
1318 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1319 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1320 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1321 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1322 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1323 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1324 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1325 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
1326#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 7
1327
1328#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 8
1329 template <class ARGS_01,
1330 class ARGS_02,
1331 class ARGS_03,
1332 class ARGS_04,
1333 class ARGS_05,
1334 class ARGS_06,
1335 class ARGS_07,
1336 class ARGS_08>
1337 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1338 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1339 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1340 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1341 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1342 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
1346#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 8
1347
1348#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 9
1349 template <class ARGS_01,
1350 class ARGS_02,
1351 class ARGS_03,
1352 class ARGS_04,
1353 class ARGS_05,
1354 class ARGS_06,
1355 class ARGS_07,
1356 class ARGS_08,
1357 class ARGS_09>
1358 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1359 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1360 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1361 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1362 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1363 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1364 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1365 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1366 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1367 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
1368#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 9
1369
1370#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 10
1371 template <class ARGS_01,
1372 class ARGS_02,
1373 class ARGS_03,
1374 class ARGS_04,
1375 class ARGS_05,
1376 class ARGS_06,
1377 class ARGS_07,
1378 class ARGS_08,
1379 class ARGS_09,
1380 class ARGS_10>
1381 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1382 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1383 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1384 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1385 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1386 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1387 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1388 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1389 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1390 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1391 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
1392#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 10
1393
1394#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 11
1395 template <class ARGS_01,
1396 class ARGS_02,
1397 class ARGS_03,
1398 class ARGS_04,
1399 class ARGS_05,
1400 class ARGS_06,
1401 class ARGS_07,
1402 class ARGS_08,
1403 class ARGS_09,
1404 class ARGS_10,
1405 class ARGS_11>
1406 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1407 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1408 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1409 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1410 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1411 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1412 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1413 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1414 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1415 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1416 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
1417 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11);
1418#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 11
1419
1420#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 12
1421 template <class ARGS_01,
1422 class ARGS_02,
1423 class ARGS_03,
1424 class ARGS_04,
1425 class ARGS_05,
1426 class ARGS_06,
1427 class ARGS_07,
1428 class ARGS_08,
1429 class ARGS_09,
1430 class ARGS_10,
1431 class ARGS_11,
1432 class ARGS_12>
1433 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1434 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1435 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1436 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1437 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1438 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1439 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1440 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1441 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1442 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1443 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
1444 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
1445 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12);
1446#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 12
1447
1448#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 13
1449 template <class ARGS_01,
1450 class ARGS_02,
1451 class ARGS_03,
1452 class ARGS_04,
1453 class ARGS_05,
1454 class ARGS_06,
1455 class ARGS_07,
1456 class ARGS_08,
1457 class ARGS_09,
1458 class ARGS_10,
1459 class ARGS_11,
1460 class ARGS_12,
1461 class ARGS_13>
1462 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1463 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1464 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1465 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1466 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1467 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1468 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1469 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1470 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1471 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1472 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
1473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
1474 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
1475 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13);
1476#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 13
1477
1478#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 14
1479 template <class ARGS_01,
1480 class ARGS_02,
1481 class ARGS_03,
1482 class ARGS_04,
1483 class ARGS_05,
1484 class ARGS_06,
1485 class ARGS_07,
1486 class ARGS_08,
1487 class ARGS_09,
1488 class ARGS_10,
1489 class ARGS_11,
1490 class ARGS_12,
1491 class ARGS_13,
1492 class ARGS_14>
1493 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1494 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1495 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1496 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1497 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1498 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1499 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1500 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1501 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1502 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1503 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
1504 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
1505 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
1506 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
1507 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14);
1508#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_A >= 14
1509
1510#else
1511// The generated code below is a workaround for the absence of perfect
1512// forwarding in some compilers.
1513
1514 template <class... ARGS>
1515 void createInplace(BloombergLP::bslma::Allocator *basicAllocator,
1516 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
1517// }}} END GENERATED CODE
1518#endif
1519
1520 /// Modify this shared pointer to manage the same modifiable object (if
1521 /// any) as the specified `source` shared pointer to the (template
1522 /// parameter) type `ANY_TYPE`, and refer to the modifiable object at
1523 /// the specified `object` address (i.e., make this shared pointer an
1524 /// "alias" of `source`). If this shared pointer is already managing a
1525 /// (possibly shared) object, then release the shared reference to that
1526 /// shared object, and destroy it using its associated deleter if this
1527 /// shared pointer held the last shared reference to that object.
1528 ///
1529 /// \note Note that typically the objects referred to by `source` and `object` have
1530 /// identical lifetimes (e.g., one might be a part of the other), so
1531 /// that the deleter for `source` will destroy them both, but they do
1532 /// not necessarily have the same type. Also note that if `source` is
1533 /// empty, then this shared pointer will be reset to an empty state,
1534 /// even if `object` is not null (in which case this empty shared
1535 /// pointer will refer to the same object as `object`). Also note that
1536 /// if `object` is null and `source` is not empty, then this shared
1537 /// pointer will be reset to a (reference-counted) null pointer alias.
1538 /// Also note that this function is logically equivalent to:
1539 /// @code
1540 /// *this = shared_ptr<ELEMENT_TYPE>(source, object);
1541 /// @endcode
1542 /// Further note that the behavior of this method is the same as
1543 /// `reset(source, object)`.
1544 ///
1545 /// @deprecated Use @ref reset instead.
1546 template <class ANY_TYPE>
1547 void loadAlias(const shared_ptr<ANY_TYPE>& source,
1548 ELEMENT_TYPE *object);
1549
1550 /// Return the pair consisting of the addresses of the modifiable
1551 /// `ELEMENT_TYPE` object referred to, and the representation shared by,
1552 /// this shared pointer, and reset this shared pointer to the empty
1553 /// state, referring to no object, with no effect on the representation.
1554 /// The reference counter is not modified nor is the shared object
1555 /// deleted; if the reference count of the representation is greater
1556 /// than one, then it is not safe to release the representation (thereby
1557 /// destroying the shared object), but it is always safe to create
1558 /// another shared pointer with the representation using the constructor
1559 /// with the following signature:
1560 /// @code
1561 /// 'shared_ptr(ELEMENT_TYPE *ptr,
1562 /// BloombergLP::bslma::SharedPtrRep *rep)'
1563 /// @endcode
1564 ///
1565 /// \note Note that this function returns a pair of null pointers if this
1566 /// shared pointer is empty.
1567 pair<element_type *, BloombergLP::bslma::SharedPtrRep *> release()
1569
1570#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1571 // DEPRECATED BDE LEGACY MANIPULATORS
1572
1573 /// Reset this shared pointer to the empty state. If this shared
1574 /// pointer is managing a (possibly shared) object, then release the
1575 /// reference to the shared object, calling the associated deleter to
1576 /// destroy the shared object if this shared pointer is the last reference.
1577 ///
1578 /// \note Note that the behavior of this method is the same as
1579 /// `reset()`.
1580 ///
1581 /// @deprecated Use @ref reset instead.
1583
1584 /// Modify this shared pointer to manage the modifiable object of the
1585 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1586 /// address and to refer to `(ELEMENT_TYPE *)ptr`. If this shared
1587 /// pointer is already managing a (possibly shared) object, then, unless
1588 /// an exception is thrown allocating memory to manage `ptr`, release
1589 /// the reference to the shared object, calling the associated deleter
1590 /// to destroy the shared object if this shared pointer is the last
1591 /// reference. The currently installed default allocator is used to
1592 /// allocate the internal representation of this shared pointer, and the
1593 /// shared object will be destroyed by a call to `delete ptr` when all
1594 /// references have been released. If an exception is thrown allocating
1595 /// the internal representation, then `delete ptr` is called and this
1596 /// shared pointer retains ownership of its original object. If
1597 /// `COMPATIBLE_TYPE*` is not implicitly convertible to `ELEMENT_TYPE*`,
1598 /// then a compiler diagnostic will be emitted indicating the error.
1599 ///
1600 /// \note Note that if `ptr` is 0, then this shared pointer will still
1601 /// allocate an internal representation to share ownership of that empty
1602 /// state, which will be reclaimed when the last reference is destroyed.
1603 /// Also note also that the behavior of this method is the same as
1604 /// `reset(ptr)`.
1605 ///
1606 /// @deprecated Use @ref reset instead.
1607 template <class COMPATIBLE_TYPE>
1608 void load(COMPATIBLE_TYPE *ptr);
1609
1610 /// Modify this shared pointer to manage the modifiable object of the
1611 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1612 /// address and to refer to `(ELEMENT_TYPE *)ptr`. If this shared
1613 /// pointer is already managing a (possibly shared) object, then, unless
1614 /// an exception is thrown allocating memory to manage `ptr`, release
1615 /// the reference to the shared object, calling the associated deleter
1616 /// to destroy the shared object if this shared pointer is the last
1617 /// reference. Use the specified `basicAllocator` to allocate the
1618 /// internal representation of this shared pointer and to destroy the
1619 /// shared object when all references have been released; if
1620 /// `basicAllocator` is 0, the currently installed default allocator is
1621 /// used. If an exception is thrown allocating the internal
1622 /// representation, then destroy `*ptr` with a call to
1623 /// `alloc->deleteObject(ptr)` where `alloc` is the chosen allocator,
1624 /// and this shared pointer retains ownership of its original object.
1625 /// If `COMPATIBLE_TYPE *` is not implicitly convertible to
1626 /// `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
1627 ///
1628 /// \note Note that if `ptr` is 0, then this shared
1629 /// pointer will still allocate an internal representation to share
1630 /// ownership of that empty state, which will be reclaimed when the last
1631 /// reference is destroyed. Also note that this function is logically
1632 /// equivalent to:
1633 /// @code
1634 /// *this = shared_ptr<ELEMENT_TYPE>(ptr, basicAllocator);
1635 /// @endcode
1636 ///
1637 /// @deprecated Use @ref reset instead.
1638 template <class COMPATIBLE_TYPE>
1639 void load(COMPATIBLE_TYPE *ptr,
1640 BloombergLP::bslma::Allocator *basicAllocator);
1641
1642 /// Modify this shared pointer to manage the modifiable object of the
1643 /// (template parameter) type `COMPATIBLE_TYPE` at the specified `ptr`
1644 /// address, refer to `(ELEMENT_TYPE *)ptr` and use the specified
1645 /// `deleter` to delete the shared object when all references have been
1646 /// released. Use the specified `basicAllocator` to allocate and
1647 /// deallocate the internal representation of the shared pointer. If
1648 /// `basicAllocator` is 0, the currently installed default allocator is
1649 /// used. If this shared pointer is already managing a (possibly
1650 /// shared) object, then, unless an exception is thrown creating storage
1651 /// to manage `ptr`, release the shared reference to that shared object,
1652 /// and destroy it using its associated deleter if this shared pointer
1653 /// held the last shared reference to that object. If `DELETER` is a
1654 /// reference type, then `deleter` is assumed to be a function-like
1655 /// deleter that may be invoked to destroy the object referred to by a
1656 /// single argument of type `COMPATIBLE_TYPE *` (i.e., `deleter(ptr)`
1657 /// will be called to destroy the shared object). If `DELETER` is a
1658 /// pointer type, then `deleter` is assumed to be a pointer to a factory
1659 /// object that exposes a member function that can be invoked as
1660 /// `deleteObject(ptr)` that will be called to destroy the object at the
1661 /// `ptr` address (i.e., `deleter->deleteObject(ptr)` will be called to
1662 /// delete the shared object). (See the "Deleters" section in the
1663 /// component-level documentation.) If an exception is thrown
1664 /// allocating the internal representation, then `deleter(ptr)` is
1665 /// called (or `deleter->deleteObject(ptr)` for factory-type deleters)
1666 /// and this shared pointer retains ownership of its original object.
1667 ///
1668 /// \pre The behavior is undefined unless `deleter(ptr)` is a well-defined
1669 /// expression (or `deleter->deleteObject(ptr)` for factory-type
1670 /// deleters), and unless the copy constructor for `deleter` does not
1671 /// throw an exception. If `COMPATIBLE_TYPE *` is not implicitly
1672 /// convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error.
1673 ///
1674 /// \note Note that, for factory deleters, the
1675 /// `deleter` must remain valid until all references to `ptr` have been
1676 /// released. Also note that if `ptr` is 0, then an internal
1677 /// representation will still be allocated, and this shared pointer will
1678 /// share ownership of a copy of `deleter`. Further note that this
1679 /// function is logically equivalent to:
1680 /// @code
1681 /// *this = shared_ptr<ELEMENT_TYPE>(ptr, deleter, basicAllocator);
1682 /// @endcode
1683 ///
1684 /// @deprecated Use @ref reset instead.
1685 template <class COMPATIBLE_TYPE, class DELETER>
1686 void load(COMPATIBLE_TYPE *ptr,
1687 const DELETER& deleter,
1688 BloombergLP::bslma::Allocator *basicAllocator);
1689
1690#endif // BDE_OMIT_INTERNAL_DEPRECATED
1691
1692 // ACCESSORS
1693
1694 /// Return a value of an "unspecified bool" type that evaluates to
1695 /// `false` if this shared pointer does not refer to an object, and `true` otherwise.
1696 ///
1697 /// \note Note that this conversion operator allows a
1698 /// shared pointer to be used within a conditional context (e.g., within
1699 /// an `if` or `while` statement), but does *not* allow shared pointers
1700 /// to unrelated types to be compared (e.g., via `<` or `>`).
1701 operator BoolType() const BSLS_KEYWORD_NOEXCEPT;
1702
1703 /// Return a reference providing modifiable access to the object
1704 /// referred to by this shared pointer.
1705 ///
1706 /// \pre The behavior is undefined unless this shared pointer refers to an object, and `ELEMENT_TYPE`
1707 /// is not (potentially `const` or `volatile` qualified) `void`.
1708 typename add_lvalue_reference<ELEMENT_TYPE>::type
1709 operator*() const BSLS_KEYWORD_NOEXCEPT;
1710
1711 /// Return the address providing modifiable access to the object
1712 /// referred to by this shared pointer, or 0 if this shared pointer does not refer to an object.
1713 ///
1714 /// \note Note that applying this operator
1715 /// conventionally (e.g., to invoke a method) to an shared pointer that
1716 /// does not refer to an object will result in undefined behavior.
1717 ELEMENT_TYPE *operator->() const BSLS_KEYWORD_NOEXCEPT;
1718
1719 /// Return the address providing modifiable access to the object
1720 /// referred to by this shared pointer, or 0 if this shared pointer does
1721 /// not refer to an object.
1723
1724 /// Return a reference providing modifiable access to the object at the
1725 /// specified `index` offset in the object referred to by this shared pointer.
1726 ///
1727 /// \pre The behavior is undefined unless this shared pointer is
1728 /// not empty, `ELEMENT_TYPE` is not `void` (a compiler error will be
1729 /// generated if this operator is instantiated within the
1730 /// `shared_ptr<void>` class), and this shared pointer refers to an
1731 /// array of `ELEMENT_TYPE` objects. Instead of `element_type &`, we
1732 /// use `add_lvalue_reference<element_type>::type` for the return type
1733 /// because that allows people to instantiate `shared_ptr<cv_void>`, as long as they don't use this method.
1734 ///
1735 /// \note Note that this method is
1736 /// logically equivalent to `*(get() + index)`.
1737 typename add_lvalue_reference<element_type>::type
1738 operator[](ptrdiff_t index) const;
1739
1740 template<class ANY_TYPE>
1741 bool owner_before(const shared_ptr<ANY_TYPE>& other) const
1743
1744 /// Return `true` if the address of the
1745 /// `BloombergLP::bslma::SharedPtrRep` object used by this shared
1746 /// pointer is ordered before the address of the
1747 /// `BloombergLP::bslma::SharedPtrRep` object used by the specified
1748 /// `other` shared pointer under the total ordering defined by
1749 /// `std::less<BloombergLP::bslma::SharedPtrRep *>`, and `false`
1750 /// otherwise.
1751 template<class ANY_TYPE>
1752 bool owner_before(const weak_ptr<ANY_TYPE>& other) const
1754
1755 template<class ANY_TYPE>
1756 bool owner_equal(const shared_ptr<ANY_TYPE>& other) const
1758
1759 /// Return `true` if the address of the
1760 /// `BloombergLP::bslma::SharedPtrRep` object used by this shared
1761 /// pointer is equal to the address of the
1762 /// `BloombergLP::bslma::SharedPtrRep` object used by the specified
1763 /// `other` shared pointer, and `false` otherwise.
1764 template<class ANY_TYPE>
1765 bool owner_equal(const weak_ptr<ANY_TYPE>& other) const
1767
1768 /// Return an unspecified value such that, for any object `x` where
1769 /// `owner_equal(x)` is true, `owner_hash() == x.owner_hash()` is true.
1770 ///
1771 /// \note Note that this is based on the hash of the address of the
1772 /// `BloombergLP::bslma::SharedPtrRep` object used by this object.
1773 /// Note also that for two empty smart pointers `x` and `y`,
1774 /// `x.owner_hash() == y.owner_hash()` is true.
1775 size_t owner_hash() const BSLS_KEYWORD_NOEXCEPT;
1776
1778 "deprecated_cpp17_standard_library_features",
1779 "do not use")
1780 /// Return `true` if this shared pointer is not empty and does not share
1781 /// ownership of the object it managed with any other shared pointer, and `false` otherwise.
1782 ///
1783 /// \note Note that a shared pointer with a custom
1784 /// deleter can refer to a null pointer without being empty, and so may
1785 /// be `unique`. Also note that the result of this function may not be
1786 /// reliable in a multi-threaded program, where a weak pointer may be
1787 /// locked on another thread.
1788 ///
1789 /// @deprecated This function is deprecated in C++17 because its
1790 /// correctness is not guaranteed since the value returned by the used
1791 /// @ref use_count function is approximate.
1792 bool unique() const BSLS_KEYWORD_NOEXCEPT;
1793
1794 /// Return a "snapshot" of the number of shared pointers (including this
1795 /// one) that share ownership of the object managed by this shared pointer.
1796 ///
1797 /// \note Note that 0 is returned if this shared pointer is empty.
1798 /// Also note that any result other than 0 may be unreliable in a
1799 /// multi-threaded program, where another pointer sharing ownership in a
1800 /// different thread may be copied or destroyed, or a weak pointer may
1801 /// be locked in the case that 1 is returned (that would otherwise
1802 /// indicate unique ownership).
1803 long use_count() const BSLS_KEYWORD_NOEXCEPT;
1804
1805 // ADDITIONAL BSL ACCESSORS
1806
1807 /// Return a managed pointer that refers to the same object as this
1808 /// shared pointer. If this shared pointer is not empty, and is not
1809 /// null, then increment the shared count on the shared object, and give
1810 /// the managed pointer a deleter that decrements the reference count for the shared object.
1811 ///
1812 /// \note Note that if this `shared_ptr` is reference-
1813 /// counting a null pointer, the empty `bslma::ManagedPtr` returned will
1814 /// not participate in that shared ownership.
1815 BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE> managedPtr() const;
1816
1817 /// Return the address providing modifiable access to the
1818 /// `BloombergLP::bslma::SharedPtrRep` object used by this shared
1819 /// pointer, or 0 if this shared pointer is empty.
1820 BloombergLP::bslma::SharedPtrRep *rep() const BSLS_KEYWORD_NOEXCEPT;
1821
1822#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1823 // DEPRECATED BDE LEGACY ACCESSORS
1824
1825 /// Return a "snapshot" of the number of shared pointers (including this
1826 /// one) that share ownership of the object managed by this shared pointer.
1827 ///
1828 /// \note Note that the behavior of this function is the same as
1829 /// @ref use_count , and the result may be unreliable in multi-threaded code
1830 /// for the same reasons.
1831 ///
1832 /// @deprecated Use @ref use_count instead.
1834
1835 /// Return the address providing modifiable access to the object
1836 /// referred to by this shared pointer, or 0 if this shared pointer does not refer to an object.
1837 ///
1838 /// \note Note that the behavior of this function is
1839 /// the same as `get`.
1840 ///
1841 /// @deprecated Use @ref get instead.
1843#endif // BDE_OMIT_INTERNAL_DEPRECATED
1844};
1845
1846#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1847// CLASS TEMPLATE DEDUCTION GUIDES
1848
1849// The obvious deduction guide:
1850// template <class T>
1851// shared_ptr(T*) -> shared_ptr<T>;
1852// is not provided because there's no way to distinguish from T* and T[].
1853
1854/// Deduce the specified type `ELEMENT_TYPE` corresponding template
1855/// parameter of the `bsl::weak_ptr` supplied to the constructor of
1856/// `shared_ptr`.
1857template<class ELEMENT_TYPE>
1858shared_ptr(weak_ptr<ELEMENT_TYPE>) -> shared_ptr<ELEMENT_TYPE>;
1859
1860/// Deduce the specified type `ELEMENT_TYPE` corresponding template
1861/// parameter of the `std::unique_ptr` supplied to the constructor of
1862/// `shared_ptr`.
1863template<class ELEMENT_TYPE, class DELETER>
1864shared_ptr(std::unique_ptr<ELEMENT_TYPE, DELETER>)
1865-> shared_ptr<ELEMENT_TYPE>;
1866
1867/// Deduce the specified type `ELEMENT_TYPE` corresponding template
1868/// parameter of the `std::unique_ptr` supplied to the constructor of
1869/// `shared_ptr`. This guide does not participate in deduction unless the
1870/// specified `ALLOC` inherits from `bslma::Allocator`.
1871template<class ELEMENT_TYPE,
1872 class DELETER,
1873 class ALLOC,
1874 class = typename bsl::enable_if_t<
1875 bsl::is_convertible_v<ALLOC *, BloombergLP::bslma::Allocator *>>
1876 >
1877shared_ptr(std::unique_ptr<ELEMENT_TYPE, DELETER>, ALLOC *)
1878-> shared_ptr<ELEMENT_TYPE>;
1879
1880// Deduction guides for `auto_ptr` and @ref auto_ptr_ref are deliberately not
1881// provided, since auto_ptr has been removed from C++17.
1882
1883/// Deduce the specified type `ELEMENT_TYPE` corresponding template
1884/// parameter of the `bslma::ManagedPtr` supplied to the constructor of
1885/// `shared_ptr`.
1886template<class ELEMENT_TYPE>
1887shared_ptr(BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>)
1888-> shared_ptr<ELEMENT_TYPE>;
1889
1890/// Deduce the specified type `ELEMENT_TYPE` corresponding template
1891/// parameter of the `bslma::ManagedPtr` supplied to the constructor of
1892/// `shared_ptr`. This guide does not participate in deduction unless the
1893/// specified `ALLOC` inherits from `bslma::Allocator`.
1894template<class ELEMENT_TYPE,
1895 class ALLOC,
1896 class = typename bsl::enable_if_t<
1897 bsl::is_convertible_v<ALLOC *, BloombergLP::bslma::Allocator *>>
1898 >
1899shared_ptr(BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>, ALLOC *)
1900-> shared_ptr<ELEMENT_TYPE>;
1901#endif
1902
1903// FREE OPERATORS
1904
1905/// Return `true` if the specified `lhs` shared pointer refers to the same
1906/// object (if any) as that referred to by the specified `rhs` shared
1907/// pointer (if any), and `false` otherwise; a compiler diagnostic will be
1908/// emitted indicating the error unless a (raw) pointer to `LHS_TYPE` can be compared to a (raw) pointer to `RHS_TYPE`.
1909///
1910/// \note Note that two shared
1911/// pointers that compare equal do not necessarily manage the same object
1912/// due to aliasing.
1913template <class LHS_TYPE, class RHS_TYPE>
1914bool operator==(const shared_ptr<LHS_TYPE>& lhs,
1915 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1916
1917#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1918
1919/// Perform a three-way comparison of the specified `lhs` and the specified
1920/// `rhs` pointers by using the comparison operators of `LHS_TYPE *` and
1921/// `RHS_TYPE *`; return the result of that comparison.
1922template<class LHS_TYPE, class RHS_TYPE>
1923strong_ordering operator<=>(const shared_ptr<LHS_TYPE>& lhs,
1924 const shared_ptr<RHS_TYPE>& rhs)
1926
1927#else
1928
1929/// Return `true` if the specified `lhs` shared pointer does not refer to
1930/// the same object (if any) as that referred to by the specified `rhs`
1931/// shared pointer (if any), and `false` otherwise; a compiler diagnostic
1932/// will be emitted indicating the error unless a (raw) pointer to
1933/// `LHS_TYPE` can be compared to a (raw) pointer to `RHS_TYPE`.
1934///
1935/// \note Note that two shared pointers that do not compare equal may manage the same object
1936/// due to aliasing.
1937template <class LHS_TYPE, class RHS_TYPE>
1938bool operator!=(const shared_ptr<LHS_TYPE>& lhs,
1939 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1940
1941/// Return `true` if the address of the object that the specified `lhs`
1942/// shared pointer refers to is ordered before the address of the object
1943/// that the specified `rhs` shared pointer refers to under the total
1944/// ordering supplied by `std::less<T *>`, where `T *` is the composite
1945/// pointer type of `LHS_TYPE *` and `RHS_TYPE *`, and `false` otherwise.
1946template<class LHS_TYPE, class RHS_TYPE>
1947bool operator<(const shared_ptr<LHS_TYPE>& lhs,
1948 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1949
1950/// Return `true` if the address of the object that the specified `lhs`
1951/// shared pointer refers to is ordered after the address of the object
1952/// that the specified `rhs` shared pointer refers to under the total
1953/// ordering supplied by `std::less<T *>`, where `T *` is the composite
1954/// pointer type of `LHS_TYPE *` and `RHS_TYPE *`, and `false` otherwise.
1955template<class LHS_TYPE, class RHS_TYPE>
1956bool operator>(const shared_ptr<LHS_TYPE>& lhs,
1957 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1958
1959/// Return `true` if the specified `lhs` shared pointer refers to the same
1960/// object as the specified `rhs` shared pointer, or if the address of the
1961/// object referred to by `lhs` (if any) is ordered before the address of
1962/// the object referred to by `rhs` (if any) under the total ordering
1963/// supplied by `std::less<T *>`, where `T *` is the composite pointer type
1964// of `LHS_TYPE *` and `RHS_TYPE *`, and `false` otherwise.
1965template<class LHS_TYPE, class RHS_TYPE>
1966bool operator<=(const shared_ptr<LHS_TYPE>& lhs,
1967 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1968
1969/// Return `true` if the specified `lhs` shared pointer refers to the same
1970/// object as the specified `rhs` shared pointer, or if the address of the
1971/// object referred to by `lhs` (if any) is ordered after the address of the
1972/// object referred to by `rhs` (if any) under the total ordering supplied
1973/// by `std::less<T *>`, where `T *` is the composite pointer type of
1974/// `LHS_TYPE *` and `RHS_TYPE *`, and `false` otherwise.
1975template<class LHS_TYPE, class RHS_TYPE>
1976bool operator>=(const shared_ptr<LHS_TYPE>& lhs,
1977 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
1978
1979#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1980
1981/// Return `true` if the specified `lhs` shared pointer does not refer to an
1982/// object, and `false` otherwise.
1983template <class LHS_TYPE>
1984bool operator==(const shared_ptr<LHS_TYPE>& lhs,
1986
1987#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1988
1989/// Perform a three-way comparison of the specified `ptr` and null pointer
1990/// by using the comparison operators of `TYPE *`; return the result of that
1991/// comparison.
1992template<class TYPE>
1993strong_ordering operator<=>(const shared_ptr<TYPE>& ptr,
1995
1996#else
1997
1998/// Return `true` if the specified `rhs` shared pointer does not refer to an
1999/// object, and `false` otherwise.
2000template <class RHS_TYPE>
2002 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
2003
2004/// Return `true` if the specified `lhs` shared pointer refers to an object,
2005/// and `false` otherwise.
2006template <class LHS_TYPE>
2007bool operator!=(const shared_ptr<LHS_TYPE>& lhs,
2009
2010/// Return `true` if the specified `rhs` shared pointer refers to an object,
2011/// and `false` otherwise.
2012template <class RHS_TYPE>
2014 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
2015
2016/// Return `true` if the address of the object referred to by the specified
2017/// `lhs` shared pointer is ordered before the null-pointer value under the
2018/// total ordering supplied by `std::less<LHS_TYPE *>`, and `false`
2019/// otherwise.
2020template <class LHS_TYPE>
2021bool operator<(const shared_ptr<LHS_TYPE>& lhs, nullptr_t)
2023
2024/// Return `true` if the address of the object referred to by the specified
2025/// `rhs` shared pointer is ordered after the null-pointer value under the
2026/// total ordering supplied by `std::less<RHS_TYPE *>`, and `false`
2027/// otherwise.
2028template <class RHS_TYPE>
2029bool operator<(nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
2031
2032/// Return `true` if the specified `lhs` shared pointer does not refer to an
2033/// object, or if the address of the object referred to by `lhs` is ordered
2034/// before the null-pointer value under the total ordering supplied by
2035/// `std::less<LHS_TYPE *>`, and `false` otherwise.
2036template <class LHS_TYPE>
2037bool operator<=(const shared_ptr<LHS_TYPE>& lhs,
2039
2040/// Return `true` if the specified `rhs` shared pointer does not refer to an
2041/// object, or if the address of the object referred to by `rhs` is ordered
2042/// after the null-pointer value under the total ordering supplied by
2043/// `std::less<RHS_TYPE *>`, and `false` otherwise.
2044template <class RHS_TYPE>
2046 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
2047
2048/// Return `true` if the address of the object referred to by the specified
2049/// `lhs` shared pointer is ordered after the null-pointer value under the
2050/// total ordering supplied by `std::less<LHS_TYPE *>`, and `false`
2051/// otherwise.
2052template <class LHS_TYPE>
2053bool operator>(const shared_ptr<LHS_TYPE>& lhs, nullptr_t)
2055
2056/// Return `true` if the address of the object referred to by the specified
2057/// `rhs` shared pointer is ordered before the null-pointer value under the
2058/// total ordering supplied by `std::less<RHS_TYPE *>`, and `false`
2059/// otherwise.
2060template <class RHS_TYPE>
2061bool operator>(nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
2063
2064/// Return `true` if the specified `lhs` shared pointer does not refer to an
2065/// object, or if the address of the object referred to by `lhs` is ordered
2066/// after the null-pointer value under the total ordering supplied by
2067/// `std::less<LHS_TYPE *>`, and `false` otherwise.
2068template <class LHS_TYPE>
2069bool operator>=(const shared_ptr<LHS_TYPE>& lhs,
2071
2072/// Return `true` if the specified `rhs` shared pointer does not refer to an
2073/// object, or if the address of the object referred to by `rhs` is ordered
2074/// before the null-pointer value under the total ordering supplied by
2075/// `std::less<RHS_TYPE *>`, and `false` otherwise.
2076template <class RHS_TYPE>
2078 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
2079
2080#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2081
2082/// Print to the specified `stream` the address of the shared object
2083/// referred to by the specified `rhs` shared pointer and return a reference
2084/// to the modifiable `stream`.
2085template<class CHAR_TYPE, class CHAR_TRAITS, class ELEMENT_TYPE>
2086std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
2087operator<<(std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>& stream,
2088 const shared_ptr<ELEMENT_TYPE>& rhs);
2089
2090// ASPECTS
2091
2092/// Pass the address of the object referred to by the specified `input`
2093/// shared pointer to the specified `hashAlg` hashing algorithm of (template
2094/// parameter) type `HASHALG`.
2095template <class HASHALG, class ELEMENT_TYPE>
2096void hashAppend(HASHALG& hashAlg, const shared_ptr<ELEMENT_TYPE>& input);
2097
2098/// Efficiently exchange the states of the specified `a` and `b` shared
2099/// pointers such that each will refer to the object formerly referred to by
2100/// the other, and each will manage the object formerly managed by the
2101/// other.
2102template <class ELEMENT_TYPE>
2103void swap(shared_ptr<ELEMENT_TYPE>& a, shared_ptr<ELEMENT_TYPE>& b)
2105
2106// STANDARD FREE FUNCTIONS
2107
2108/// Return the address of deleter used by the specified `p` shared pointer
2109/// if the (template parameter) type `DELETER` is the type of the deleter
2110/// installed in `p`, and a null pointer value otherwise.
2111template<class DELETER, class ELEMENT_TYPE>
2112DELETER *get_deleter(const shared_ptr<ELEMENT_TYPE>& p) BSLS_KEYWORD_NOEXCEPT;
2113
2114// STANDARD CAST FUNCTIONS
2115
2116/// Return a `shared_ptr<TO_TYPE>` object sharing ownership of the same
2117/// object as the specified `source` shared pointer to the (template
2118/// parameter) `FROM_TYPE`, and referring to `const_cast<TO_TYPE *>(source.get())`.
2119///
2120/// \note Note that if `source` cannot be
2121/// `const`-cast to `TO_TYPE *`, then a compiler diagnostic will be emitted
2122/// indicating the error.
2123template<class TO_TYPE, class FROM_TYPE>
2124shared_ptr<TO_TYPE> const_pointer_cast(const shared_ptr<FROM_TYPE>& source)
2126
2127/// Return a `shared_ptr<TO_TYPE>` object sharing ownership of the same
2128/// object as the specified `source` shared pointer to the (template
2129/// parameter) `FROM_TYPE`, and referring to
2130/// `dynamic_cast<TO_TYPE*>(source.get())`. If `source` cannot be
2131/// dynamically cast to `TO_TYPE *`, then an empty `shared_ptr<TO_TYPE>`
2132/// object is returned.
2133template<class TO_TYPE, class FROM_TYPE>
2134shared_ptr<TO_TYPE> dynamic_pointer_cast(const shared_ptr<FROM_TYPE>& source)
2136
2137/// Return a `shared_ptr<TO_TYPE>` object sharing ownership of the same
2138/// object as the specified `source` shared pointer to the (template
2139/// parameter) `FROM_TYPE`, and referring to `static_cast<TO_TYPE *>(source.get())`.
2140///
2141/// \note Note that if `source` cannot be
2142/// statically cast to `TO_TYPE *`, then a compiler diagnostic will be
2143/// emitted indicating the error.
2144template<class TO_TYPE, class FROM_TYPE>
2145shared_ptr<TO_TYPE> static_pointer_cast(const shared_ptr<FROM_TYPE>& source)
2147
2148/// Return a `shared_ptr<TO_TYPE>` object sharing ownership of the same
2149/// object as the specified `source` shared pointer to the (template
2150/// parameter) `FROM_TYPE`, and referring to `reinterpret_cast<TO_TYPE *>(source.get())`.
2151///
2152/// \note Note that if `source`
2153/// cannot be reinterpret_cast-ed to `TO_TYPE *`, then a compiler diagnostic
2154/// will be emitted indicating the error.
2155template<class TO_TYPE, class FROM_TYPE>
2156shared_ptr<TO_TYPE> reinterpret_pointer_cast(
2157 const shared_ptr<FROM_TYPE>& source) BSLS_KEYWORD_NOEXCEPT;
2158
2159
2160// STANDARD FACTORY FUNCTIONS
2161 // ===========================
2162 // allocate_shared(ALLOC, ...)
2163 // ===========================
2164
2165#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2166// {{{ BEGIN GENERATED CODE
2167// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
2168#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
2169#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
2170#endif
2171#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B
2172#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B BSLSTL_SHAREDPTR_VARIADIC_LIMIT
2173#endif
2174
2175#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 0
2176template<class ELEMENT_TYPE, class ALLOC>
2177typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2178 shared_ptr<ELEMENT_TYPE> >::type
2179allocate_shared(ALLOC basicAllocator);
2180#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 0
2181
2182#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 1
2183template<class ELEMENT_TYPE, class ALLOC, class ARGS_01>
2184typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2185 shared_ptr<ELEMENT_TYPE> >::type
2186allocate_shared(ALLOC basicAllocator,
2187 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
2188#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 1
2189
2190#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 2
2191template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2192 class ARGS_02>
2193typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2194 shared_ptr<ELEMENT_TYPE> >::type
2195allocate_shared(ALLOC basicAllocator,
2196 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2197 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2198#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 2
2199
2200#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 3
2201template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2202 class ARGS_02,
2203 class ARGS_03>
2204typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2205 shared_ptr<ELEMENT_TYPE> >::type
2206allocate_shared(ALLOC basicAllocator,
2207 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2208 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2209 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2210#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 3
2211
2212#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 4
2213template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2214 class ARGS_02,
2215 class ARGS_03,
2216 class ARGS_04>
2217typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2218 shared_ptr<ELEMENT_TYPE> >::type
2219allocate_shared(ALLOC basicAllocator,
2220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2224#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 4
2225
2226#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 5
2227template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2228 class ARGS_02,
2229 class ARGS_03,
2230 class ARGS_04,
2231 class ARGS_05>
2232typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2233 shared_ptr<ELEMENT_TYPE> >::type
2234allocate_shared(ALLOC basicAllocator,
2235 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2236 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2237 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2238 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2239 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2240#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 5
2241
2242#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 6
2243template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2244 class ARGS_02,
2245 class ARGS_03,
2246 class ARGS_04,
2247 class ARGS_05,
2248 class ARGS_06>
2249typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2250 shared_ptr<ELEMENT_TYPE> >::type
2251allocate_shared(ALLOC basicAllocator,
2252 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2253 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2254 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2255 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2256 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2257 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2258#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 6
2259
2260#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 7
2261template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2262 class ARGS_02,
2263 class ARGS_03,
2264 class ARGS_04,
2265 class ARGS_05,
2266 class ARGS_06,
2267 class ARGS_07>
2268typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2269 shared_ptr<ELEMENT_TYPE> >::type
2270allocate_shared(ALLOC basicAllocator,
2271 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2272 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2273 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2275 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2278#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 7
2279
2280#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 8
2281template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2282 class ARGS_02,
2283 class ARGS_03,
2284 class ARGS_04,
2285 class ARGS_05,
2286 class ARGS_06,
2287 class ARGS_07,
2288 class ARGS_08>
2289typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2290 shared_ptr<ELEMENT_TYPE> >::type
2291allocate_shared(ALLOC basicAllocator,
2292 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2293 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2294 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2295 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2296 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2297 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2298 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2299 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2300#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 8
2301
2302#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 9
2303template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2304 class ARGS_02,
2305 class ARGS_03,
2306 class ARGS_04,
2307 class ARGS_05,
2308 class ARGS_06,
2309 class ARGS_07,
2310 class ARGS_08,
2311 class ARGS_09>
2312typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2313 shared_ptr<ELEMENT_TYPE> >::type
2314allocate_shared(ALLOC basicAllocator,
2315 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2316 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2317 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2318 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2319 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2320 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2321 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2322 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2323 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2324#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 9
2325
2326#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 10
2327template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2328 class ARGS_02,
2329 class ARGS_03,
2330 class ARGS_04,
2331 class ARGS_05,
2332 class ARGS_06,
2333 class ARGS_07,
2334 class ARGS_08,
2335 class ARGS_09,
2336 class ARGS_10>
2337typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2338 shared_ptr<ELEMENT_TYPE> >::type
2339allocate_shared(ALLOC basicAllocator,
2340 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2341 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2342 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2347 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2348 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2349 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2350#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 10
2351
2352#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 11
2353template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2354 class ARGS_02,
2355 class ARGS_03,
2356 class ARGS_04,
2357 class ARGS_05,
2358 class ARGS_06,
2359 class ARGS_07,
2360 class ARGS_08,
2361 class ARGS_09,
2362 class ARGS_10,
2363 class ARGS_11>
2364typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2365 shared_ptr<ELEMENT_TYPE> >::type
2366allocate_shared(ALLOC basicAllocator,
2367 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2368 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2369 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2370 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2371 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2374 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2375 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2376 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2377 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11);
2378#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 11
2379
2380#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 12
2381template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2382 class ARGS_02,
2383 class ARGS_03,
2384 class ARGS_04,
2385 class ARGS_05,
2386 class ARGS_06,
2387 class ARGS_07,
2388 class ARGS_08,
2389 class ARGS_09,
2390 class ARGS_10,
2391 class ARGS_11,
2392 class ARGS_12>
2393typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2394 shared_ptr<ELEMENT_TYPE> >::type
2395allocate_shared(ALLOC basicAllocator,
2396 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2397 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2398 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2401 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2402 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2404 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2405 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2406 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2407 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12);
2408#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 12
2409
2410#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 13
2411template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2412 class ARGS_02,
2413 class ARGS_03,
2414 class ARGS_04,
2415 class ARGS_05,
2416 class ARGS_06,
2417 class ARGS_07,
2418 class ARGS_08,
2419 class ARGS_09,
2420 class ARGS_10,
2421 class ARGS_11,
2422 class ARGS_12,
2423 class ARGS_13>
2424typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2425 shared_ptr<ELEMENT_TYPE> >::type
2426allocate_shared(ALLOC basicAllocator,
2427 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2428 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2429 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2430 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2431 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2432 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2433 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2434 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2435 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2436 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2437 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2438 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
2439 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13);
2440#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 13
2441
2442#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 14
2443template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2444 class ARGS_02,
2445 class ARGS_03,
2446 class ARGS_04,
2447 class ARGS_05,
2448 class ARGS_06,
2449 class ARGS_07,
2450 class ARGS_08,
2451 class ARGS_09,
2452 class ARGS_10,
2453 class ARGS_11,
2454 class ARGS_12,
2455 class ARGS_13,
2456 class ARGS_14>
2457typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2458 shared_ptr<ELEMENT_TYPE> >::type
2459allocate_shared(ALLOC basicAllocator,
2460 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2461 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2462 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2463 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2464 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2465 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2466 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2467 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2468 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2469 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2470 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2471 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
2472 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
2473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14);
2474#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_B >= 14
2475
2476#else
2477// The generated code below is a workaround for the absence of perfect
2478// forwarding in some compilers.
2479
2480template<class ELEMENT_TYPE, class ALLOC, class... ARGS>
2481typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2482 shared_ptr<ELEMENT_TYPE> >::type
2483allocate_shared(ALLOC basicAllocator,
2484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2485
2486// }}} END GENERATED CODE
2487#endif
2488
2489/// Return a `shared_ptr` object referring to and managing a new
2490/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2491/// specified `basicAllocator` will be used to supply a single contiguous
2492/// region of memory holding the returned shared pointer's internal
2493/// representation and the new `ARRAY_TYPE` object, and each element in the
2494/// array is default constructed.
2495template<class ARRAY_TYPE, class ALLOC>
2496typename enable_if<is_bounded_array<ARRAY_TYPE>::value &&
2498 shared_ptr<ARRAY_TYPE> >::type
2499allocate_shared(ALLOC basicAllocator);
2500
2501/// Return a `shared_ptr` object referring to and managing a new
2502/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2503/// specified `basicAllocator` will be used to supply a single contiguous
2504/// region of memory holding the returned shared pointer's internal
2505/// representation and the new `ARRAY_TYPE` object, and each element in the
2506/// array is constructed from the specified `value`.
2507template<class ARRAY_TYPE, class ALLOC>
2508typename enable_if<is_bounded_array<ARRAY_TYPE>::value &&
2510 shared_ptr<ARRAY_TYPE> >::type
2511allocate_shared(ALLOC basicAllocator,
2512 const typename remove_extent<ARRAY_TYPE>::type& value);
2513
2514/// Return a `shared_ptr` object referring to and managing a new
2515/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2516/// specified `basicAllocator` will be used to supply a single contiguous
2517/// region of memory holding the returned shared pointer's internal
2518/// representation and the new `ARRAY_TYPE` containing the specified
2519/// `numElements` number of elements, and each element in the array is
2520/// default constructed.
2521template<class ARRAY_TYPE, class ALLOC>
2522typename enable_if<is_unbounded_array<ARRAY_TYPE>::value &&
2524 shared_ptr<ARRAY_TYPE> >::type
2525allocate_shared(ALLOC basicAllocator, size_t numElements);
2526
2527/// Return a `shared_ptr` object referring to and managing a new
2528/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2529/// specified `basicAllocator` will be used to supply a single contiguous
2530/// region of memory holding the returned shared pointer's internal
2531/// representation and the new `ARRAY_TYPE` containing the specified
2532/// `numElements` number of elements, and each element in the array is
2533/// constructed from the specified `value`.
2534template<class ARRAY_TYPE, class ALLOC>
2535typename enable_if<is_unbounded_array<ARRAY_TYPE>::value &&
2537 shared_ptr<ARRAY_TYPE> >::type
2538allocate_shared(ALLOC basicAllocator,
2539 size_t numElements,
2540 const typename remove_extent<ARRAY_TYPE>::type& value);
2541
2542 // =========================================
2543 // allocate_shared_for_overwrite(ALLOC, ...)
2544 // =========================================
2545
2546/// Return a `shared_ptr` object referring to and managing a new
2547/// `ELEMENT_TYPE` object. The specified `basicAllocator` will be used to
2548/// supply a single contiguous region of memory holding the returned shared
2549/// pointer's internal representation and the new `ELEMENT_TYPE` object,
2550/// which is default-constructed.
2551template<class ELEMENT_TYPE, class ALLOC>
2552typename enable_if<!is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value,
2553 shared_ptr<ELEMENT_TYPE> >::type
2554allocate_shared_for_overwrite(ALLOC basicAllocator);
2555
2556/// Return a `shared_ptr` object referring to and managing a new
2557/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2558/// specified `basicAllocator` will be used to supply a single contiguous
2559/// region of memory holding the returned shared pointer's internal
2560/// representation and the new `ARRAY_TYPE` object, and the array is
2561/// default-constructed.
2562template<class ARRAY_TYPE, class ALLOC>
2563typename enable_if<is_bounded_array<ARRAY_TYPE>::value &&
2565 shared_ptr<ARRAY_TYPE> >::type
2566allocate_shared_for_overwrite(ALLOC basicAllocator);
2567
2568/// Return a `shared_ptr` object referring to and managing a new
2569/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2570/// specified `basicAllocator` will be used to supply a single contiguous
2571/// region of memory holding the returned shared pointer's internal
2572/// representation and the new `ARRAY_TYPE` containing the specified
2573/// `numElements` number of elements, and the array is default-constructed.
2574template<class ARRAY_TYPE, class ALLOC>
2575typename enable_if<is_unbounded_array<ARRAY_TYPE>::value &&
2577 shared_ptr<ARRAY_TYPE> >::type
2578allocate_shared_for_overwrite(ALLOC basicAllocator, size_t numElements);
2579
2580 // =============================
2581 // allocate_shared(ALLOC *, ...)
2582 // =============================
2583
2584#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2585// {{{ BEGIN GENERATED CODE
2586// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
2587#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
2588#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
2589#endif
2590#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C
2591#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C BSLSTL_SHAREDPTR_VARIADIC_LIMIT
2592#endif
2593
2594#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 0
2595template<class ELEMENT_TYPE, class ALLOC>
2596typename enable_if<!is_array<ELEMENT_TYPE>::value,
2597 shared_ptr<ELEMENT_TYPE> >::type
2598allocate_shared(ALLOC *basicAllocator);
2599#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 0
2600
2601#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 1
2602template<class ELEMENT_TYPE, class ALLOC, class ARGS_01>
2603typename enable_if<!is_array<ELEMENT_TYPE>::value,
2604 shared_ptr<ELEMENT_TYPE> >::type
2605allocate_shared(ALLOC *basicAllocator,
2606 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
2607#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 1
2608
2609#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 2
2610template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2611 class ARGS_02>
2612typename enable_if<!is_array<ELEMENT_TYPE>::value,
2613 shared_ptr<ELEMENT_TYPE> >::type
2614allocate_shared(ALLOC *basicAllocator,
2615 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2616 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2617#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 2
2618
2619#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 3
2620template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2621 class ARGS_02,
2622 class ARGS_03>
2623typename enable_if<!is_array<ELEMENT_TYPE>::value,
2624 shared_ptr<ELEMENT_TYPE> >::type
2625allocate_shared(ALLOC *basicAllocator,
2626 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2627 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2628 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2629#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 3
2630
2631#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 4
2632template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2633 class ARGS_02,
2634 class ARGS_03,
2635 class ARGS_04>
2636typename enable_if<!is_array<ELEMENT_TYPE>::value,
2637 shared_ptr<ELEMENT_TYPE> >::type
2638allocate_shared(ALLOC *basicAllocator,
2639 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2640 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2641 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2642 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2643#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 4
2644
2645#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 5
2646template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2647 class ARGS_02,
2648 class ARGS_03,
2649 class ARGS_04,
2650 class ARGS_05>
2651typename enable_if<!is_array<ELEMENT_TYPE>::value,
2652 shared_ptr<ELEMENT_TYPE> >::type
2653allocate_shared(ALLOC *basicAllocator,
2654 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2655 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2656 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2657 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2658 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2659#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 5
2660
2661#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 6
2662template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2663 class ARGS_02,
2664 class ARGS_03,
2665 class ARGS_04,
2666 class ARGS_05,
2667 class ARGS_06>
2668typename enable_if<!is_array<ELEMENT_TYPE>::value,
2669 shared_ptr<ELEMENT_TYPE> >::type
2670allocate_shared(ALLOC *basicAllocator,
2671 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2672 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2673 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2674 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2675 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2676 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2677#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 6
2678
2679#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 7
2680template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2681 class ARGS_02,
2682 class ARGS_03,
2683 class ARGS_04,
2684 class ARGS_05,
2685 class ARGS_06,
2686 class ARGS_07>
2687typename enable_if<!is_array<ELEMENT_TYPE>::value,
2688 shared_ptr<ELEMENT_TYPE> >::type
2689allocate_shared(ALLOC *basicAllocator,
2690 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2691 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2692 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2693 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2694 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2695 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2696 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2697#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 7
2698
2699#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 8
2700template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2701 class ARGS_02,
2702 class ARGS_03,
2703 class ARGS_04,
2704 class ARGS_05,
2705 class ARGS_06,
2706 class ARGS_07,
2707 class ARGS_08>
2708typename enable_if<!is_array<ELEMENT_TYPE>::value,
2709 shared_ptr<ELEMENT_TYPE> >::type
2710allocate_shared(ALLOC *basicAllocator,
2711 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2712 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2713 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2714 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2715 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2716 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2717 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2718 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2719#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 8
2720
2721#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 9
2722template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2723 class ARGS_02,
2724 class ARGS_03,
2725 class ARGS_04,
2726 class ARGS_05,
2727 class ARGS_06,
2728 class ARGS_07,
2729 class ARGS_08,
2730 class ARGS_09>
2731typename enable_if<!is_array<ELEMENT_TYPE>::value,
2732 shared_ptr<ELEMENT_TYPE> >::type
2733allocate_shared(ALLOC *basicAllocator,
2734 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2735 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2736 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2737 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2738 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2739 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2740 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2741 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2742 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2743#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 9
2744
2745#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 10
2746template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2747 class ARGS_02,
2748 class ARGS_03,
2749 class ARGS_04,
2750 class ARGS_05,
2751 class ARGS_06,
2752 class ARGS_07,
2753 class ARGS_08,
2754 class ARGS_09,
2755 class ARGS_10>
2756typename enable_if<!is_array<ELEMENT_TYPE>::value,
2757 shared_ptr<ELEMENT_TYPE> >::type
2758allocate_shared(ALLOC *basicAllocator,
2759 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2760 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2761 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2762 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2763 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2764 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2765 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2766 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2767 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2768 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2769#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 10
2770
2771#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 11
2772template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2773 class ARGS_02,
2774 class ARGS_03,
2775 class ARGS_04,
2776 class ARGS_05,
2777 class ARGS_06,
2778 class ARGS_07,
2779 class ARGS_08,
2780 class ARGS_09,
2781 class ARGS_10,
2782 class ARGS_11>
2783typename enable_if<!is_array<ELEMENT_TYPE>::value,
2784 shared_ptr<ELEMENT_TYPE> >::type
2785allocate_shared(ALLOC *basicAllocator,
2786 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2787 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2788 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2789 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2790 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2791 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2792 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2793 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2794 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2795 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2796 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11);
2797#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 11
2798
2799#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 12
2800template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2801 class ARGS_02,
2802 class ARGS_03,
2803 class ARGS_04,
2804 class ARGS_05,
2805 class ARGS_06,
2806 class ARGS_07,
2807 class ARGS_08,
2808 class ARGS_09,
2809 class ARGS_10,
2810 class ARGS_11,
2811 class ARGS_12>
2812typename enable_if<!is_array<ELEMENT_TYPE>::value,
2813 shared_ptr<ELEMENT_TYPE> >::type
2814allocate_shared(ALLOC *basicAllocator,
2815 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2816 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2817 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2818 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2819 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2820 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2821 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2822 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2823 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2824 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2825 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2826 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12);
2827#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 12
2828
2829#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 13
2830template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2831 class ARGS_02,
2832 class ARGS_03,
2833 class ARGS_04,
2834 class ARGS_05,
2835 class ARGS_06,
2836 class ARGS_07,
2837 class ARGS_08,
2838 class ARGS_09,
2839 class ARGS_10,
2840 class ARGS_11,
2841 class ARGS_12,
2842 class ARGS_13>
2843typename enable_if<!is_array<ELEMENT_TYPE>::value,
2844 shared_ptr<ELEMENT_TYPE> >::type
2845allocate_shared(ALLOC *basicAllocator,
2846 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2847 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2848 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2849 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2850 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2851 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2852 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2853 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2854 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2855 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2856 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2857 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
2858 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13);
2859#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 13
2860
2861#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 14
2862template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
2863 class ARGS_02,
2864 class ARGS_03,
2865 class ARGS_04,
2866 class ARGS_05,
2867 class ARGS_06,
2868 class ARGS_07,
2869 class ARGS_08,
2870 class ARGS_09,
2871 class ARGS_10,
2872 class ARGS_11,
2873 class ARGS_12,
2874 class ARGS_13,
2875 class ARGS_14>
2876typename enable_if<!is_array<ELEMENT_TYPE>::value,
2877 shared_ptr<ELEMENT_TYPE> >::type
2878allocate_shared(ALLOC *basicAllocator,
2879 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2880 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2881 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2882 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2883 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2884 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2885 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2886 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2887 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2888 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
2889 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
2890 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
2891 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
2892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14);
2893#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_C >= 14
2894
2895#else
2896// The generated code below is a workaround for the absence of perfect
2897// forwarding in some compilers.
2898
2899template<class ELEMENT_TYPE, class ALLOC, class... ARGS>
2900typename enable_if<!is_array<ELEMENT_TYPE>::value,
2901 shared_ptr<ELEMENT_TYPE> >::type
2902allocate_shared(ALLOC *basicAllocator,
2903 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2904// }}} END GENERATED CODE
2905#endif
2906
2907/// Return a `shared_ptr` object referring to and managing a new
2908/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2909/// specified `basicAllocator` will be used to supply a single contiguous
2910/// region of memory holding the returned shared pointer's internal
2911/// representation and the new `ARRAY_TYPE` object, and each element in the
2912/// array is default constructed. If `basicAllocator` is 0, then the
2913/// default allocator will be used instead.
2914template<class ARRAY_TYPE, class ALLOC>
2915typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
2916 shared_ptr<ARRAY_TYPE> >::type
2917allocate_shared(ALLOC *basicAllocator);
2918
2919/// Return a `shared_ptr` object referring to and managing a new
2920/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2921/// specified `basicAllocator` will be used to supply a single contiguous
2922/// region of memory holding the returned shared pointer's internal
2923/// representation and the new `ARRAY_TYPE` object, and each element in the
2924/// array is constructed from the specified `value`. If `basicAllocator`
2925/// is 0, then the default allocator will be used instead.
2926template<class ARRAY_TYPE, class ALLOC>
2927typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
2928 shared_ptr<ARRAY_TYPE> >::type
2930 ALLOC *basicAllocator,
2931 const typename remove_extent<ARRAY_TYPE>::type& value);
2932
2933/// Return a `shared_ptr` object referring to and managing a new
2934/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2935/// specified `basicAllocator` will be used to supply a single contiguous
2936/// region of memory holding the returned shared pointer's internal
2937/// representation and the new `ARRAY_TYPE` containing the specified
2938/// `numElements` number of elements, and each element in the array is
2939/// default constructed. If `basicAllocator` is 0, then the default
2940/// allocator will be used instead.
2941template<class ARRAY_TYPE, class ALLOC>
2942typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
2943 shared_ptr<ARRAY_TYPE> >::type
2944allocate_shared(ALLOC *basicAllocator, size_t numElements);
2945
2946/// Return a `shared_ptr` object referring to and managing a new
2947/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2948/// specified `basicAllocator` will be used to supply a single contiguous
2949/// region of memory holding the returned shared pointer's internal
2950/// representation and the new `ARRAY_TYPE` containing the specified
2951/// `numElements` number of elements, and each element in the array is
2952/// constructed from the specified `value`. If `basicAllocator` is 0, then
2953/// the default allocator will be used instead.
2954template<class ARRAY_TYPE, class ALLOC>
2955typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
2956 shared_ptr<ARRAY_TYPE> >::type
2958 ALLOC *basicAllocator,
2959 size_t numElements,
2960 const typename remove_extent<ARRAY_TYPE>::type& value);
2961
2962 // ===========================================
2963 // allocate_shared_for_overwrite(ALLOC *, ...)
2964 // ===========================================
2965
2966/// Return a `shared_ptr` object referring to and managing a new
2967/// `ELEMENT_TYPE` object. The specified `basicAllocator` will be used to
2968/// supply a single contiguous region of memory holding the returned shared
2969/// pointer's internal representation and the new `ELEMENT_TYPE` object,
2970/// which is default-constructed. If `basicAllocator` is 0, then the
2971/// default allocator will be used instead.
2972template<class ELEMENT_TYPE, class ALLOC>
2973typename enable_if<!is_array<ELEMENT_TYPE>::value,
2974 shared_ptr<ELEMENT_TYPE> >::type
2975allocate_shared_for_overwrite(ALLOC *basicAllocator);
2976
2977/// Return a `shared_ptr` object referring to and managing a new
2978/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The
2979/// specified `basicAllocator` will be used to supply a single contiguous
2980/// region of memory holding the returned shared pointer's internal
2981/// representation and the new `ARRAY_TYPE` object, and the array is
2982/// default-constructed. If `basicAllocator` is 0, then the default
2983/// allocator will be used instead.
2984template<class ARRAY_TYPE, class ALLOC>
2985typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
2986 shared_ptr<ARRAY_TYPE> >::type
2987allocate_shared_for_overwrite(ALLOC *basicAllocator);
2988
2989/// Return a `shared_ptr` object referring to and managing a new
2990/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a unbounded array. The
2991/// specified `basicAllocator` will be used to supply a single contiguous
2992/// region of memory holding the returned shared pointer's internal
2993/// representation and the new `ARRAY_TYPE` containing the specified
2994/// `numElements` number of elements, and the array is default-constructed.
2995/// If `basicAllocator` is 0, then the default allocator will be used
2996/// instead.
2997template<class ARRAY_TYPE, class ALLOC>
2998typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
2999 shared_ptr<ARRAY_TYPE> >::type
3000allocate_shared_for_overwrite(ALLOC *basicAllocator, size_t numElements);
3001
3002 // ================
3003 // make_shared(...)
3004 // ================
3005
3006#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3007// {{{ BEGIN GENERATED CODE
3008// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
3009#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
3010#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
3011#endif
3012#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D
3013#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D BSLSTL_SHAREDPTR_VARIADIC_LIMIT
3014#endif
3015
3016#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 0
3017template<class ELEMENT_TYPE>
3020make_shared();
3021#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 0
3022
3023#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 1
3024template<class ELEMENT_TYPE, class ARGS_01>
3028#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 1
3029
3030#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 2
3031template<class ELEMENT_TYPE, class ARGS_01,
3032 class ARGS_02>
3036 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
3037#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 2
3038
3039#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 3
3040template<class ELEMENT_TYPE, class ARGS_01,
3041 class ARGS_02,
3042 class ARGS_03>
3046 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3047 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
3048#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 3
3049
3050#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 4
3051template<class ELEMENT_TYPE, class ARGS_01,
3052 class ARGS_02,
3053 class ARGS_03,
3054 class ARGS_04>
3058 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3059 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3060 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
3061#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 4
3062
3063#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 5
3064template<class ELEMENT_TYPE, class ARGS_01,
3065 class ARGS_02,
3066 class ARGS_03,
3067 class ARGS_04,
3068 class ARGS_05>
3072 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3073 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3074 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3075 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
3076#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 5
3077
3078#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 6
3079template<class ELEMENT_TYPE, class ARGS_01,
3080 class ARGS_02,
3081 class ARGS_03,
3082 class ARGS_04,
3083 class ARGS_05,
3084 class ARGS_06>
3088 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3089 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3090 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3091 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3092 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
3093#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 6
3094
3095#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 7
3096template<class ELEMENT_TYPE, class ARGS_01,
3097 class ARGS_02,
3098 class ARGS_03,
3099 class ARGS_04,
3100 class ARGS_05,
3101 class ARGS_06,
3102 class ARGS_07>
3106 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3107 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3108 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3109 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3110 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3111 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
3112#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 7
3113
3114#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 8
3115template<class ELEMENT_TYPE, class ARGS_01,
3116 class ARGS_02,
3117 class ARGS_03,
3118 class ARGS_04,
3119 class ARGS_05,
3120 class ARGS_06,
3121 class ARGS_07,
3122 class ARGS_08>
3126 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3127 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3128 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3129 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3130 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3131 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3132 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
3133#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 8
3134
3135#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 9
3136template<class ELEMENT_TYPE, class ARGS_01,
3137 class ARGS_02,
3138 class ARGS_03,
3139 class ARGS_04,
3140 class ARGS_05,
3141 class ARGS_06,
3142 class ARGS_07,
3143 class ARGS_08,
3144 class ARGS_09>
3148 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3149 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3150 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3151 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3152 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3153 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3154 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
3156#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 9
3157
3158#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 10
3159template<class ELEMENT_TYPE, class ARGS_01,
3160 class ARGS_02,
3161 class ARGS_03,
3162 class ARGS_04,
3163 class ARGS_05,
3164 class ARGS_06,
3165 class ARGS_07,
3166 class ARGS_08,
3167 class ARGS_09,
3168 class ARGS_10>
3172 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3173 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3174 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3175 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3176 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3177 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3178 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3179 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3180 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
3181#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 10
3182
3183#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 11
3184template<class ELEMENT_TYPE, class ARGS_01,
3185 class ARGS_02,
3186 class ARGS_03,
3187 class ARGS_04,
3188 class ARGS_05,
3189 class ARGS_06,
3190 class ARGS_07,
3191 class ARGS_08,
3192 class ARGS_09,
3193 class ARGS_10,
3194 class ARGS_11>
3198 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3199 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3200 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3201 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3202 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3203 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3204 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3205 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3206 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
3207 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11);
3208#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 11
3209
3210#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 12
3211template<class ELEMENT_TYPE, class ARGS_01,
3212 class ARGS_02,
3213 class ARGS_03,
3214 class ARGS_04,
3215 class ARGS_05,
3216 class ARGS_06,
3217 class ARGS_07,
3218 class ARGS_08,
3219 class ARGS_09,
3220 class ARGS_10,
3221 class ARGS_11,
3222 class ARGS_12>
3226 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3227 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3228 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3229 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3230 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3231 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3232 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3233 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3234 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
3235 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
3236 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12);
3237#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 12
3238
3239#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 13
3240template<class ELEMENT_TYPE, class ARGS_01,
3241 class ARGS_02,
3242 class ARGS_03,
3243 class ARGS_04,
3244 class ARGS_05,
3245 class ARGS_06,
3246 class ARGS_07,
3247 class ARGS_08,
3248 class ARGS_09,
3249 class ARGS_10,
3250 class ARGS_11,
3251 class ARGS_12,
3252 class ARGS_13>
3256 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3257 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3258 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3259 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3260 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3261 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3262 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3263 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3264 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
3265 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
3266 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
3267 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13);
3268#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 13
3269
3270#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 14
3271template<class ELEMENT_TYPE, class ARGS_01,
3272 class ARGS_02,
3273 class ARGS_03,
3274 class ARGS_04,
3275 class ARGS_05,
3276 class ARGS_06,
3277 class ARGS_07,
3278 class ARGS_08,
3279 class ARGS_09,
3280 class ARGS_10,
3281 class ARGS_11,
3282 class ARGS_12,
3283 class ARGS_13,
3284 class ARGS_14>
3288 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3289 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3290 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3291 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3292 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3293 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3294 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3295 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3296 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
3297 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
3298 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
3299 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
3300 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14);
3301#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_D >= 14
3302
3303#else
3304// The generated code below is a workaround for the absence of perfect
3305// forwarding in some compilers.
3306
3307template<class ELEMENT_TYPE, class... ARGS>
3311// }}} END GENERATED CODE
3312#endif
3313
3314/// Return a `shared_ptr` object referring to and managing a new
3315/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The default
3316/// allocator will be used to supply a single contiguous region of memory
3317/// holding the returned shared pointer's internal representation and the
3318/// new `ARRAY_TYPE` object, and each element in the array is default
3319/// constructed.
3320template<class ARRAY_TYPE>
3321typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
3322 shared_ptr<ARRAY_TYPE> >::type
3323make_shared();
3324
3325/// Return a `shared_ptr` object referring to and managing a new
3326/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The default
3327/// allocator will be used to supply a single contiguous region of memory
3328/// holding the returned shared pointer's internal representation and the
3329/// new `ARRAY_TYPE` object, and each element in the array is constructed
3330/// from the specified `value`.
3331template<class ARRAY_TYPE>
3332typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
3333 shared_ptr<ARRAY_TYPE> >::type
3334make_shared(const typename remove_extent<ARRAY_TYPE>::type& value);
3335
3336// unbounded array overloads
3337
3338/// Return a `shared_ptr` object referring to and managing a new `ARRAY_TYPE`
3339/// object, where `ARRAY_TYPE` is a unbounded array. The default allocator
3340/// will be used to supply a single contiguous region of memory holding the
3341/// returned shared pointer's internal representation and the new `ARRAY_TYPE`
3342/// containing the specified `numElements` number of elements, and each element
3343/// in the array is default constructed.
3344template<class ARRAY_TYPE>
3345typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
3346 shared_ptr<ARRAY_TYPE> >::type
3347make_shared(size_t numElements);
3348
3349/// Return a `shared_ptr` object referring to and managing a new `ARRAY_TYPE`
3350/// object, where `ARRAY_TYPE` is a unbounded array. The default allocator
3351/// will be used to supply a single contiguous region of memory holding the
3352/// returned shared pointer's internal representation and the new `ARRAY_TYPE`
3353/// containing the specified `numElements` number of elements, and each element
3354/// in the array is constructed from the specified `value`.
3355template<class ARRAY_TYPE>
3356typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
3357 shared_ptr<ARRAY_TYPE> >::type
3358make_shared(size_t numElements,
3359 const typename remove_extent<ARRAY_TYPE>::type& value);
3360
3361 // ==============================
3362 // make_shared_for_overwrite(...)
3363 // ==============================
3364
3365/// Return a `shared_ptr` object referring to and managing a new
3366/// `ELEMENT_TYPE` object. The default allocator will be used to supply a
3367/// single contiguous region of memory holding the returned shared pointer's
3368/// internal representation and the new `ELEMENT_TYPE` object, which is
3369/// default-constructed.
3370template<class ELEMENT_TYPE>
3371typename enable_if<!is_array<ELEMENT_TYPE>::value,
3372 shared_ptr<ELEMENT_TYPE> >::type
3374
3375/// Return a `shared_ptr` object referring to and managing a new
3376/// `ARRAY_TYPE` object, where `ARRAY_TYPE` is a bounded array. The default
3377/// allocator will be used to supply a single contiguous region of memory
3378/// holding the returned shared pointer's internal representation and the
3379/// new `ARRAY_TYPE` object, and the array is default-constructed.
3380template<class ARRAY_TYPE>
3381typename enable_if<is_bounded_array<ARRAY_TYPE>::value,
3382 shared_ptr<ARRAY_TYPE> >::type
3384
3385/// Return a `shared_ptr` object referring to and managing a new `ARRAY_TYPE`
3386/// object, where `ARRAY_TYPE` is a unbounded array. The default allocator
3387/// will be used to supply a single contiguous region of memory holding the
3388/// returned shared pointer's internal representation and the new `ARRAY_TYPE`
3389/// containing the specified `numElements` number of elements, and the array is
3390/// default-constructed.
3391template<class ARRAY_TYPE>
3392typename enable_if<is_unbounded_array<ARRAY_TYPE>::value,
3393 shared_ptr<ARRAY_TYPE> >::type
3394make_shared_for_overwrite(size_t numElements);
3395
3396 // ==============
3397 // class weak_ptr
3398 // ==============
3399
3400/// This `class` provides a mechanism to create weak references to
3401/// reference-counted shared (`shared_ptr`) objects. A weak reference
3402/// provides conditional access to a shared object managed by a
3403/// `shared_ptr`, but, unlike a shared (or "strong") reference, does not
3404/// affect the shared object's lifetime.
3405///
3406/// See @ref bslstl_sharedptr_cpp03
3407template <class ELEMENT_TYPE>
3408class weak_ptr {
3409
3410 // DATA
3411 ELEMENT_TYPE *d_ptr_p; // pointer to the referenced
3412 // object
3413
3414 BloombergLP::bslma::SharedPtrRep *d_rep_p; // pointer to the representation
3415 // object that manages the
3416 // shared object (held, not
3417 // owned)
3418
3419 // PRIVATE MANIPULATORS
3420
3421 /// Release weak ownership of the currently managed shared pointer rep
3422 /// and assign to this weak pointer weak ownership of the specified
3423 /// shared pointer `rep`, aliasing the specified `target` pointer.
3424 void privateAssign(BloombergLP::bslma::SharedPtrRep *rep,
3425 ELEMENT_TYPE *target);
3426
3427 // FRIENDS
3428
3429 /// This `friend` declaration provides access to the internal data
3430 /// members while constructing a weak pointer from a weak pointer of a
3431 /// different type.
3432 template <class COMPATIBLE_TYPE>
3433 friend class weak_ptr;
3434
3436
3437 public:
3438 // TRAITS
3439 BSLMF_NESTED_TRAIT_DECLARATION(weak_ptr<ELEMENT_TYPE>,
3441
3442 // TYPES
3443
3444 /// For weak pointers to non-array types, @ref element_type is an alias to
3445 /// the `ELEMENT_TYPE` template parameter. Otherwise, it is an alias to
3446 /// the type contained in the array.
3448
3449 // CREATORS
3450
3451 /// Create a weak pointer in the empty state and referring to no object,
3452 /// i.e., a weak pointer having no representation.
3455
3456 /// Create a weak pointer that refers to the same object (if any) as the
3457 /// specified `original` weak pointer, and reset `original` to an empty
3458 /// state.
3459 weak_ptr(BloombergLP::bslmf::MovableRef<weak_ptr> original)
3461
3462 /// Create a weak pointer that refers to the same object (if any) as the
3463 /// specified `other` weak pointer, and reset `original` to an empty state.
3464 ///
3465 /// \note Note that this operation does not involve any change to
3466 /// reference counts.
3467#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3468 template <class COMPATIBLE_TYPE
3470 weak_ptr(weak_ptr<COMPATIBLE_TYPE>&& other) BSLS_KEYWORD_NOEXCEPT;
3471#else
3472 template <class COMPATIBLE_TYPE
3474 weak_ptr(BloombergLP::bslmf::MovableRef<weak_ptr<COMPATIBLE_TYPE> > other)
3476#endif
3477
3478 /// Create a weak pointer that refers to the same object (if any) as the
3479 /// specified `original` weak pointer, and increment the number of weak
3480 /// references to the object managed by `original` (if any).
3481 ///
3482 /// \note Note that if `original` is in the empty state, this weak pointer will be
3483 /// initialized to the empty state.
3484 weak_ptr(const weak_ptr& original) BSLS_KEYWORD_NOEXCEPT;
3485
3486 /// Create a weak pointer that refers to the same object (if any) as the
3487 /// specified `other` (shared or weak) pointer of the (template
3488 /// parameter) `COMPATIBLE_TYPE`, and increment the number of weak
3489 /// references to the object managed by `other` (if any). If
3490 /// `COMPATIBLE_TYPE *` is not implicitly convertible to
3491 /// `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted.
3492 ///
3493 /// \note Note that if `other` is in the empty state, this weak pointer will be
3494 /// initialized to the empty state.
3495 template <class COMPATIBLE_TYPE
3497 weak_ptr(const shared_ptr<COMPATIBLE_TYPE>& other) BSLS_KEYWORD_NOEXCEPT;
3498 // IMPLICIT
3499 template <class COMPATIBLE_TYPE
3501 weak_ptr(const weak_ptr<COMPATIBLE_TYPE>& other) BSLS_KEYWORD_NOEXCEPT;
3502 // IMPLICIT
3503
3504 /// Destroy this weak pointer object. If this weak pointer manages a
3505 /// (possibly shared) object, release the weak reference to that object.
3506 ~weak_ptr();
3507
3508 // MANIPULATORS
3509
3510 /// Make this weak pointer refer to the same object (if any) as the
3511 /// specified `rhs` weak pointer. If `rhs` is not a reference to this
3512 /// weak pointer, decrement the number of weak references to the object
3513 /// this weak pointer managed (if any), and reset `rhs` to an empty
3514 /// state. Return a reference providing modifiable access to this weak pointer.
3515 ///
3516 /// \note Note that if `rhs` is in an empty state, this weak pointer
3517 /// will be set to an empty state.
3518 weak_ptr& operator=(BloombergLP::bslmf::MovableRef<weak_ptr> rhs)
3520
3521 /// Make this weak pointer refer to the same object (if any) as the
3522 /// specified `rhs` weak pointer. Decrement the number of weak
3523 /// references to the object this weak pointer manages (if any), and
3524 /// increment the number of weak references to the object managed by
3525 /// `rhs` (if any). Return a reference providing modifiable access to this weak pointer.
3526 ///
3527 /// \note Note that if `rhs` is in an empty state, this
3528 /// weak pointer will be set to an empty state.
3530
3531 /// Make this weak pointer refer to the same object (if any) as the
3532 /// specified `rhs` weak pointer. Decrement the number of weak
3533 /// references to the object this weak pointer managed (if any), and
3534 /// reset `rhs` to an empty state. Return a reference providing
3535 /// modifiable access to this weak pointer. This function does not
3536 /// exist unless a pointer to (the template parameter) `COMPATIBLE_TYPE`
3537 /// is convertible to a pointer to (the template parameter) `ELEMENT_TYPE`.
3538 ///
3539 /// \note Note that if `rhs` is in an empty state, this weak
3540 /// pointer will be set to an empty state.
3541#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
3542 template <class COMPATIBLE_TYPE>
3543 typename enable_if<
3544 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value, weak_ptr&>::type
3545 operator=(weak_ptr<COMPATIBLE_TYPE>&& rhs) BSLS_KEYWORD_NOEXCEPT;
3546#else
3547 template <class COMPATIBLE_TYPE>
3548 typename enable_if<
3549 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value, weak_ptr&>::type
3550 operator=(BloombergLP::bslmf::MovableRef<weak_ptr<COMPATIBLE_TYPE> > rhs)
3552#endif
3553
3554 template <class COMPATIBLE_TYPE>
3555 typename enable_if<
3556 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value, weak_ptr&>::type
3557 operator=(const shared_ptr<COMPATIBLE_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
3558
3559 /// Make this weak pointer refer to the same object (if any) as the
3560 /// specified `rhs` (shared or weak) pointer to the (template parameter)
3561 /// `COMPATIBLE_TYPE`. Decrement the number of weak references to the
3562 /// object to which this weak pointer currently manages (if any), and
3563 /// increment the number of weak references to the object managed by
3564 /// `rhs` (if any). Return a reference providing modifiable access to
3565 /// this weak pointer. If `COMPATIBLE_TYPE *` is not implicitly
3566 /// convertible to `TYPE *`, then a compiler diagnostic will be emitted.
3567 ///
3568 /// \note Note that if `rhs` is in the empty state, this weak pointer will be
3569 /// set to the empty state.
3570 template <class COMPATIBLE_TYPE>
3571 typename enable_if<
3572 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value, weak_ptr&>::type
3573 operator=(const weak_ptr<COMPATIBLE_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT;
3574
3575 /// Reset this weak pointer to the empty state. If this weak pointer
3576 /// manages a (possibly shared) object, then decrement the number of
3577 /// weak references to that object.
3579
3580 /// Efficiently exchange the states of this weak pointer and the
3581 /// specified `other` weak pointer such that each will refer to the
3582 /// object (if any) and representation (if any) formerly referred to and
3583 /// managed by the other.
3584 void swap(weak_ptr& other) BSLS_KEYWORD_NOEXCEPT;
3585
3586 // ACCESSORS
3587
3588 /// Return `true` if this weak pointer is in the empty state or the
3589 /// object that it originally referenced has been destroyed, and `false`
3590 /// otherwise.
3591 bool expired() const BSLS_KEYWORD_NOEXCEPT;
3592
3593 /// Return a shared pointer to the object referred to by this weak
3594 /// pointer if `false == expired()`, and a shared pointer in the empty
3595 /// state otherwise.
3596 shared_ptr<ELEMENT_TYPE> lock() const BSLS_KEYWORD_NOEXCEPT;
3597
3598 template <class ANY_TYPE>
3599 bool owner_before(const shared_ptr<ANY_TYPE>& other) const
3601
3602 /// Return `true` if the address of the
3603 /// `BloombergLP::bslma::SharedPtrRep` object used by this weak pointer
3604 /// is ordered before the address of the
3605 /// `BloombergLP::bslma::SharedPtrRep` object used by the specified
3606 /// `other` shared pointer under the total ordering defined by
3607 /// `std::less<BloombergLP::bslma::SharedPtrRep *>`, and `false`
3608 /// otherwise.
3609 template <class ANY_TYPE>
3610 bool owner_before(const weak_ptr<ANY_TYPE>& other) const
3612
3613 template<class ANY_TYPE>
3614 bool owner_equal(const shared_ptr<ANY_TYPE>& other) const
3616
3617 /// Return `true` if the address of the
3618 /// `BloombergLP::bslma::SharedPtrRep` object used by this shared
3619 /// pointer is equal to the address of the
3620 /// `BloombergLP::bslma::SharedPtrRep` object used by the specified
3621 /// `other` shared pointer, and `false` otherwise.
3622 template<class ANY_TYPE>
3623 bool owner_equal(const weak_ptr<ANY_TYPE>& other) const
3625
3626 /// Return an unspecified value such that, for any object `x` where
3627 /// `owner_equal(x)` is true, `owner_hash() == x.owner_hash()` is true.
3628 ///
3629 /// \note Note that this is based on the hash of the address of the
3630 /// `BloombergLP::bslma::SharedPtrRep` object used by this object.
3631 /// Note also that for two empty smart pointers `x` and `y`,
3632 /// `x.owner_hash() == y.owner_hash()` is true.
3633 size_t owner_hash() const BSLS_KEYWORD_NOEXCEPT;
3634
3635 /// Return the address providing modifiable access to the
3636 /// `BloombergLP::bslma::SharedPtrRep` object held by this weak pointer,
3637 /// or 0 if this weak pointer is in the empty state.
3638 BloombergLP::bslma::SharedPtrRep *rep() const BSLS_KEYWORD_NOEXCEPT;
3639
3640 /// Return a "snapshot" of the current number of shared pointers that
3641 /// share ownership of the object referred to by this weak pointer, or 0 if this weak pointer is in the empty state.
3642 ///
3643 /// \note Note that any result
3644 /// other than 0 may be unreliable in a multi-threaded program, where
3645 /// another pointer sharing ownership in a different thread may be
3646 /// copied or destroyed, or another weak pointer may be locked in the
3647 /// case that 1 is returned (that would otherwise indicate unique
3648 /// ownership).
3649 long use_count() const BSLS_KEYWORD_NOEXCEPT;
3650
3651#ifndef BDE_OMIT_INTERNAL_DEPRECATED
3652 // DEPRECATED BDE LEGACY ACCESSORS
3653
3654 /// Return a shared pointer to the object referred to by this weak
3655 /// pointer and managing the same object as that managed by this weak
3656 /// pointer (if any) if `false == expired()`, and a shared pointer in the empty state otherwise.
3657 ///
3658 /// \note Note that the behavior of this method is
3659 /// the same as that of `lock`.
3660 shared_ptr<ELEMENT_TYPE> acquireSharedPtr() const BSLS_KEYWORD_NOEXCEPT;
3661
3662 /// Return a "snapshot" of the current number of shared pointers that
3663 /// share ownership of the object referred to by this weak pointer, or 0 if this weak pointer is in the empty state.
3664 ///
3665 /// \note Note that the behavior
3666 /// of this method is the same as that of @ref use_count , and the result
3667 /// may be unreliable in multi-threaded code for the same reasons.
3668 ///
3669 /// @deprecated Use @ref use_count instead.
3671#endif // BDE_OMIT_INTERNAL_DEPRECATED
3672};
3673
3674#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
3675// CLASS TEMPLATE DEDUCTION GUIDES
3676
3677/// Deduce the specified type `ELEMENT_TYPE` corresponding template
3678/// parameter of the `bsl::shared_ptr` supplied to the constructor of
3679/// `weak_ptr`.
3680template<class ELEMENT_TYPE>
3681weak_ptr(shared_ptr<ELEMENT_TYPE>) -> weak_ptr<ELEMENT_TYPE>;
3682#endif
3683
3684 //==============================
3685 // class enable_shared_from_this
3686 //==============================
3687
3688/// This class allows an object that is currently managed by a `shared_ptr`
3689/// to safely generate a copy of the managing `shared_ptr` object.
3690/// Inheriting from `enable_shared_from_this<ELEMENT_TYPE>` provides the
3691/// (template parameter) `ELEMENT_TYPE` type with a member function
3692/// @ref shared_from_this . If an object of type `ELEMENT_TYPE` is managed by a
3693/// `shared_ptr` then calling @ref shared_from_this will return a
3694/// `shared_ptr<ELEMENT_TYPE>` that shares ownership of that object. It is
3695/// undefined behavior to call @ref shared_from_this on an object unless that
3696/// object is managed by a `shared_ptr`.
3697///
3698/// The intended use of @ref enable_shared_from_this is that the (template
3699/// parameter) type `ELEMENT_TYPE` inherits directly from the
3700/// @ref enable_shared_from_this class template. In the case of multiple
3701/// inheritance, only one of the base classes should inherit from the
3702/// @ref enable_shared_from_this class template. If multiple base classes
3703/// inherit from @ref enable_shared_from_this , then there will be ambiguous
3704/// calls to the @ref shared_from_this function.
3705///
3706/// See @ref bslstl_sharedptr_cpp03
3707template<class ELEMENT_TYPE>
3708class enable_shared_from_this {
3709
3710 // FRIENDS
3711
3712 /// Allows `shared_ptr` to initialize `d_weakThis` when it detects an
3713 /// @ref enable_shared_from_this base class.
3715
3716 private:
3717 // DATA
3718 mutable bsl::weak_ptr<ELEMENT_TYPE> d_weakThis;
3719
3720 protected:
3721 // PROTECTED CREATORS
3722
3723 /// Create an @ref enable_shared_from_this object that is not owned by any
3724 /// `shared_ptr` object.
3726
3727 /// Create an @ref enable_shared_from_this object that is not owned by any `shared_ptr` object.
3728 ///
3729 /// \note Note that the specified `unused` argument is
3730 /// not used by this constructor.
3733
3734 /// Destroy this @ref enable_shared_form_this .
3736
3737 // PROTECTED MANIPULATORS
3738
3739 /// Return `*this`. This object is unchanged.
3740 /// \note Note that the specified
3741 /// `rhs` is not used.
3744
3745 public:
3746 // MANIPULATORS
3747
3748 /// Return a `shared_ptr<ELEMENT_TYPE>` that shares ownership with an
3749 /// existing `shared_ptr` object that managed this object, and throw a
3750 /// `std::bad_weak_ptr` exception if there is no `shared_ptr` currently
3751 /// managing this object. If multiple groups of `shared_ptr`s are
3752 /// managing this object, the returned `shared_ptr` will share ownership
3753 /// with the group that first managed this object.
3754 bsl::shared_ptr<ELEMENT_TYPE> shared_from_this();
3755
3756 /// Return a `weak_ptr` holding a weak reference to this managed object
3757 /// if this object is currently managed by `shared_ptr`, and return an
3758 /// expired `weak_ptr` otherwise. If multiple groups of `shared_ptr`s
3759 /// are managing this object, the returned `weak_ptr` will hold a weak
3760 /// reference to the group that first managed this object.
3761 bsl::weak_ptr<ELEMENT_TYPE> weak_from_this() BSLS_KEYWORD_NOEXCEPT;
3762
3763 // ACCESSORS
3764
3765 /// Return a `shared_ptr<const ELEMENT_TYPE>` that shares ownership with
3766 /// an existing `shared_ptr` object that managed this object, and throw
3767 /// a `std::bad_weak_ptr` exception if there is no `shared_ptr`
3768 /// currently managing this object. If multiple groups of `shared_ptr`s
3769 /// are managing this object, the returned `shared_ptr` will share
3770 /// ownership with the group that first managed this object.
3771 bsl::shared_ptr<const ELEMENT_TYPE> shared_from_this() const;
3772
3773
3774 /// Return a `weak_ptr` holding a weak reference (with only `const`
3775 /// access) to this managed object if this object is currently managed
3776 /// by `shared_ptr`, and return an expired `weak_ptr` otherwise. If
3777 /// multiple groups of `shared_ptr`s are managing this object, the
3778 /// returned `weak_ptr` will hold a weak reference to the group that
3779 /// first managed this object.
3780 bsl::weak_ptr<const ELEMENT_TYPE> weak_from_this() const
3782};
3783
3784// ASPECTS
3785
3786/// Efficiently exchange the states of the specified `a` and `b` weak
3787/// pointers such that each will refer to the object (if any) and
3788/// representation formerly referred to by the other.
3789template <class ELEMENT_TYPE>
3790void swap(weak_ptr<ELEMENT_TYPE>& a, weak_ptr<ELEMENT_TYPE>& b)
3792
3793 // =========================
3794 // class hash specialization
3795 // =========================
3796
3797// A partial specialization of 'bsl::hash' is no longer necessary, as the
3798// primary template has the correct behavior once 'hashAppend' is defined.
3799
3800} // close namespace bsl
3801
3802
3803namespace bslstl {
3804
3805 // ====================
3806 // struct SharedPtrUtil
3807 // ====================
3808
3809/// This `struct` provides a namespace for operations on shared pointers.
3810///
3811/// See @ref bslstl_sharedptr_cpp03
3812struct SharedPtrUtil {
3813
3814 // CLASS METHODS
3815
3816 /// Return a shared pointer with an in-place representation holding a
3817 /// newly-created uninitialized buffer of the specified `bufferSize` (in
3818 /// bytes). Optionally specify a `basicAllocator` used to supply
3819 /// memory. If `basicAllocator` is 0, the currently installed default allocator is used.
3820 ///
3821 /// \pre The behavior is undefined unless
3822 /// `0 < bufferSize`.
3823 static
3825 createInplaceUninitializedBuffer(size_t bufferSize,
3826 bslma::Allocator *basicAllocator = 0);
3827
3828 // CASTING FUNCTIONS
3829
3830 /// Load into the specified `target` an aliased shared pointer sharing
3831 /// ownership of the object managed by the specified `source` shared
3832 /// pointer and referring to `const_cast<TARGET *>(source.get())`. If
3833 /// `*target` is already managing a (possibly shared) object, then
3834 /// release the shared reference to that object, and destroy it using
3835 /// its associated deleter if that shared pointer held the last shared reference to that object.
3836 ///
3837 /// \note Note that a compiler diagnostic will be
3838 /// emitted indicating an error unless
3839 /// `const_cast<TARGET *>(source.get())` is a valid expression.
3840 template <class TARGET, class SOURCE>
3841 static
3842 void constCast(bsl::shared_ptr<TARGET> *target,
3843 const bsl::shared_ptr<SOURCE>& source);
3844
3845 /// Return a `bsl::shared_ptr<TARGET>` object sharing ownership of the
3846 /// same object as the specified `source` shared pointer to the
3847 /// (template parameter) `SOURCE` type, and referring to `const_cast<TARGET *>(source.get())`.
3848 ///
3849 /// \note Note that a compiler
3850 /// diagnostic will be emitted indicating an error unless
3851 /// `const_cast<TARGET *>(source.get())` is a valid expression.
3852 template <class TARGET, class SOURCE>
3853 static
3854 bsl::shared_ptr<TARGET> constCast(const bsl::shared_ptr<SOURCE>& source)
3856
3857 /// Load into the specified `target` an aliased shared pointer sharing
3858 /// ownership of the object managed by the specified `source` shared
3859 /// pointer and referring to `dynamic_cast<TARGET *>(source.get())`. If
3860 /// `*target` is already managing a (possibly shared) object, then
3861 /// release the shared reference to that object, and destroy it using
3862 /// its associated deleter if that shared pointer held the last shared
3863 /// reference to that object. If
3864 /// `0 == dynamic_cast<TARGET*>(source.get())`, then `*target` shall be
3865 /// reset to an empty state that does not refer to an object.
3866 ///
3867 /// \note Note that a compiler diagnostic will be emitted indicating an error unless
3868 /// `dynamic_cast<TARGET *>(source.get())` is a valid expression.
3869 template <class TARGET, class SOURCE>
3870 static
3871 void dynamicCast(bsl::shared_ptr<TARGET> *target,
3872 const bsl::shared_ptr<SOURCE>& source);
3873
3874 /// Return a `bsl::shared_ptr<TARGET>` object sharing ownership of the
3875 /// same object as the specified `source` shared pointer to the
3876 /// (template parameter) `SOURCE` type, and referring to
3877 /// `dynamic_cast<TARGET *>(source.get())`. If that would return a
3878 /// shared pointer referring to nothing (`0 == get()`), then instead return an (empty) default constructed shared pointer.
3879 ///
3880 /// \note Note that a
3881 /// compiler diagnostic will be emitted indicating an error unless
3882 /// `dynamic_cast<TARGET *>(source.get())` is a valid expression..
3883 template <class TARGET, class SOURCE>
3884 static
3885 bsl::shared_ptr<TARGET> dynamicCast(const bsl::shared_ptr<SOURCE>& source)
3887
3888 /// Load into the specified `target` an aliased shared pointer sharing
3889 /// ownership of the object managed by the specified `source` shared
3890 /// pointer and referring to `static_cast<TARGET *>(source.get())`. If
3891 /// `*target` is already managing a (possibly shared) object, then
3892 /// release the shared reference to that object, and destroy it using
3893 /// its associated deleter if that shared pointer held the last shared reference to that object.
3894 ///
3895 /// \note Note that a compiler diagnostic will be
3896 /// emitted indicating an error unless
3897 /// `static_cast<TARGET *>(source.get())` is a valid expression.
3898 template <class TARGET, class SOURCE>
3899 static
3900 void staticCast(bsl::shared_ptr<TARGET> *target,
3901 const bsl::shared_ptr<SOURCE>& source);
3902
3903 /// Return a `bsl::shared_ptr<TARGET>` object sharing ownership of the
3904 /// same object as the specified `source` shared pointer to the
3905 /// (template parameter) `SOURCE` type, and referring to `static_cast<TARGET *>(source.get())`.
3906 ///
3907 /// \note Note that a compiler
3908 /// diagnostic will be emitted indicating an error unless
3909 /// `static_cast<TARGET *>(source.get())` is a valid expression.
3910 template <class TARGET, class SOURCE>
3911 static
3912 bsl::shared_ptr<TARGET> staticCast(const bsl::shared_ptr<SOURCE>& source)
3914};
3915
3916 // ==========================
3917 // struct SharedPtrNilDeleter
3918 // ==========================
3919
3920/// This `struct` provides a function-like shared pointer deleter that does
3921/// nothing when invoked.
3922///
3923/// See @ref bslstl_sharedptr_cpp03
3924struct SharedPtrNilDeleter {
3925
3926 // ACCESSORS
3927
3928 /// No-Op.
3929 void operator()(const volatile void *) const BSLS_KEYWORD_NOEXCEPT;
3930};
3931
3932 // ===============================
3933 // struct SharedPtr_DefaultDeleter
3934 // ===============================
3935
3936/// This `struct` provides a function-like shared pointer deleter that
3937/// invokes `delete` with the passed pointer. If the template parameter is
3938/// `true`, then the pointer is deleted using `operator delete []`.
3939/// Otherwise, it is deleted using `operator delete`.
3940///
3941/// See @ref bslstl_sharedptr_cpp03
3942template <bool>
3943struct SharedPtr_DefaultDeleter {
3944
3945 // ACCESSORS
3946
3947 /// Call `delete` with the specified `ptr`.
3948 template <class ANY_TYPE>
3949 void operator()(ANY_TYPE *ptr) const BSLS_KEYWORD_NOEXCEPT;
3950};
3951
3952 //=========================
3953 // struct SharedPtr_ImpUtil
3954 //=========================
3955
3956/// This `struct` should be used by only `shared_ptr` constructors. Its
3957/// purpose is to enable `shared_ptr` constructors to determine if the
3958/// (template parameter) types `COMPATIBLE_TYPE` or `ELEMENT_TYPE` have a
3959/// specialization of @ref enable_shared_from_this as an unambiguous, publicly
3960/// accessible, base class.
3961///
3962/// See @ref bslstl_sharedptr_cpp03
3963struct SharedPtr_ImpUtil {
3964
3965 // PUBLIC TYPES
3966#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
3967 template <class TYPE, unsigned DIM = 0>
3968 struct Extent : std::extent<TYPE, DIM> {};
3969#else
3970 template <class TYPE, unsigned DIM = 0>
3971 struct Extent : public bsl::integral_constant<size_t, 0> {};
3972
3973 template <class TYPE>
3974 struct Extent<TYPE[], 0> : public bsl::integral_constant<size_t, 0> {};
3975
3976 template <class TYPE, unsigned DIM>
3977 struct Extent<TYPE[], DIM>
3978 : public bsl::integral_constant<size_t, Extent<TYPE, DIM-1>::value> {};
3979
3980 template <class TYPE, size_t SIZE>
3981 struct Extent<TYPE[SIZE], 0>
3982 : public bsl::integral_constant<size_t, SIZE> {};
3983
3984 template <class TYPE, size_t SIZE, unsigned DIM>
3985 struct Extent<TYPE[SIZE], DIM>
3986 : public bsl::integral_constant<size_t, Extent<TYPE, DIM-1>::value> {};
3987#endif
3988
3989 // CLASS METHODS
3990
3991 /// Load the specified `result` with the control block (i.e.,
3992 /// `SharedPtrRep`) from the specified `sharedPtr` if (and only if)
3993 /// `result` is not 0 and `result` does not already refer to a
3994 /// non-expired shared-pointer control block. If `result` is 0, or if
3995 /// `result->d_weakThis` has not expired, this operation has no effect.
3996 /// This operation is used to initialize data members from a type that
3997 /// inherits from @ref enable_shared_from_this when constructing an
3998 /// out-of-place shared pointer representation. This function shall be
3999 /// called only by `shared_ptr` constructors creating shared pointers
4000 /// for classes that derive publicly and unambiguously from a specialization of `enabled_shared_from_this`.
4001 ///
4002 /// \note Note that overload
4003 /// resolution will select the overload below if a supplied type does
4004 /// not derive from a specialization of @ref enable_shared_from_this .
4005 template<class SHARED_TYPE, class ENABLE_TYPE>
4006 static void loadEnableSharedFromThis(
4008 bsl::shared_ptr<SHARED_TYPE> *sharedPtr);
4009
4010 /// Do nothing. This overload is selected, rather than the immediately
4011 /// preceding template, when the `SHARED_TYPE` template type parameter
4012 /// of `shared_ptr<SHARED_TYPE>` does not derive from a specialization
4013 /// of @ref enable_shared_from_this .
4014 static void loadEnableSharedFromThis(const volatile void *, const void *)
4016
4017 /// Throw a `bsl::bad_weak_ptr` exception.
4018 static void throwBadWeakPtr();
4019};
4020
4021 // ==========================
4022 // class SharedPtr_RepProctor
4023 // ==========================
4024
4025/// This `class` implements a proctor that, unless its `release` method has
4026/// previously been invoked, automatically releases a reference held by the
4027/// `bslma::SharedPtrRep` object that is supplied at construction.
4028///
4029/// See @ref bslstl_sharedptr_cpp03
4030class SharedPtr_RepProctor {
4031
4032 private:
4033 // DATA
4034 bslma::SharedPtrRep *d_rep_p; // Address of representation being managed
4035
4036 private:
4037 // NOT IMPLEMENTED
4038 SharedPtr_RepProctor(const SharedPtr_RepProctor&);
4039 SharedPtr_RepProctor& operator=(const SharedPtr_RepProctor&);
4040
4041 public:
4042 // CREATORS
4043
4044 /// Create a `SharedPtr_RepProctor` that conditionally manages the
4045 /// specified `rep` (if non-zero).
4046 explicit SharedPtr_RepProctor(bslma::SharedPtrRep *rep)
4048
4049 /// Destroy this `SharedPtr_RepProctor`, and dispose of (deallocate) the
4050 /// `bslma::SharedPtrRep` it manages (if any). If no such object is currently being managed, this method has no effect.
4051 ///
4052 /// \note Note that the
4053 /// destructor of the `bslma::SharedPtrRep` will not be called as the
4054 /// reference count will not be decremented.
4055 ~SharedPtr_RepProctor();
4056
4057 // MANIPULATORS
4058
4059 /// Release from management the object currently managed by this
4060 /// proctor. If no object is currently being managed, this method has
4061 /// no effect.
4062 void release() BSLS_KEYWORD_NOEXCEPT;
4063};
4064
4065} // close package namespace
4066
4067
4068// ============================================================================
4069// INLINE DEFINITIONS
4070// ============================================================================
4071
4072#if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
4073
4074namespace bslstl {
4075
4076#if defined(BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE) && \
4077 defined(BSLS_PLATFORM_CMP_MSVC) && \
4078 BSLS_PLATFORM_CMP_VERSION >= 1936 && BSLS_PLATFORM_CMP_VERSION <= 1937
4079// Microsoft needs a workaround to correctly handle calling `sizeof` on an
4080// unevaluated expression. This compiler bug was introduced in Visual Studio
4081// 2022 version 17.6 (cl 19.36, released May 2022). The report to Microsoft is
4082// https://developercommunity.visualstudio.com/t/C-templates:-new-compiler-error-in-MSV/10381900
4083
4084# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) decltype(__VA_ARGS__)
4085#else
4086# define BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(...) (__VA_ARGS__)
4087#endif
4088
4089template <class FUNCTOR>
4090struct SharedPtr_TestIsCallable {
4091 private:
4092 // PRIVATE TYPES
4093 typedef BloombergLP::bslmf::Util Util;
4094
4095 struct TrueType {
4096 char d_padding;
4097 };
4098 struct FalseType {
4099 char d_padding[17];
4100 };
4101
4102 // The two structs `TrueType` and `FalseType` are guaranteed to have
4103 // distinct sizes, so that a `sizeof(expression)` query, where `expression`
4104 // returns one of these two types, will give different answers depending on
4105 // which type is returned.
4106
4107 public:
4108 // CLASS METHODS
4109
4110 /// This function is never defined. It provides a property-checker that
4111 /// an entity of (template parameter) type `FACTORY` can be called like
4112 /// a function with a single argument, which is a pointer to an object
4113 /// of (template parameter) type `ARG`. The `sizeof()` expression
4114 /// provides an unevaluated context to check the validity of the
4115 /// enclosed expression, and the `, 0` ensures that the `sizeof` check
4116 /// remains valid, even if the expression returns `void`. Similarly,
4117 /// the cast to `void` ensures that there are no surprises with types that overload the comma operator.
4118 ///
4119 /// \note Note that the cast to `void` is
4120 /// elided for Clang compilers using versions of LLVM prior to
4121 /// 12, which fail to evaluate the trait properly.
4122 ///
4123 /// \note Note that `sizeof(decltype())` is required for MSVC due to a compiler bug in
4124 /// MSVC 17.6 and later (at least including 17.7.0 Preview 2.0).
4125 template <class ARG>
4126 static FalseType test(...);
4127 template <class ARG>
4128 static TrueType
4129 test(typename bsl::enable_if<
4130 static_cast<bool>(
4131 sizeof(BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND(
4132 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4133 Util::declval<FUNCTOR>()(Util::declval<ARG>())),
4134 0)))>::type *);
4135};
4136
4137#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1920
4138// Microsoft needs a workaround to correctly handle calling through function
4139// pointers with incompatible types in Visual Studio 2017. In Visual Studio
4140// 2019 the workaround isn't needed and crashes the compiler if enabled!
4141// (Visual Studio versions prior to 2017 appear to not need the workaround,
4142// based on further testing, but it's being left in place so as not to alter
4143// this code for people using older compiler versions.)
4144
4145template <class RESULT, class PARAM>
4146struct SharedPtr_TestIsCallable<RESULT(PARAM)> {
4147 private:
4148 // PRIVATE TYPES
4149 typedef BloombergLP::bslmf::Util Util;
4150
4151 struct TrueType { char d_padding; };
4152 struct FalseType { char d_padding[17]; };
4153
4154 // PRIVATE CLASS METHODS
4155 static RESULT callMe(PARAM);
4156
4157 public:
4158 // CLASS METHODS
4159
4160 // This function is never defined. It provides a property-checker that
4161 // an entity of (template parameter) type `FACTORY` can be called like
4162 // a function with a single argument, which is a pointer to an object
4163 // of (template parameter) type `ARG`. The `sizeof` expression
4164 // provides an unevaluated context to check the validity of the
4165 // enclosed expression, and the `, 0` ensures that the `sizeof` check
4166 // remains valid, even if the expression returns `void`. Similarly,
4167 // the cast to `void` ensures that there are no surprises with types
4168 // that overload the comma operator.
4169 template <class ARG>
4170 static FalseType test(...);
4171 template <class ARG>
4172 static TrueType test(typename bsl::enable_if<(bool)sizeof(
4173 ((void)callMe(Util::declval<ARG>())), 0
4174 )>::type *);
4175};
4176
4177template <class RESULT, class PARAM>
4178struct SharedPtr_TestIsCallable<RESULT(*)(PARAM)>
4179 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4180};
4181
4182template <class RESULT, class PARAM>
4183struct SharedPtr_TestIsCallable<RESULT(&)(PARAM)>
4184 : SharedPtr_TestIsCallable<RESULT(PARAM)> {
4185};
4186
4187#if BSLS_PLATFORM_CMP_VERSION >= 1910
4188// MSVC 2017 expression-SFINAE has a regression that is failing in two
4189// additional cases:
4190// 1) for pointers to object types
4191// 2) where `0` is used for a null pointer literal, deducing as `int`.
4192// We resolve those issues with a couple more specializations below.
4193
4194template <class TYPE>
4195struct SharedPtr_TestIsCallable<TYPE *> {
4196 struct TrueType { char d_padding; };
4197 struct FalseType { char d_padding[17]; };
4198
4199 template <class ARG>
4200 static FalseType test(...);
4201};
4202
4203template <>
4204struct SharedPtr_TestIsCallable<int> {
4205 struct TrueType { char d_padding; };
4206 struct FalseType { char d_padding[17]; };
4207
4208 template <class ARG>
4209 static FalseType test(...);
4210};
4211#endif // MSVC 2017
4212
4213#endif // BSLS_PLATFORM_CMP_MSVC
4214
4215template <class FUNCTOR, class ARG>
4216struct SharedPtr_IsCallable {
4217 enum { k_VALUE =
4218 sizeof(SharedPtr_TestIsCallable<FUNCTOR>::template test<ARG>(0)) == 1
4219 };
4220};
4221
4222
4223struct SharedPtr_IsFactoryFor_Impl {
4224 private:
4225 // PRIVATE TYPES
4226 struct TrueType {
4227 char d_padding;
4228 };
4229 struct FalseType {
4230 char d_padding[17];
4231 };
4232
4233 public:
4234 // CLASS METHODS
4235
4236 /// This function is never defined. It provides a property-checker that
4237 /// an object of (template parameter) type `FACTORY` has a
4238 /// member-function called `deleteObject` that can be called with a
4239 /// single argument, which is a pointer to an object of (template
4240 /// parameter) type `ARG`. The `sizeof` expression provides an
4241 /// unevaluated context to check the validity of the enclosed
4242 /// expression, and the `, 0` ensures that the `sizeof` check remains
4243 /// valid, even if the expression returns `void`. Similarly, the cast
4244 /// to `void` ensures that there are no surprises with types that overload the comma operator.
4245 ///
4246 /// \note Note that the cast to `void` is elided
4247 /// for Clang compilers using versions of LLVM prior to 12, which fail
4248 /// to evaluate the trait properly.
4249 template <class FACTORY, class ARG>
4250 static FalseType test(...);
4251 template <class FACTORY, class ARG>
4252 static TrueType test(typename bsl::enable_if<static_cast<bool>(sizeof(
4253 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4254 (*(FACTORY *)0)->deleteObject((ARG *)0)),
4255 0))>::type *);
4256};
4257
4258template <class FACTORY, class ARG>
4259struct SharedPtr_IsFactoryFor {
4260 enum { k_VALUE =
4261 sizeof(SharedPtr_IsFactoryFor_Impl::test<FACTORY, ARG>(0)) == 1
4262 };
4263};
4264
4265
4266struct SharedPtr_IsNullableFactory_Impl {
4267 private:
4268 // PRIVATE TYPES
4269 struct TrueType {
4270 char d_padding;
4271 };
4272 struct FalseType {
4273 char d_padding[17];
4274 };
4275
4276 public:
4277 // CLASS METHODS
4278
4279 /// This function is never defined. It provides a property-checker that
4280 /// an object of (template parameter) type `FACTORY` has a
4281 /// member-function called `deleteObject` that can be called with a
4282 /// single argument, which is a pointer to an object of (template
4283 /// parameter) type `ARG`. The `sizeof` expression provides an
4284 /// unevaluated context to check the validity of the enclosed
4285 /// expression, and the `, 0` ensures that the `sizeof` check remains
4286 /// valid, even if the expression returns `void`. Similarly, the cast
4287 /// to `void` ensures that there are no surprises with types that overload the comma operator.
4288 ///
4289 /// \note Note that the cast to `void` is elided
4290 /// for Clang compilers using versions of LLVM prior to 12, which fail
4291 /// to evaluate the trait properly.
4292 template <class FACTORY>
4293 static FalseType test(...);
4294 template <class FACTORY>
4295 static TrueType test(typename bsl::enable_if<static_cast<bool>(sizeof(
4296 BSLSTL_SHAREDPTR_SFINAE_DISCARD(
4297 (*(FACTORY *)0)->deleteObject(nullptr)),
4298 0))>::type *);
4299};
4300
4301template <class FACTORY>
4302struct SharedPtr_IsNullableFactory {
4303 enum { k_VALUE =
4304 sizeof(SharedPtr_IsNullableFactory_Impl::test<FACTORY>(0)) == 1
4305 };
4306};
4307
4308
4309template <class SOURCE_TYPE, class DEST_TYPE>
4310struct SharedPtr_IsPointerConvertible_Impl
4311: bsl::is_convertible<SOURCE_TYPE *, DEST_TYPE *>::type {};
4312
4313template <class SOURCE_TYPE, class DEST_TYPE>
4314struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[]>
4315: bsl::is_convertible<SOURCE_TYPE (*)[], DEST_TYPE (*)[]>::type {};
4316
4317template <class SOURCE_TYPE, class DEST_TYPE, size_t DEST_SIZE>
4318struct SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE[DEST_SIZE]>
4319: bsl::is_convertible<SOURCE_TYPE (*)[DEST_SIZE],
4320 DEST_TYPE (*)[DEST_SIZE]>::type {};
4321
4322
4323template <class SOURCE_TYPE, class DEST_TYPE>
4324struct SharedPtr_IsPointerConvertible
4325: SharedPtr_IsPointerConvertible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4326
4327
4328template <class SOURCE_TYPE, class DEST_TYPE>
4329struct SharedPtr_IsPointerCompatible_Impl
4330 : bsl::is_convertible<SOURCE_TYPE *, DEST_TYPE *>::type {};
4331
4332template <class TYPE, size_t SIZE>
4333struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], TYPE[]>
4334 : bsl::true_type {};
4335
4336template <class TYPE, size_t SIZE>
4337struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const TYPE[]>
4338 : bsl::true_type {};
4339
4340template <class TYPE, size_t SIZE>
4341struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], volatile TYPE[]>
4342 : bsl::true_type {};
4343
4344template <class TYPE, size_t SIZE>
4345struct SharedPtr_IsPointerCompatible_Impl<TYPE[SIZE], const volatile TYPE[]>
4346 : bsl::true_type {};
4347
4348
4349template <class SOURCE_TYPE, class DEST_TYPE>
4350struct SharedPtr_IsPointerCompatible
4351: SharedPtr_IsPointerCompatible_Impl<SOURCE_TYPE, DEST_TYPE>::type {};
4352
4353} // close package namespace
4354
4355#endif // BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS
4356
4357
4358namespace bsl {
4359 //------------------------------
4360 // class enable_shared_from_this
4361 //------------------------------
4362// CREATORS
4363template<class ELEMENT_TYPE>
4364inline // constexpr
4365enable_shared_from_this<ELEMENT_TYPE>::enable_shared_from_this()
4367: d_weakThis()
4368{
4369}
4370
4371template<class ELEMENT_TYPE>
4372inline
4373enable_shared_from_this<ELEMENT_TYPE>::enable_shared_from_this(
4374 const enable_shared_from_this&)
4376: d_weakThis()
4377{
4378}
4379
4380template<class ELEMENT_TYPE>
4381inline
4382enable_shared_from_this<ELEMENT_TYPE>::~enable_shared_from_this()
4383{
4384}
4385
4386// MANIPULATORS
4387template<class ELEMENT_TYPE>
4388inline
4389enable_shared_from_this<ELEMENT_TYPE>&
4390enable_shared_from_this<ELEMENT_TYPE>::operator=(
4391 const enable_shared_from_this&)
4393{
4394 return *this;
4395}
4396
4397template<class ELEMENT_TYPE>
4398inline
4399shared_ptr<ELEMENT_TYPE>
4400enable_shared_from_this<ELEMENT_TYPE>::shared_from_this()
4401{
4402 return shared_ptr<ELEMENT_TYPE>(d_weakThis);
4403}
4404
4405template<class ELEMENT_TYPE>
4406inline
4407shared_ptr<const ELEMENT_TYPE>
4408enable_shared_from_this<ELEMENT_TYPE>::shared_from_this() const
4409{
4410 return shared_ptr<const ELEMENT_TYPE>(d_weakThis);
4411}
4412
4413template<class ELEMENT_TYPE>
4414inline
4415weak_ptr<ELEMENT_TYPE>
4416enable_shared_from_this<ELEMENT_TYPE>::weak_from_this() BSLS_KEYWORD_NOEXCEPT
4417{
4418 return d_weakThis;
4419}
4420
4421template<class ELEMENT_TYPE>
4422inline
4423weak_ptr<const ELEMENT_TYPE>
4424enable_shared_from_this<ELEMENT_TYPE>::weak_from_this() const
4426{
4427 return d_weakThis;
4428}
4429
4430 // ----------------
4431 // class shared_ptr
4432 // ----------------
4433
4434// PRIVATE CLASS METHODS
4435template <class ELEMENT_TYPE>
4436template <class INPLACE_REP>
4437inline
4438BloombergLP::bslma::SharedPtrRep *
4439shared_ptr<ELEMENT_TYPE>::makeInternalRep(
4440 ELEMENT_TYPE *,
4441 INPLACE_REP *,
4442 BloombergLP::bslma::SharedPtrRep *rep)
4443{
4444 return rep;
4445}
4446
4447template <class ELEMENT_TYPE>
4448template <class COMPATIBLE_TYPE, class ALLOCATOR>
4449inline
4450BloombergLP::bslma::SharedPtrRep *
4451shared_ptr<ELEMENT_TYPE>::makeInternalRep(
4452 COMPATIBLE_TYPE *ptr,
4453 ALLOCATOR *,
4454 BloombergLP::bslma::Allocator *allocator)
4455{
4456 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4457 COMPATIBLE_TYPE,
4458 BloombergLP::bslma::Allocator *>
4459 RepMaker;
4460
4461 return RepMaker::makeOutofplaceRep(ptr, allocator, allocator);
4462}
4463
4464template <class ELEMENT_TYPE>
4465template <class COMPATIBLE_TYPE, class DELETER>
4466inline
4467BloombergLP::bslma::SharedPtrRep *
4468shared_ptr<ELEMENT_TYPE>::makeInternalRep(COMPATIBLE_TYPE *ptr,
4469 DELETER *deleter,
4470 ...)
4471{
4472 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<COMPATIBLE_TYPE,
4473 DELETER *> RepMaker;
4474
4475 return RepMaker::makeOutofplaceRep(ptr, deleter, 0);
4476}
4477
4478// CREATORS
4479template <class ELEMENT_TYPE>
4480inline
4482shared_ptr<ELEMENT_TYPE>::shared_ptr() BSLS_KEYWORD_NOEXCEPT
4483: d_ptr_p(0)
4484, d_rep_p(0)
4485{
4486}
4487
4488template <class ELEMENT_TYPE>
4489inline
4491shared_ptr<ELEMENT_TYPE>::shared_ptr(bsl::nullptr_t) BSLS_KEYWORD_NOEXCEPT
4492: d_ptr_p(0)
4493, d_rep_p(0)
4494{
4495}
4496
4497template <class ELEMENT_TYPE>
4498template <class CONVERTIBLE_TYPE
4500inline
4501shared_ptr<ELEMENT_TYPE>::shared_ptr(CONVERTIBLE_TYPE *ptr)
4502: d_ptr_p(ptr)
4503{
4504 typedef BloombergLP::bslstl::SharedPtr_DefaultDeleter<
4506 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4507 Deleter> RepMaker;
4508
4509 d_rep_p = RepMaker::makeOutofplaceRep(ptr, Deleter(), 0);
4511 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4512 this);
4513 }
4514}
4515
4516template <class ELEMENT_TYPE>
4517template <class CONVERTIBLE_TYPE
4519inline
4520shared_ptr<ELEMENT_TYPE>::shared_ptr(
4521 CONVERTIBLE_TYPE *ptr,
4522 BloombergLP::bslma::Allocator *basicAllocator)
4523: d_ptr_p(ptr)
4524{
4525 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<
4526 CONVERTIBLE_TYPE,
4527 BloombergLP::bslma::Allocator *>
4528 RepMaker;
4529
4530 d_rep_p = RepMaker::makeOutofplaceRep(ptr, basicAllocator, basicAllocator);
4532 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4533 this);
4534 }
4535}
4536
4537template <class ELEMENT_TYPE>
4538inline
4539shared_ptr<ELEMENT_TYPE>::shared_ptr(
4540 typename shared_ptr<ELEMENT_TYPE>::element_type *ptr,
4541 BloombergLP::bslma::SharedPtrRep *rep)
4542: d_ptr_p(ptr)
4543, d_rep_p(rep)
4544{
4545 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4546 this);
4547}
4548
4549template <class ELEMENT_TYPE>
4550inline
4551shared_ptr<ELEMENT_TYPE>::shared_ptr(
4552 ELEMENT_TYPE *ptr,
4553 BloombergLP::bslma::SharedPtrRep *rep,
4554 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr)
4555: d_ptr_p(ptr)
4556, d_rep_p(rep)
4557{
4558}
4559
4560template <class ELEMENT_TYPE>
4561template <class CONVERTIBLE_TYPE,
4562 class DISPATCH
4564 BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(DISPATCH *, CONVERTIBLE_TYPE)>
4565inline
4566shared_ptr<ELEMENT_TYPE>::shared_ptr(CONVERTIBLE_TYPE *ptr,
4567 DISPATCH *dispatch)
4568: d_ptr_p(ptr)
4569, d_rep_p(makeInternalRep(ptr, dispatch, dispatch))
4570{
4572 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4573 this);
4574 }
4575}
4576
4577template <class ELEMENT_TYPE>
4578template <class CONVERTIBLE_TYPE,
4579 class DELETER
4581 BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(DELETER, CONVERTIBLE_TYPE)>
4582inline
4583shared_ptr<ELEMENT_TYPE>::shared_ptr(
4584 CONVERTIBLE_TYPE *ptr,
4585 DELETER deleter,
4586 BloombergLP::bslma::Allocator *basicAllocator)
4587: d_ptr_p(ptr)
4588{
4589 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<CONVERTIBLE_TYPE,
4590 DELETER> RepMaker;
4591
4592 d_rep_p = RepMaker::makeOutofplaceRep(ptr, deleter, basicAllocator);
4594 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4595 this);
4596 }
4597}
4598
4599template <class ELEMENT_TYPE>
4600template <class CONVERTIBLE_TYPE,
4601 class DELETER,
4602 class ALLOCATOR
4604 BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(DELETER, CONVERTIBLE_TYPE)>
4605inline
4606shared_ptr<ELEMENT_TYPE>::shared_ptr(CONVERTIBLE_TYPE *ptr,
4607 DELETER deleter,
4608 ALLOCATOR basicAllocator,
4609 typename ALLOCATOR::value_type *)
4610: d_ptr_p(ptr)
4611{
4612#ifdef BSLS_PLATFORM_CMP_MSVC
4613 // This is not quite C++11 'decay' as we do not need to worry about array
4614 // types, and do not want to remove reference or cv-qualification from
4615 // DELETER otherwise. This works around a Microsoft bug turning function
4616 // pointers into function references.
4617
4620 DELETER>::type DeleterType;
4621#else
4622 typedef DELETER DeleterType;
4623#endif
4624
4625 typedef
4626 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<CONVERTIBLE_TYPE,
4627 DeleterType,
4628 ALLOCATOR> RepMaker;
4629
4630 d_rep_p = RepMaker::makeOutofplaceRep(ptr, deleter, basicAllocator);
4632 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(ptr,
4633 this);
4634 }
4635}
4636
4637template <class ELEMENT_TYPE>
4638inline
4639shared_ptr<ELEMENT_TYPE>::shared_ptr(nullptr_t,
4640 BloombergLP::bslma::Allocator *)
4641: d_ptr_p(0)
4642, d_rep_p(0)
4643{
4644}
4645
4646template <class ELEMENT_TYPE>
4647template <class DELETER
4649inline
4650shared_ptr<ELEMENT_TYPE>::shared_ptr(
4651 nullptr_t,
4652 DELETER deleter,
4653 BloombergLP::bslma::Allocator *basicAllocator)
4654: d_ptr_p(0)
4655{
4656 typedef BloombergLP::bslma::SharedPtrOutofplaceRep<ELEMENT_TYPE,
4657 DELETER> RepMaker;
4658
4661 d_rep_p = 0;
4662 }
4663 else {
4664 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
4665 deleter,
4666 basicAllocator);
4667 }
4668}
4669
4670template <class ELEMENT_TYPE>
4671template <class DELETER, class ALLOCATOR
4673inline
4674shared_ptr<ELEMENT_TYPE>::shared_ptr(
4675 nullptr_t,
4676 DELETER deleter,
4677 ALLOCATOR basicAllocator,
4678 typename ALLOCATOR::value_type *)
4679: d_ptr_p(0)
4680{
4681#ifdef BSLS_PLATFORM_CMP_MSVC
4682 // This is not quite C++11 'decay' as we do not need to worry about array
4683 // types, and do not want to remove reference or cv-qualification from
4684 // DELETER otherwise. This works around a Microsoft bug turning function
4685 // pointers into function references.
4686
4689 DELETER>::type DeleterType;
4690#else
4691 typedef DELETER DeleterType;
4692#endif
4693
4694 typedef
4695 BloombergLP::bslstl::SharedPtrAllocateOutofplaceRep<ELEMENT_TYPE,
4696 DeleterType,
4697 ALLOCATOR> RepMaker;
4698
4699 d_rep_p = RepMaker::makeOutofplaceRep((ELEMENT_TYPE *)0,
4700 deleter,
4701 basicAllocator);
4702}
4703
4704template <class ELEMENT_TYPE>
4705template <class CONVERTIBLE_TYPE
4707shared_ptr<ELEMENT_TYPE>::shared_ptr(
4708 BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE> managedPtr,
4709 BloombergLP::bslma::Allocator *basicAllocator)
4710: d_ptr_p(managedPtr.ptr())
4711, d_rep_p(0)
4712{
4713 typedef BloombergLP::bslma::SharedPtrInplaceRep<
4714 BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE> > Rep;
4715
4716 if (d_ptr_p) {
4717 ELEMENT_TYPE *pPotentiallyShared = static_cast<ELEMENT_TYPE *>(
4718 managedPtr.deleter().object());
4719
4720 if (&BloombergLP::bslma::SharedPtrRep::managedPtrDeleter ==
4721 managedPtr.deleter().deleter()) {
4722 d_rep_p = static_cast<BloombergLP::bslma::SharedPtrRep *>
4723 (managedPtr.release().second.factory());
4724 }
4725 else if (&BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter ==
4726 managedPtr.deleter().deleter()) {
4727 d_rep_p = 0;
4728 managedPtr.release();
4729 }
4730 else {
4731 basicAllocator =
4732 BloombergLP::bslma::Default::allocator(basicAllocator);
4733 Rep *rep = new (*basicAllocator) Rep(basicAllocator);
4734 (*rep->ptr()) = managedPtr;
4735 d_rep_p = rep;
4736 }
4737
4738 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
4739 pPotentiallyShared,
4740 this);
4741 }
4742}
4743
4744#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
4745template <class ELEMENT_TYPE>
4746template <class CONVERTIBLE_TYPE
4748shared_ptr<ELEMENT_TYPE>::shared_ptr(
4749 std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr,
4750 BloombergLP::bslma::Allocator *basicAllocator)
4751: d_ptr_p(autoPtr.get())
4752, d_rep_p(0)
4753{
4754 typedef BloombergLP::bslma::SharedPtrInplaceRep<
4755 std::auto_ptr<CONVERTIBLE_TYPE> > Rep;
4756
4757 if (d_ptr_p) {
4758 basicAllocator =
4759 BloombergLP::bslma::Default::allocator(basicAllocator);
4760 Rep *rep = new (*basicAllocator) Rep(basicAllocator);
4761 (*rep->ptr()) = autoPtr;
4762 d_rep_p = rep;
4763 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
4764 d_ptr_p,
4765 this);
4766 }
4767}
4768
4769template <class ELEMENT_TYPE>
4770shared_ptr<ELEMENT_TYPE>::shared_ptr(
4771 std::auto_ptr_ref<ELEMENT_TYPE> autoRef,
4772 BloombergLP::bslma::Allocator *basicAllocator)
4773: d_ptr_p(0)
4774, d_rep_p(0)
4775{
4776 typedef BloombergLP::bslma::SharedPtrInplaceRep<
4777 std::auto_ptr<ELEMENT_TYPE> > Rep;
4778
4779 std::auto_ptr<ELEMENT_TYPE> autoPtr(autoRef);
4780 if (autoPtr.get()) {
4781 basicAllocator =
4782 BloombergLP::bslma::Default::allocator(basicAllocator);
4783 Rep *rep = new (*basicAllocator) Rep(basicAllocator);
4784 d_ptr_p = autoPtr.get();
4785 (*rep->ptr()) = autoPtr;
4786 d_rep_p = rep;
4787 }
4788}
4789#endif
4790
4791#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
4792# if defined(BSLSTL_SHAREDPTR_SUPPORTS_SFINAE_CHECKS)
4793template <class ELEMENT_TYPE>
4794template <class COMPATIBLE_TYPE,
4795 class UNIQUE_DELETER,
4796 typename enable_if<is_convertible<
4797 typename std::unique_ptr<COMPATIBLE_TYPE,
4798 UNIQUE_DELETER>::pointer,
4799 ELEMENT_TYPE *>::value>::type *>
4800shared_ptr<ELEMENT_TYPE>::shared_ptr(
4801 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee,
4802 BloombergLP::bslma::Allocator *basicAllocator)
4803: d_ptr_p(adoptee.get())
4804, d_rep_p(0)
4805{
4806 typedef BloombergLP::bslma::SharedPtrInplaceRep<
4807 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER> > Rep;
4808
4809 if (d_ptr_p) {
4810 basicAllocator =
4811 BloombergLP::bslma::Default::allocator(basicAllocator);
4812 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
4813 BloombergLP::bslmf::MovableRefUtil::move(adoptee));
4814 d_rep_p = rep;
4815 BloombergLP::bslstl::SharedPtr_ImpUtil::loadEnableSharedFromThis(
4816 d_ptr_p,
4817 this);
4818 }
4819}
4820# endif
4821#endif
4822
4823template <class ELEMENT_TYPE>
4824template <class ANY_TYPE>
4825shared_ptr<ELEMENT_TYPE>::shared_ptr(const shared_ptr<ANY_TYPE>& source,
4826 ELEMENT_TYPE *object)
4828: d_ptr_p(object)
4829, d_rep_p(source.d_rep_p)
4830{
4831 if (d_rep_p) {
4832 d_rep_p->acquireRef();
4833 }
4834}
4835
4836template <class ELEMENT_TYPE>
4837template <class COMPATIBLE_TYPE
4839shared_ptr<ELEMENT_TYPE>::
4840shared_ptr(const shared_ptr<COMPATIBLE_TYPE>& other) BSLS_KEYWORD_NOEXCEPT
4841: d_ptr_p(other.d_ptr_p)
4842, d_rep_p(other.d_rep_p)
4843{
4844 if (d_rep_p) {
4845 d_rep_p->acquireRef();
4846 }
4847}
4848
4849template <class ELEMENT_TYPE>
4850shared_ptr<ELEMENT_TYPE>::shared_ptr(const shared_ptr& original)
4852: d_ptr_p(original.d_ptr_p)
4853, d_rep_p(original.d_rep_p)
4854{
4855 if (d_rep_p) {
4856 d_rep_p->acquireRef();
4857 }
4858}
4859
4860template <class ELEMENT_TYPE>
4861shared_ptr<ELEMENT_TYPE>::shared_ptr
4862 (BloombergLP::bslmf::MovableRef<shared_ptr> original)
4864: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
4865, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
4866{
4867 BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p = 0;
4868 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
4869}
4870
4871#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4872template <class ELEMENT_TYPE>
4873template <class COMPATIBLE_TYPE
4875shared_ptr<ELEMENT_TYPE>::shared_ptr(shared_ptr<COMPATIBLE_TYPE>&& other)
4877: d_ptr_p(other.d_ptr_p)
4878, d_rep_p(other.d_rep_p)
4879{
4880 other.d_ptr_p = 0;
4881 other.d_rep_p = 0;
4882}
4883#else
4884template <class ELEMENT_TYPE>
4885template <class COMPATIBLE_TYPE
4887shared_ptr<ELEMENT_TYPE>::
4888shared_ptr(BloombergLP::bslmf::MovableRef<shared_ptr<COMPATIBLE_TYPE> > other)
4890: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p)
4891, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p)
4892{
4893 BloombergLP::bslmf::MovableRefUtil::access(other).d_ptr_p = 0;
4894 BloombergLP::bslmf::MovableRefUtil::access(other).d_rep_p = 0;
4895}
4896#endif
4897
4898template <class ELEMENT_TYPE>
4899template <class COMPATIBLE_TYPE
4901shared_ptr<ELEMENT_TYPE>::shared_ptr(const weak_ptr<COMPATIBLE_TYPE>& other)
4902: d_ptr_p(0)
4903, d_rep_p(0)
4904{
4905 // This implementation handles two awkward cases:
4906 //
4907 // i) a ref-counted null pointer, means we cannot simply test 'if (!value)'
4908 // ii) a null pointer aliasing a non-null pointer is still expired, and so
4909 // should throw.
4910
4911 SelfType value = other.lock();
4912 if (other.expired()) {
4913 // Test after lock to avoid a race between testing 'expired' and
4914 // claiming the lock.
4915
4916 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
4917 }
4918
4919 swap(value);
4920}
4921
4922#if !defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
4923template <class ELEMENT_TYPE>
4924template <class COMPATIBLE_TYPE
4926shared_ptr<ELEMENT_TYPE>::shared_ptr(
4927 BloombergLP::bslmf::MovableRef<weak_ptr<COMPATIBLE_TYPE> > ptr)
4928: d_ptr_p(0)
4929, d_rep_p(0)
4930{
4931 // This implementation handles two awkward cases:
4932 //
4933 // i) a ref-counted null pointer, means we cannot simply test 'if (!value)'
4934 // ii) a null pointer aliasing a non-null pointer is still expired, and so
4935 // should throw.
4936
4937 weak_ptr<COMPATIBLE_TYPE>& other = ptr;
4938
4939 SelfType value = other.lock();
4940 if (other.expired()) {
4941 // Test after lock to avoid a race between testing 'expired' and
4942 // claiming the lock.
4943
4944 BloombergLP::bslstl::SharedPtr_ImpUtil::throwBadWeakPtr();
4945 }
4946
4947 swap(value);
4948}
4949#endif
4950
4951template <class ELEMENT_TYPE>
4952shared_ptr<ELEMENT_TYPE>::~shared_ptr()
4953{
4954 if (d_rep_p) {
4955 d_rep_p->releaseRef();
4956 }
4957}
4958
4959// MANIPULATORS
4960template <class ELEMENT_TYPE>
4961shared_ptr<ELEMENT_TYPE>&
4962shared_ptr<ELEMENT_TYPE>::operator=(const shared_ptr& rhs)
4964{
4965 // Instead of testing '&rhs == this', which happens infrequently, optimize
4966 // for when reps are the same.
4967
4968 if (rhs.d_rep_p == d_rep_p) {
4969 d_ptr_p = rhs.d_ptr_p;
4970 }
4971 else {
4972 SelfType(rhs).swap(*this);
4973 }
4974
4975 return *this;
4976}
4977
4978template <class ELEMENT_TYPE>
4979shared_ptr<ELEMENT_TYPE>&
4980shared_ptr<ELEMENT_TYPE>::operator=(
4981 BloombergLP::bslmf::MovableRef<shared_ptr> rhs)
4983{
4984 // No self-assignment to optimize, postcondition demands 'rhs' is left
4985 // empty, unless it is the exact same object, not just the same 'rep'.
4986
4987 shared_ptr(BloombergLP::bslmf::MovableRefUtil::move(rhs)).swap(*this);
4988
4989 return *this;
4990}
4991
4992template <class ELEMENT_TYPE>
4993template <class COMPATIBLE_TYPE>
4994typename enable_if<
4995 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
4996 shared_ptr<ELEMENT_TYPE>&>::type
4997shared_ptr<ELEMENT_TYPE>::operator=(const shared_ptr<COMPATIBLE_TYPE>& rhs)
4999{
5000 // Instead of testing '&rhs == this', which happens infrequently, optimize
5001 // for when reps are the same.
5002
5003 if (rhs.d_rep_p == d_rep_p) {
5004 d_ptr_p = rhs.d_ptr_p;
5005 }
5006 else {
5007 SelfType(rhs).swap(*this);
5008 }
5009
5010 return *this;
5011}
5012
5013#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5014template <class ELEMENT_TYPE>
5015template <class COMPATIBLE_TYPE>
5016typename enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5017 shared_ptr<ELEMENT_TYPE>&>::type
5018shared_ptr<ELEMENT_TYPE>::operator=(shared_ptr<COMPATIBLE_TYPE>&& rhs)
5020#else
5021template <class ELEMENT_TYPE>
5022template <class COMPATIBLE_TYPE>
5023typename enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5024 shared_ptr<ELEMENT_TYPE>&>::type
5025shared_ptr<ELEMENT_TYPE>::operator=(
5026 BloombergLP::bslmf::MovableRef<shared_ptr<COMPATIBLE_TYPE> > rhs)
5028#endif
5029{
5030 // No self-assignment to optimize, postcondition demands 'rhs' is left
5031 // empty, unless it is the exact same object, not just the same 'rep'.
5032
5033 shared_ptr(BloombergLP::bslmf::MovableRefUtil::move(rhs)).swap(*this);
5034
5035 return *this;
5036}
5037
5038template <class ELEMENT_TYPE>
5039template <class COMPATIBLE_TYPE>
5040inline
5041typename enable_if<
5042 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5043 shared_ptr<ELEMENT_TYPE>&>::type
5044shared_ptr<ELEMENT_TYPE>::operator=(
5045 BloombergLP::bslma::ManagedPtr<COMPATIBLE_TYPE> rhs)
5046{
5047 SelfType(rhs).swap(*this);
5048 return *this;
5049}
5050
5051#if defined(BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR)
5052template <class ELEMENT_TYPE>
5053template <class COMPATIBLE_TYPE>
5054inline
5055typename enable_if<
5056 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
5057 shared_ptr<ELEMENT_TYPE>&>::type
5058shared_ptr<ELEMENT_TYPE>::operator=(std::auto_ptr<COMPATIBLE_TYPE> rhs)
5059{
5060 SelfType(rhs).swap(*this);
5061 return *this;
5062}
5063#endif
5064
5065#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR)
5066template <class ELEMENT_TYPE>
5067template <class COMPATIBLE_TYPE, class UNIQUE_DELETER>
5068inline
5069typename enable_if<
5070 is_convertible<
5071 typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer,
5072 ELEMENT_TYPE *>::value,
5073 shared_ptr<ELEMENT_TYPE>&>::type
5074shared_ptr<ELEMENT_TYPE>::operator=(
5075 std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& rhs)
5076{
5077 SelfType(BloombergLP::bslmf::MovableRefUtil::move(rhs)).swap(*this);
5078 return *this;
5079}
5080#endif
5081
5082template <class ELEMENT_TYPE>
5083inline
5084void shared_ptr<ELEMENT_TYPE>::reset() BSLS_KEYWORD_NOEXCEPT
5085{
5086 BloombergLP::bslma::SharedPtrRep *rep = d_rep_p;
5087
5088 // Clear 'd_rep_p' first so that a self-referencing shared pointer's
5089 // destructor does not try to call 'releaseRef' again.
5090
5091 d_rep_p = 0;
5092 d_ptr_p = 0;
5093
5094 if (rep) {
5095 rep->releaseRef();
5096 }
5097}
5098
5099template <class ELEMENT_TYPE>
5100template <class COMPATIBLE_TYPE>
5101inline
5102typename
5103 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
5104shared_ptr<ELEMENT_TYPE>::reset(COMPATIBLE_TYPE *ptr)
5105{
5106 SelfType(ptr).swap(*this);
5107}
5108
5109template <class ELEMENT_TYPE>
5110template <class COMPATIBLE_TYPE, class DELETER>
5111inline
5112typename
5113 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
5114shared_ptr<ELEMENT_TYPE>::reset(COMPATIBLE_TYPE *ptr,
5115 DELETER deleter)
5116{
5117 SelfType(ptr, deleter).swap(*this);
5118}
5119
5120template <class ELEMENT_TYPE>
5121template <class COMPATIBLE_TYPE, class DELETER, class ALLOCATOR>
5122inline
5123typename
5124 enable_if<is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value>::type
5125shared_ptr<ELEMENT_TYPE>::reset(COMPATIBLE_TYPE *ptr,
5126 DELETER deleter,
5127 ALLOCATOR basicAllocator)
5128{
5129 SelfType(ptr, deleter, basicAllocator).swap(*this);
5130}
5131
5132template <class ELEMENT_TYPE>
5133template <class ANY_TYPE>
5134inline
5135void shared_ptr<ELEMENT_TYPE>::reset(const shared_ptr<ANY_TYPE>& source,
5136 ELEMENT_TYPE *ptr)
5137{
5138 // Optimize for the (expected) common case where aliases are managing the
5139 // same data structure.
5140
5141 if (source.d_rep_p == d_rep_p && ptr) {
5142 d_ptr_p = ptr;
5143 }
5144 else {
5145 SelfType(source, ptr).swap(*this);
5146 }
5147}
5148
5149template <class ELEMENT_TYPE>
5150inline
5151void shared_ptr<ELEMENT_TYPE>::swap(shared_ptr& other) BSLS_KEYWORD_NOEXCEPT
5152{
5153 // We directly implement swapping of two pointers, rather than simply
5154 // calling 'bsl::swap' or using 'bslalg::SwapUtil', to avoid (indirectly)
5155 // including the platform <algorithm> header, which may transitively
5156 // include other standard headers. This reduces the risk of
5157 // platform-specific cycles, which have been observed to cause problems.
5158
5159 // Also, as 'shared_ptr' is bitwise-moveable, we could simplify this to
5160 // 'memcpy'-ing through an (aligned?) array of sufficient 'char'.
5161
5162 element_type *tempPtr_p = d_ptr_p;
5163 d_ptr_p = other.d_ptr_p;
5164 other.d_ptr_p = tempPtr_p;
5165
5166 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
5167 d_rep_p = other.d_rep_p;
5168 other.d_rep_p = tempRep_p;
5169}
5170
5171// ADDITIONAL BSL MANIPULATORS
5172template<class ELEMENT_TYPE>
5173void
5174shared_ptr<ELEMENT_TYPE>::createInplace()
5175{
5176 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5177
5178 BloombergLP::bslma::Allocator *basicAllocator =
5179 BloombergLP::bslma::Default::allocator();
5180
5181 Rep *rep = new (*basicAllocator) Rep(basicAllocator);
5182 SelfType(rep->ptr(), rep).swap(*this);
5183}
5184
5185#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
5186// {{{ BEGIN GENERATED CODE
5187// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
5188#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
5189#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
5190#endif
5191#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E
5192#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E BSLSTL_SHAREDPTR_VARIADIC_LIMIT
5193#endif
5194#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 0
5195template <class ELEMENT_TYPE>
5196void
5197shared_ptr<ELEMENT_TYPE>::createInplace(
5198 BloombergLP::bslma::Allocator *basicAllocator)
5199{
5200 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5201
5202 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5203 Rep *rep = new (*basicAllocator) Rep(basicAllocator);
5204 SelfType(rep->ptr(), rep).swap(*this);
5205}
5206#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 0
5207
5208#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 1
5209template <class ELEMENT_TYPE>
5210template <class ARGS_01>
5211void
5212shared_ptr<ELEMENT_TYPE>::createInplace(
5213 BloombergLP::bslma::Allocator *basicAllocator,
5214 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
5215{
5216 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5217
5218 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5219 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5220 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01));
5221 SelfType(rep->ptr(), rep).swap(*this);
5222}
5223#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 1
5224
5225#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 2
5226template <class ELEMENT_TYPE>
5227template <class ARGS_01,
5228 class ARGS_02>
5229void
5230shared_ptr<ELEMENT_TYPE>::createInplace(
5231 BloombergLP::bslma::Allocator *basicAllocator,
5232 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5233 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
5234{
5235 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5236
5237 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5238 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5239 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5240 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02));
5241 SelfType(rep->ptr(), rep).swap(*this);
5242}
5243#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 2
5244
5245#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 3
5246template <class ELEMENT_TYPE>
5247template <class ARGS_01,
5248 class ARGS_02,
5249 class ARGS_03>
5250void
5251shared_ptr<ELEMENT_TYPE>::createInplace(
5252 BloombergLP::bslma::Allocator *basicAllocator,
5253 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5254 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5255 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
5256{
5257 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5258
5259 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5260 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5261 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5262 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5263 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03));
5264 SelfType(rep->ptr(), rep).swap(*this);
5265}
5266#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 3
5267
5268#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 4
5269template <class ELEMENT_TYPE>
5270template <class ARGS_01,
5271 class ARGS_02,
5272 class ARGS_03,
5273 class ARGS_04>
5274void
5275shared_ptr<ELEMENT_TYPE>::createInplace(
5276 BloombergLP::bslma::Allocator *basicAllocator,
5277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5280 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
5281{
5282 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5283
5284 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5285 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5286 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5287 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5288 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5289 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04));
5290 SelfType(rep->ptr(), rep).swap(*this);
5291}
5292#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 4
5293
5294#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 5
5295template <class ELEMENT_TYPE>
5296template <class ARGS_01,
5297 class ARGS_02,
5298 class ARGS_03,
5299 class ARGS_04,
5300 class ARGS_05>
5301void
5302shared_ptr<ELEMENT_TYPE>::createInplace(
5303 BloombergLP::bslma::Allocator *basicAllocator,
5304 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5305 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5306 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
5309{
5310 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5311
5312 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5313 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5314 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5315 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5316 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5317 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5318 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05));
5319 SelfType(rep->ptr(), rep).swap(*this);
5320}
5321#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 5
5322
5323#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 6
5324template <class ELEMENT_TYPE>
5325template <class ARGS_01,
5326 class ARGS_02,
5327 class ARGS_03,
5328 class ARGS_04,
5329 class ARGS_05,
5330 class ARGS_06>
5331void
5332shared_ptr<ELEMENT_TYPE>::createInplace(
5333 BloombergLP::bslma::Allocator *basicAllocator,
5334 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5335 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5336 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5337 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5338 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5339 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
5340{
5341 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5342
5343 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5344 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5345 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5346 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5347 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5348 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5349 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5350 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06));
5351 SelfType(rep->ptr(), rep).swap(*this);
5352}
5353#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 6
5354
5355#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 7
5356template <class ELEMENT_TYPE>
5357template <class ARGS_01,
5358 class ARGS_02,
5359 class ARGS_03,
5360 class ARGS_04,
5361 class ARGS_05,
5362 class ARGS_06,
5363 class ARGS_07>
5364void
5365shared_ptr<ELEMENT_TYPE>::createInplace(
5366 BloombergLP::bslma::Allocator *basicAllocator,
5367 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5368 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5369 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5370 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5371 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
5374{
5375 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5376
5377 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5378 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5379 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5380 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5381 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5382 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5383 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5384 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5385 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07));
5386 SelfType(rep->ptr(), rep).swap(*this);
5387}
5388#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 7
5389
5390#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 8
5391template <class ELEMENT_TYPE>
5392template <class ARGS_01,
5393 class ARGS_02,
5394 class ARGS_03,
5395 class ARGS_04,
5396 class ARGS_05,
5397 class ARGS_06,
5398 class ARGS_07,
5399 class ARGS_08>
5400void
5401shared_ptr<ELEMENT_TYPE>::createInplace(
5402 BloombergLP::bslma::Allocator *basicAllocator,
5403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5404 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5405 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5406 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5407 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5408 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5409 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5410 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
5411{
5412 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5413
5414 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5415 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5416 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5417 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5418 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5419 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5420 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5421 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5422 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5423 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08));
5424 SelfType(rep->ptr(), rep).swap(*this);
5425}
5426#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 8
5427
5428#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 9
5429template <class ELEMENT_TYPE>
5430template <class ARGS_01,
5431 class ARGS_02,
5432 class ARGS_03,
5433 class ARGS_04,
5434 class ARGS_05,
5435 class ARGS_06,
5436 class ARGS_07,
5437 class ARGS_08,
5438 class ARGS_09>
5439void
5440shared_ptr<ELEMENT_TYPE>::createInplace(
5441 BloombergLP::bslma::Allocator *basicAllocator,
5442 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5443 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5444 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5445 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5446 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5447 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5448 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5449 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5450 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
5451{
5452 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5453
5454 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5455 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5456 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5457 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5458 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5459 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5460 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5461 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5462 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5463 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5464 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09));
5465 SelfType(rep->ptr(), rep).swap(*this);
5466}
5467#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 9
5468
5469#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 10
5470template <class ELEMENT_TYPE>
5471template <class ARGS_01,
5472 class ARGS_02,
5473 class ARGS_03,
5474 class ARGS_04,
5475 class ARGS_05,
5476 class ARGS_06,
5477 class ARGS_07,
5478 class ARGS_08,
5479 class ARGS_09,
5480 class ARGS_10>
5481void
5482shared_ptr<ELEMENT_TYPE>::createInplace(
5483 BloombergLP::bslma::Allocator *basicAllocator,
5484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5485 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5486 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5487 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5488 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5489 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5490 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5491 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5492 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
5493 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
5494{
5495 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5496
5497 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5498 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5499 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5500 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5501 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5502 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5503 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5504 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5505 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5506 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5507 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
5508 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10));
5509 SelfType(rep->ptr(), rep).swap(*this);
5510}
5511#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 10
5512
5513#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 11
5514template <class ELEMENT_TYPE>
5515template <class ARGS_01,
5516 class ARGS_02,
5517 class ARGS_03,
5518 class ARGS_04,
5519 class ARGS_05,
5520 class ARGS_06,
5521 class ARGS_07,
5522 class ARGS_08,
5523 class ARGS_09,
5524 class ARGS_10,
5525 class ARGS_11>
5526void
5527shared_ptr<ELEMENT_TYPE>::createInplace(
5528 BloombergLP::bslma::Allocator *basicAllocator,
5529 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5530 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5531 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5532 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5533 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5534 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5535 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5536 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5537 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
5538 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
5539 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11)
5540{
5541 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5542
5543 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5544 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5545 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5546 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5547 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5548 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5549 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5550 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5551 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5552 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5553 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
5554 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
5555 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11));
5556 SelfType(rep->ptr(), rep).swap(*this);
5557}
5558#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 11
5559
5560#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 12
5561template <class ELEMENT_TYPE>
5562template <class ARGS_01,
5563 class ARGS_02,
5564 class ARGS_03,
5565 class ARGS_04,
5566 class ARGS_05,
5567 class ARGS_06,
5568 class ARGS_07,
5569 class ARGS_08,
5570 class ARGS_09,
5571 class ARGS_10,
5572 class ARGS_11,
5573 class ARGS_12>
5574void
5575shared_ptr<ELEMENT_TYPE>::createInplace(
5576 BloombergLP::bslma::Allocator *basicAllocator,
5577 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5578 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5579 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5580 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5581 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5582 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5583 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5584 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5585 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
5586 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
5587 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
5588 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12)
5589{
5590 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5591
5592 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5593 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5594 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5595 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5596 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5597 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5598 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5599 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5600 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5601 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5602 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
5603 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
5604 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
5605 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12));
5606 SelfType(rep->ptr(), rep).swap(*this);
5607}
5608#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 12
5609
5610#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 13
5611template <class ELEMENT_TYPE>
5612template <class ARGS_01,
5613 class ARGS_02,
5614 class ARGS_03,
5615 class ARGS_04,
5616 class ARGS_05,
5617 class ARGS_06,
5618 class ARGS_07,
5619 class ARGS_08,
5620 class ARGS_09,
5621 class ARGS_10,
5622 class ARGS_11,
5623 class ARGS_12,
5624 class ARGS_13>
5625void
5626shared_ptr<ELEMENT_TYPE>::createInplace(
5627 BloombergLP::bslma::Allocator *basicAllocator,
5628 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5629 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5630 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5631 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5632 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5633 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5634 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5635 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5636 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
5637 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
5638 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
5639 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
5640 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13)
5641{
5642 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5643
5644 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5645 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5646 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5647 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5648 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5649 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5650 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5651 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5652 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5653 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5654 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
5655 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
5656 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
5657 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
5658 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13));
5659 SelfType(rep->ptr(), rep).swap(*this);
5660}
5661#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 13
5662
5663#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 14
5664template <class ELEMENT_TYPE>
5665template <class ARGS_01,
5666 class ARGS_02,
5667 class ARGS_03,
5668 class ARGS_04,
5669 class ARGS_05,
5670 class ARGS_06,
5671 class ARGS_07,
5672 class ARGS_08,
5673 class ARGS_09,
5674 class ARGS_10,
5675 class ARGS_11,
5676 class ARGS_12,
5677 class ARGS_13,
5678 class ARGS_14>
5679void
5680shared_ptr<ELEMENT_TYPE>::createInplace(
5681 BloombergLP::bslma::Allocator *basicAllocator,
5682 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
5683 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
5684 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
5685 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
5686 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
5687 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
5688 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
5689 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
5690 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
5691 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
5692 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
5693 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
5694 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
5695 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14)
5696{
5697 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5698
5699 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5700 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5701 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
5702 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
5703 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
5704 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
5705 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
5706 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
5707 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
5708 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
5709 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
5710 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
5711 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
5712 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
5713 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13),
5714 BSLS_COMPILERFEATURES_FORWARD(ARGS_14,args_14));
5715 SelfType(rep->ptr(), rep).swap(*this);
5716}
5717#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_E >= 14
5718
5719#else
5720// The generated code below is a workaround for the absence of perfect
5721// forwarding in some compilers.
5722template <class ELEMENT_TYPE>
5723template <class... ARGS>
5724void
5725shared_ptr<ELEMENT_TYPE>::createInplace(
5726 BloombergLP::bslma::Allocator *basicAllocator,
5728{
5729 typedef BloombergLP::bslma::SharedPtrInplaceRep<ELEMENT_TYPE> Rep;
5730
5731 basicAllocator = BloombergLP::bslma::Default::allocator(basicAllocator);
5732 Rep *rep = new (*basicAllocator) Rep(basicAllocator,
5733 BSLS_COMPILERFEATURES_FORWARD(ARGS,args)...);
5734 SelfType(rep->ptr(), rep).swap(*this);
5735}
5736// }}} END GENERATED CODE
5737#endif
5738
5739template <class ELEMENT_TYPE>
5740template <class ANY_TYPE>
5741void
5742shared_ptr<ELEMENT_TYPE>::loadAlias(const shared_ptr<ANY_TYPE>& source,
5743 ELEMENT_TYPE *object)
5744{
5745 if (source.d_rep_p == d_rep_p && object) {
5746 d_ptr_p = object;
5747 }
5748 else {
5749 SelfType(source, object).swap(*this);
5750 }
5751}
5752
5753template <class ELEMENT_TYPE>
5754pair<typename shared_ptr<ELEMENT_TYPE>::element_type *, BloombergLP::bslma::SharedPtrRep *>
5755shared_ptr<ELEMENT_TYPE>::release() BSLS_KEYWORD_NOEXCEPT
5756{
5757 pair<element_type *, BloombergLP::bslma::SharedPtrRep *> ret(d_ptr_p,
5758 d_rep_p);
5759 d_ptr_p = 0;
5760 d_rep_p = 0;
5761 return ret;
5762}
5763
5764#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5765// DEPRECATED BDE LEGACY MANIPULATORS
5766template <class ELEMENT_TYPE>
5767inline
5768void shared_ptr<ELEMENT_TYPE>::clear() BSLS_KEYWORD_NOEXCEPT
5769{
5770 reset();
5771}
5772
5773template <class ELEMENT_TYPE>
5774template <class COMPATIBLE_TYPE>
5775inline
5776void shared_ptr<ELEMENT_TYPE>::load(COMPATIBLE_TYPE *ptr)
5777{
5778 SelfType(ptr).swap(*this);
5779}
5780
5781template <class ELEMENT_TYPE>
5782template <class COMPATIBLE_TYPE>
5783inline
5784void
5785shared_ptr<ELEMENT_TYPE>::load(COMPATIBLE_TYPE *ptr,
5786 BloombergLP::bslma::Allocator *basicAllocator)
5787{
5788 SelfType(ptr, basicAllocator).swap(*this);
5789}
5790
5791template <class ELEMENT_TYPE>
5792template <class COMPATIBLE_TYPE, class DELETER>
5793inline
5794void
5795shared_ptr<ELEMENT_TYPE>::load(COMPATIBLE_TYPE *ptr,
5796 const DELETER& deleter,
5797 BloombergLP::bslma::Allocator *basicAllocator)
5798{
5799 SelfType(ptr, deleter, basicAllocator).swap(*this);
5800}
5801#endif // BDE_OMIT_INTERNAL_DEPRECATED
5802
5803// ACCESSORS
5804template <class ELEMENT_TYPE>
5805inline
5806#if defined(BSLS_PLATFORM_CMP_IBM) // Last tested with xlC 12.1
5807shared_ptr<ELEMENT_TYPE>::operator typename shared_ptr::BoolType() const
5809#else
5810shared_ptr<ELEMENT_TYPE>::operator BoolType() const BSLS_KEYWORD_NOEXCEPT
5811#endif
5812{
5813 return BloombergLP::bsls::UnspecifiedBool<shared_ptr>::makeValue(d_ptr_p);
5814}
5815
5816template <class ELEMENT_TYPE>
5817inline
5818typename add_lvalue_reference<ELEMENT_TYPE>::type
5819shared_ptr<ELEMENT_TYPE>::operator*() const BSLS_KEYWORD_NOEXCEPT
5820{
5821 BSLS_ASSERT_SAFE(d_ptr_p);
5822
5823 return *d_ptr_p;
5824}
5825
5826template <class ELEMENT_TYPE>
5827inline
5828ELEMENT_TYPE *shared_ptr<ELEMENT_TYPE>::operator->() const
5830{
5831 return d_ptr_p;
5832}
5833
5834template <class ELEMENT_TYPE>
5835inline
5836typename shared_ptr<ELEMENT_TYPE>::element_type *
5837shared_ptr<ELEMENT_TYPE>::get() const BSLS_KEYWORD_NOEXCEPT
5838{
5839 return d_ptr_p;
5840}
5841
5842template <class ELEMENT_TYPE>
5843inline typename
5844add_lvalue_reference<typename shared_ptr<ELEMENT_TYPE>::element_type>::type
5845shared_ptr<ELEMENT_TYPE>::operator[](ptrdiff_t index) const
5846{
5847 BSLS_ASSERT_SAFE(d_ptr_p);
5848
5849 return *(d_ptr_p + index);
5850}
5851
5852template <class ELEMENT_TYPE>
5853template<class ANY_TYPE>
5854inline
5855bool shared_ptr<ELEMENT_TYPE>::owner_before(const shared_ptr<ANY_TYPE>& other)
5857{
5858 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5859}
5860
5861template <class ELEMENT_TYPE>
5862template<class ANY_TYPE>
5863inline
5864bool
5865shared_ptr<ELEMENT_TYPE>::owner_before(const weak_ptr<ANY_TYPE>& other) const
5867{
5868 return std::less<BloombergLP::bslma::SharedPtrRep *>()(rep(), other.rep());
5869}
5870
5871template <class ELEMENT_TYPE>
5872template<class ANY_TYPE>
5873inline
5874bool shared_ptr<ELEMENT_TYPE>::owner_equal(const shared_ptr<ANY_TYPE>& other)
5876{
5877 return rep() == other.rep();
5878}
5879
5880template <class ELEMENT_TYPE>
5881template<class ANY_TYPE>
5882inline
5883bool
5884shared_ptr<ELEMENT_TYPE>::owner_equal(const weak_ptr<ANY_TYPE>& other) const
5886{
5887 return rep() == other.rep();
5888}
5889
5890template <class ELEMENT_TYPE>
5891inline
5892size_t
5893shared_ptr<ELEMENT_TYPE>::owner_hash() const BSLS_KEYWORD_NOEXCEPT
5894{
5895 return hash<BloombergLP::bslma::SharedPtrRep *>()(rep());
5896}
5897
5898template <class ELEMENT_TYPE>
5899inline
5900bool shared_ptr<ELEMENT_TYPE>::unique() const BSLS_KEYWORD_NOEXCEPT
5901{
5902 return 1 == use_count();
5903}
5904
5905template <class ELEMENT_TYPE>
5906inline
5907long shared_ptr<ELEMENT_TYPE>::use_count() const BSLS_KEYWORD_NOEXCEPT
5908{
5909 return d_rep_p ? d_rep_p->numReferences() : 0;
5910}
5911
5912// ADDITIONAL BSL ACCESSORS
5913template <class ELEMENT_TYPE>
5914BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>
5915shared_ptr<ELEMENT_TYPE>::managedPtr() const
5916{
5917 if (d_rep_p && d_ptr_p) {
5918 d_rep_p->acquireRef();
5919 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(d_ptr_p,
5920 d_rep_p,
5921 &BloombergLP::bslma::SharedPtrRep::managedPtrDeleter);
5922 // RETURN
5923 }
5924
5925 return BloombergLP::bslma::ManagedPtr<ELEMENT_TYPE>(
5926 d_ptr_p,
5927 (BloombergLP::bslma::SharedPtrRep *)0,
5928 &BloombergLP::bslma::SharedPtrRep::managedPtrEmptyDeleter);
5929}
5930
5931template <class ELEMENT_TYPE>
5932inline
5933BloombergLP::bslma::SharedPtrRep *shared_ptr<ELEMENT_TYPE>::rep() const
5935{
5936 return d_rep_p;
5937}
5938
5939#ifndef BDE_OMIT_INTERNAL_DEPRECATED
5940// DEPRECATED BDE LEGACY ACCESSORS
5941template <class ELEMENT_TYPE>
5942inline
5943int shared_ptr<ELEMENT_TYPE>::numReferences() const BSLS_KEYWORD_NOEXCEPT
5944{
5945 return d_rep_p ? d_rep_p->numReferences() : 0;
5946}
5947
5948template <class ELEMENT_TYPE>
5949inline
5950typename shared_ptr<ELEMENT_TYPE>::element_type *
5951shared_ptr<ELEMENT_TYPE>::ptr() const BSLS_KEYWORD_NOEXCEPT
5952{
5953 return d_ptr_p;
5954}
5955#endif // BDE_OMIT_INTERNAL_DEPRECATED
5956
5957 // --------------
5958 // class weak_ptr
5959 // --------------
5960
5961// CREATORS
5962template <class ELEMENT_TYPE>
5963inline
5965weak_ptr<ELEMENT_TYPE>::weak_ptr() BSLS_KEYWORD_NOEXCEPT
5966: d_ptr_p(0)
5967, d_rep_p(0)
5968{
5969}
5970
5971template <class ELEMENT_TYPE>
5972weak_ptr<ELEMENT_TYPE>::weak_ptr(
5973 BloombergLP::bslmf::MovableRef<weak_ptr> original)
5975: d_ptr_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_ptr_p)
5976, d_rep_p(BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p)
5977{
5978 BloombergLP::bslmf::MovableRefUtil::access(original).d_rep_p = 0;
5979// original.d_ptr_p = 0; // this seems overkill for a /weak/ pointer
5980}
5981
5982#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
5983template <class ELEMENT_TYPE>
5984template <class COMPATIBLE_TYPE
5986weak_ptr<ELEMENT_TYPE>::weak_ptr(weak_ptr<COMPATIBLE_TYPE>&& original)
5988: d_ptr_p(original.d_ptr_p)
5989, d_rep_p(original.d_rep_p)
5990{
5991 original.d_rep_p = 0;
5992// original.d_ptr_p = 0; // this seems overkill for a /weak/ pointer
5993}
5994#else
5995template <class ELEMENT_TYPE>
5996template <class CONVERTIBLE_TYPE
5998weak_ptr<ELEMENT_TYPE>::weak_ptr(
5999 BloombergLP::bslmf::MovableRef<weak_ptr<CONVERTIBLE_TYPE> > original)
6001: d_ptr_p(original.d_ptr_p)
6002, d_rep_p(original.d_rep_p)
6003{
6004 original.d_rep_p = 0;
6005// original.d_ptr_p = 0; // this seems overkill for a /weak/ pointer
6006}
6007#endif
6008
6009template <class ELEMENT_TYPE>
6010weak_ptr<ELEMENT_TYPE>::weak_ptr(const weak_ptr<ELEMENT_TYPE>& original)
6012: d_ptr_p(original.d_ptr_p)
6013, d_rep_p(original.d_rep_p)
6014{
6015 if (d_rep_p) {
6016 d_rep_p->acquireWeakRef();
6017 }
6018}
6019
6020template <class ELEMENT_TYPE>
6021template <class COMPATIBLE_TYPE
6023weak_ptr<ELEMENT_TYPE>::weak_ptr(const shared_ptr<COMPATIBLE_TYPE>& other)
6025: d_ptr_p(other.get())
6026, d_rep_p(other.rep())
6027{
6028 if (d_rep_p) {
6029 d_rep_p->acquireWeakRef();
6030 }
6031}
6032
6033template <class ELEMENT_TYPE>
6034template <class COMPATIBLE_TYPE
6036weak_ptr<ELEMENT_TYPE>::weak_ptr(const weak_ptr<COMPATIBLE_TYPE>& other)
6038: d_ptr_p(other.d_ptr_p)
6039, d_rep_p(other.d_rep_p)
6040{
6041 if (d_rep_p) {
6042 d_rep_p->acquireWeakRef();
6043 }
6044}
6045
6046template <class ELEMENT_TYPE>
6047inline
6048weak_ptr<ELEMENT_TYPE>::~weak_ptr()
6049{
6050 if (d_rep_p) {
6051 d_rep_p->releaseWeakRef();
6052 }
6053}
6054
6055// PRIVATE MANIPULATORS
6056template <class ELEMENT_TYPE>
6057inline
6058void weak_ptr<ELEMENT_TYPE>::privateAssign(
6059 BloombergLP::bslma::SharedPtrRep *rep,
6060 ELEMENT_TYPE *target)
6061{
6062 if (d_rep_p) {
6063 d_rep_p->releaseWeakRef();
6064 }
6065
6066 d_ptr_p = target;
6067 d_rep_p = rep;
6068 d_rep_p->acquireWeakRef();
6069}
6070
6071// MANIPULATORS
6072template <class ELEMENT_TYPE>
6073weak_ptr<ELEMENT_TYPE>& weak_ptr<ELEMENT_TYPE>::operator=(
6074 BloombergLP::bslmf::MovableRef<weak_ptr> rhs)
6076{
6077 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
6078 tmp.swap(*this);
6079 return *this;
6080}
6081
6082#if defined(BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES)
6083template <class ELEMENT_TYPE>
6084template <class COMPATIBLE_TYPE>
6085typename enable_if<
6086 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
6087 weak_ptr<ELEMENT_TYPE>&>::type
6088weak_ptr<ELEMENT_TYPE>::operator=(weak_ptr<COMPATIBLE_TYPE>&& rhs)
6090{
6091 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
6092 tmp.swap(*this);
6093 return *this;
6094}
6095#else
6096template <class ELEMENT_TYPE>
6097template <class COMPATIBLE_TYPE>
6098typename enable_if<
6099 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
6100 weak_ptr<ELEMENT_TYPE>&>::type
6101weak_ptr<ELEMENT_TYPE>::operator=(
6102 BloombergLP::bslmf::MovableRef<weak_ptr<COMPATIBLE_TYPE> > rhs)
6104{
6105 weak_ptr tmp(BloombergLP::bslmf::MovableRefUtil::move(rhs));
6106 tmp.swap(*this);
6107 return *this;
6108}
6109#endif
6110
6111template <class ELEMENT_TYPE>
6112weak_ptr<ELEMENT_TYPE>& weak_ptr<ELEMENT_TYPE>::operator=(
6113 const weak_ptr<ELEMENT_TYPE>& rhs)
6115{
6116#if 1
6117 weak_ptr tmp(rhs);
6118 tmp.swap(*this);
6119#else
6120 // needs friendship, or use the cheating util class.
6121 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
6122#endif
6123 return *this;
6124}
6125
6126template <class ELEMENT_TYPE>
6127template <class COMPATIBLE_TYPE>
6128typename enable_if<
6129 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
6130 weak_ptr<ELEMENT_TYPE>&>::type
6131weak_ptr<ELEMENT_TYPE>::operator=(const shared_ptr<COMPATIBLE_TYPE>& rhs)
6133{
6134#if 1
6135 weak_ptr tmp(rhs);
6136 tmp.swap(*this);
6137#else
6138 // needs friendship, or use the cheating util class.
6139 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
6140#endif
6141 return *this;
6142}
6143
6144template <class ELEMENT_TYPE>
6145template <class COMPATIBLE_TYPE>
6146typename enable_if<
6147 is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value,
6148 weak_ptr<ELEMENT_TYPE>&>::type
6149weak_ptr<ELEMENT_TYPE>::operator=(const weak_ptr<COMPATIBLE_TYPE>& rhs)
6151{
6152#if 1
6153 weak_ptr tmp(rhs);
6154 tmp.swap(*this);
6155#else
6156 // needs friendship, or use the cheating util class.
6157 privateAssign(rhs.d_rep_p, rhs.d_ptr_p);
6158#endif
6159 return *this;
6160}
6161
6162template <class ELEMENT_TYPE>
6163inline
6164void weak_ptr<ELEMENT_TYPE>::reset() BSLS_KEYWORD_NOEXCEPT
6165{
6166 if (d_rep_p) {
6167 d_rep_p->releaseWeakRef();
6168 }
6169
6170 d_ptr_p = 0;
6171 d_rep_p = 0;
6172}
6173
6174template <class ELEMENT_TYPE>
6175inline
6176void weak_ptr<ELEMENT_TYPE>::swap(weak_ptr<ELEMENT_TYPE>& other)
6178{
6179 // We directly implement swapping of two pointers, rather than simply
6180 // calling 'bsl::swap' or using 'bslalg::SwapUtil', to avoid (indirectly)
6181 // including the platform <algorithm> header, which may transitively
6182 // include other standard headers. This reduces the risk of
6183 // platform-specific cycles, which have been observed to cause problems.
6184
6185 ELEMENT_TYPE *tempPtr_p = d_ptr_p;
6186 d_ptr_p = other.d_ptr_p;
6187 other.d_ptr_p = tempPtr_p;
6188
6189 BloombergLP::bslma::SharedPtrRep *tempRep_p = d_rep_p;
6190 d_rep_p = other.d_rep_p;
6191 other.d_rep_p = tempRep_p;
6192}
6193
6194// ACCESSORS
6195template <class ELEMENT_TYPE>
6196inline
6197bool weak_ptr<ELEMENT_TYPE>::expired() const BSLS_KEYWORD_NOEXCEPT
6198{
6199 return !(d_rep_p && d_rep_p->numReferences());
6200}
6201
6202template <class ELEMENT_TYPE>
6203shared_ptr<ELEMENT_TYPE> weak_ptr<ELEMENT_TYPE>::lock() const
6205{
6206 if (d_rep_p && d_rep_p->tryAcquireRef()) {
6207 return shared_ptr<ELEMENT_TYPE>(
6208 d_ptr_p,
6209 d_rep_p,
6210 BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr());
6211 // RETURN
6212 }
6213 return shared_ptr<ELEMENT_TYPE>();
6214}
6215
6216template <class ELEMENT_TYPE>
6217template <class ANY_TYPE>
6218inline
6219bool
6220weak_ptr<ELEMENT_TYPE>::owner_before(const shared_ptr<ANY_TYPE>& other) const
6222{
6223 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
6224 other.rep());
6225}
6226
6227template <class ELEMENT_TYPE>
6228template <class ANY_TYPE>
6229inline
6230bool
6231weak_ptr<ELEMENT_TYPE>::owner_before(const weak_ptr<ANY_TYPE>& other) const
6233{
6234 return std::less<BloombergLP::bslma::SharedPtrRep *>()(d_rep_p,
6235 other.d_rep_p);
6236}
6237
6238template <class ELEMENT_TYPE>
6239template<class ANY_TYPE>
6240inline
6241bool
6242weak_ptr<ELEMENT_TYPE>::owner_equal(const shared_ptr<ANY_TYPE>& other)
6244{
6245 return rep() == other.rep();
6246}
6247
6248template <class ELEMENT_TYPE>
6249template<class ANY_TYPE>
6250inline
6251bool
6252weak_ptr<ELEMENT_TYPE>::owner_equal(const weak_ptr<ANY_TYPE>& other) const
6254{
6255 return rep() == other.rep();
6256}
6257
6258template <class ELEMENT_TYPE>
6259inline
6260size_t
6261weak_ptr<ELEMENT_TYPE>::owner_hash() const BSLS_KEYWORD_NOEXCEPT
6262{
6263 return hash<BloombergLP::bslma::SharedPtrRep *>()(rep());
6264}
6265
6266template <class ELEMENT_TYPE>
6267inline
6268BloombergLP::bslma::SharedPtrRep *weak_ptr<ELEMENT_TYPE>::rep() const
6270{
6271 return d_rep_p;
6272}
6273
6274template <class ELEMENT_TYPE>
6275inline
6276long weak_ptr<ELEMENT_TYPE>::use_count() const BSLS_KEYWORD_NOEXCEPT
6277{
6278 return d_rep_p ? d_rep_p->numReferences() : 0;
6279}
6280
6281#ifndef BDE_OMIT_INTERNAL_DEPRECATED
6282// DEPRECATED BDE LEGACY ACCESSORS
6283template <class ELEMENT_TYPE>
6284inline
6285shared_ptr<ELEMENT_TYPE> weak_ptr<ELEMENT_TYPE>::acquireSharedPtr() const
6287{
6288 return lock();
6289}
6290
6291template <class ELEMENT_TYPE>
6292inline
6293int weak_ptr<ELEMENT_TYPE>::numReferences() const BSLS_KEYWORD_NOEXCEPT
6294{
6295 return d_rep_p ? d_rep_p->numReferences() : 0;
6296}
6297#endif // BDE_OMIT_INTERNAL_DEPRECATED
6298
6299} // close namespace bsl
6300
6301
6302namespace bslstl {
6303
6304 // -----------------
6305 // SharedPtr_ImpUtil
6306 // -----------------
6307
6308template <class SHARED_TYPE, class ENABLE_TYPE>
6309inline
6313{
6314 BSLS_ASSERT(0 != sharedPtr);
6315
6316 if (0 != result && result->d_weakThis.expired()) {
6317 result->d_weakThis.privateAssign(
6318 sharedPtr->d_rep_p,
6319 const_cast <ENABLE_TYPE *>(
6320 static_cast<ENABLE_TYPE const*>(sharedPtr->d_ptr_p)));
6321 }
6322}
6323
6324inline
6326 const void *)
6328{
6329}
6330
6331 // --------------------
6332 // struct SharedPtrUtil
6333 // --------------------
6334
6335// CLASS METHODS
6336template <class TARGET, class SOURCE>
6337inline
6339 const bsl::shared_ptr<SOURCE>& source)
6340{
6341 BSLS_ASSERT(0 != target);
6342
6343 target->reset(source, const_cast<TARGET *>(source.get()));
6344}
6345
6346template <class TARGET, class SOURCE>
6347inline
6351{
6352 return bsl::shared_ptr<TARGET>(source,
6353 const_cast<TARGET *>(source.get()));
6354}
6355
6356template <class TARGET, class SOURCE>
6357inline
6359 const bsl::shared_ptr<SOURCE>& source)
6360{
6361 BSLS_ASSERT(0 != target);
6362
6363 if (TARGET *castPtr = dynamic_cast<TARGET *>(source.get())) {
6364 target->reset(source, castPtr);
6365 }
6366 else {
6367 target->reset();
6368 }
6369}
6370
6371template <class TARGET, class SOURCE>
6372inline
6376{
6377 if (TARGET *castPtr = dynamic_cast<TARGET *>(source.get())) {
6378 return bsl::shared_ptr<TARGET>(source, castPtr); // RETURN
6379 }
6380
6381 return bsl::shared_ptr<TARGET>();
6382}
6383
6384template <class TARGET, class SOURCE>
6385inline
6387 const bsl::shared_ptr<SOURCE>& source)
6388{
6389 BSLS_ASSERT(0 != target);
6390
6391 target->reset(source, static_cast<TARGET *>(source.get()));
6392}
6393
6394template <class TARGET, class SOURCE>
6395inline
6399{
6400 return bsl::shared_ptr<TARGET>(source,
6401 static_cast<TARGET *>(source.get()));
6402}
6403
6404 // --------------------------
6405 // struct SharedPtrNilDeleter
6406 // --------------------------
6407
6408// ACCESSORS
6409inline
6410void SharedPtrNilDeleter::operator()(const volatile void *) const
6412{
6413}
6414
6415 // -------------------------------
6416 // struct SharedPtr_DefaultDeleter
6417 // -------------------------------
6418
6419// ACCESSORS
6420template <>
6421template <class ANY_TYPE>
6422inline
6423void SharedPtr_DefaultDeleter<true>::operator()(ANY_TYPE *ptr) const
6425{
6426 delete [] ptr;
6427}
6428
6429template <>
6430template <class ANY_TYPE>
6431inline
6432void SharedPtr_DefaultDeleter<false>::operator()(ANY_TYPE *ptr) const
6434{
6435 delete ptr;
6436}
6437
6438 // --------------------------
6439 // class SharedPtr_RepProctor
6440 // --------------------------
6441
6442// CREATORS
6443inline
6444SharedPtr_RepProctor::SharedPtr_RepProctor(bslma::SharedPtrRep *rep)
6446: d_rep_p(rep)
6447{
6448}
6449
6450inline
6452{
6453 if (d_rep_p) {
6454 d_rep_p->disposeRep();
6455 }
6456}
6457
6458// MANIPULATORS
6459inline
6461{
6462 d_rep_p = 0;
6463}
6464
6465} // close package namespace
6466
6467
6468// FREE OPERATORS
6469template <class LHS_TYPE, class RHS_TYPE>
6470inline
6471bool bsl::operator==(const shared_ptr<LHS_TYPE>& lhs,
6472 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6473{
6474 return lhs.get() == rhs.get();
6475}
6476
6477#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6478
6479template<class LHS_TYPE, class RHS_TYPE>
6480inline
6481bsl::strong_ordering bsl::operator<=>(const shared_ptr<LHS_TYPE>& lhs,
6482 const shared_ptr<RHS_TYPE>& rhs)
6484{
6485 const void *p1 = lhs.get(),
6486 *p2 = rhs.get();
6487 return p1 <=> p2;
6488}
6489
6490#else
6491
6492template <class LHS_TYPE, class RHS_TYPE>
6493inline
6494bool bsl::operator!=(const shared_ptr<LHS_TYPE>& lhs,
6495 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6496{
6497 return !(lhs == rhs);
6498}
6499
6500template <class LHS_TYPE, class RHS_TYPE>
6501inline
6502bool bsl::operator<(const shared_ptr<LHS_TYPE>& lhs,
6503 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6504{
6505 return std::less<const void *>()(lhs.get(), rhs.get());
6506}
6507
6508template <class LHS_TYPE, class RHS_TYPE>
6509inline
6510bool bsl::operator>(const shared_ptr<LHS_TYPE>& lhs,
6511 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6512{
6513 return rhs < lhs;
6514}
6515
6516template <class LHS_TYPE, class RHS_TYPE>
6517inline
6518bool bsl::operator<=(const shared_ptr<LHS_TYPE>& lhs,
6519 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6520{
6521 return !(rhs < lhs);
6522}
6523
6524template <class LHS_TYPE, class RHS_TYPE>
6525inline
6526bool bsl::operator>=(const shared_ptr<LHS_TYPE>& lhs,
6527 const shared_ptr<RHS_TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
6528{
6529 return !(lhs < rhs);
6530}
6531
6532#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6533
6534template <class LHS_TYPE>
6535inline
6536bool bsl::operator==(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6538{
6539 return !lhs;
6540}
6541
6542#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6543
6544template<class TYPE>
6545inline
6546bsl::strong_ordering bsl::operator<=>(const shared_ptr<TYPE>& ptr,
6547 nullptr_t) BSLS_KEYWORD_NOEXCEPT
6548{
6549 const typename shared_ptr<TYPE>::element_type *null = nullptr;
6550 return ptr.get() <=> null;
6551}
6552
6553#else
6554
6555template <class RHS_TYPE>
6556inline
6557bool bsl::operator==(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6559{
6560 return !rhs;
6561}
6562
6563template <class LHS_TYPE>
6564inline
6565bool bsl::operator!=(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6567{
6568 return static_cast<bool>(lhs);
6569}
6570
6571template <class RHS_TYPE>
6572inline
6573bool bsl::operator!=(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6575{
6576 return static_cast<bool>(rhs);
6577}
6578
6579template <class LHS_TYPE>
6580inline
6581bool bsl::operator<(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6583{
6584 return std::less<LHS_TYPE *>()(lhs.get(), 0);
6585}
6586
6587template <class RHS_TYPE>
6588inline
6589bool bsl::operator<(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6591{
6592 return std::less<RHS_TYPE *>()(0, rhs.get());
6593}
6594
6595template <class LHS_TYPE>
6596inline
6597bool bsl::operator<=(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6599{
6600 return !std::less<LHS_TYPE *>()(0, lhs.get());
6601}
6602
6603template <class RHS_TYPE>
6604inline
6605bool bsl::operator<=(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6607{
6608 return !std::less<RHS_TYPE *>()(rhs.get(), 0);
6609}
6610
6611template <class LHS_TYPE>
6612inline
6613bool bsl::operator>(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6615{
6616 return std::less<LHS_TYPE *>()(0, lhs.get());
6617}
6618
6619template <class RHS_TYPE>
6620inline
6621bool bsl::operator>(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6623{
6624 return std::less<RHS_TYPE *>()(rhs.get(), 0);
6625}
6626
6627template <class LHS_TYPE>
6628inline
6629bool bsl::operator>=(const shared_ptr<LHS_TYPE>& lhs, bsl::nullptr_t)
6631{
6632 return !std::less<LHS_TYPE *>()(lhs.get(), 0);
6633}
6634
6635template <class RHS_TYPE>
6636inline
6637bool bsl::operator>=(bsl::nullptr_t, const shared_ptr<RHS_TYPE>& rhs)
6639{
6640 return !std::less<RHS_TYPE *>()(0, rhs.get());
6641}
6642
6643#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6644
6645template <class CHAR_TYPE, class CHAR_TRAITS, class ELEMENT_TYPE>
6646inline
6647std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
6648bsl::operator<<(std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>& stream,
6649 const shared_ptr<ELEMENT_TYPE>& rhs)
6650{
6651 return stream << rhs.get();
6652}
6653
6654// ASPECTS
6655template <class HASHALG, class ELEMENT_TYPE>
6656inline
6657void bsl::hashAppend(HASHALG& hashAlg, const shared_ptr<ELEMENT_TYPE>& input)
6658{
6659 hashAppend(hashAlg, input.get());
6660}
6661
6662template <class ELEMENT_TYPE>
6663inline
6664void bsl::swap(shared_ptr<ELEMENT_TYPE>& a, shared_ptr<ELEMENT_TYPE>& b)
6666{
6667 a.swap(b);
6668}
6669
6670template <class ELEMENT_TYPE>
6671inline
6672void bsl::swap(weak_ptr<ELEMENT_TYPE>& a, weak_ptr<ELEMENT_TYPE>& b)
6674{
6675 a.swap(b);
6676}
6677
6678// STANDARD FREE FUNCTIONS
6679template<class DELETER, class ELEMENT_TYPE>
6680inline
6681DELETER *bsl::get_deleter(const shared_ptr<ELEMENT_TYPE>& p)
6683{
6684 BloombergLP::bslma::SharedPtrRep *rep = p.rep();
6685 return rep ? static_cast<DELETER *>(rep->getDeleter(typeid(DELETER))) : 0;
6686}
6687
6688// STANDARD CAST FUNCTIONS
6689template<class TO_TYPE, class FROM_TYPE>
6690inline
6692bsl::const_pointer_cast(const shared_ptr<FROM_TYPE>& source)
6694{
6695 return shared_ptr<TO_TYPE>(source, const_cast<TO_TYPE *>(source.get()));
6696}
6697
6698template<class TO_TYPE, class FROM_TYPE>
6699inline
6701bsl::dynamic_pointer_cast(const shared_ptr<FROM_TYPE>& source)
6703{
6704 if (TO_TYPE *castPtr = dynamic_cast<TO_TYPE *>(source.get())) {
6705 return shared_ptr<TO_TYPE>(source, castPtr); // RETURN
6706 }
6707
6708 return shared_ptr<TO_TYPE>();
6709}
6710
6711template<class TO_TYPE, class FROM_TYPE>
6712inline
6714bsl::static_pointer_cast(const shared_ptr<FROM_TYPE>& source)
6716{
6717 return shared_ptr<TO_TYPE>(source, static_cast<TO_TYPE *>(source.get()));
6718}
6719
6720template<class TO_TYPE, class FROM_TYPE>
6721inline
6723bsl::reinterpret_pointer_cast(const shared_ptr<FROM_TYPE>& source)
6725{
6726 return shared_ptr<TO_TYPE>(source,
6727 reinterpret_cast<TO_TYPE *>(source.get()));
6728}
6729
6730// STANDARD FACTORY FUNCTIONS
6731
6732 // ===========================
6733 // allocate_shared(ALLOC, ...)
6734 // ===========================
6735
6736#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
6737// {{{ BEGIN GENERATED CODE
6738// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
6739#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
6740#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
6741#endif
6742#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F
6743#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F BSLSTL_SHAREDPTR_VARIADIC_LIMIT
6744#endif
6745
6746#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 0
6747template<class ELEMENT_TYPE, class ALLOC>
6751bsl::allocate_shared(ALLOC basicAllocator)
6752{
6753 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6754
6755 typedef BloombergLP::bslstl::
6756 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6757 Rep *rep_p = Rep::makeRep(basicAllocator);
6758
6759 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6761 basicAllocator,
6762 PtrUtil::unqualify(rep_p->ptr()));
6763 proctor.release();
6764 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6765}
6766#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 0
6767
6768#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 1
6769template<class ELEMENT_TYPE, class ALLOC, class ARGS_01>
6773bsl::allocate_shared(ALLOC basicAllocator,
6774 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
6775{
6776 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6777
6778 typedef BloombergLP::bslstl::
6779 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6780 Rep *rep_p = Rep::makeRep(basicAllocator);
6781
6782 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6784 basicAllocator,
6785 PtrUtil::unqualify(rep_p->ptr()),
6786 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01));
6787 proctor.release();
6788 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6789}
6790#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 1
6791
6792#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 2
6793template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6794 class ARGS_02>
6798bsl::allocate_shared(ALLOC basicAllocator,
6799 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6800 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
6801{
6802 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6803
6804 typedef BloombergLP::bslstl::
6805 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6806 Rep *rep_p = Rep::makeRep(basicAllocator);
6807
6808 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6810 basicAllocator,
6811 PtrUtil::unqualify(rep_p->ptr()),
6812 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6813 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02));
6814 proctor.release();
6815 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6816}
6817#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 2
6818
6819#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 3
6820template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6821 class ARGS_02,
6822 class ARGS_03>
6826bsl::allocate_shared(ALLOC basicAllocator,
6827 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6828 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6829 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
6830{
6831 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6832
6833 typedef BloombergLP::bslstl::
6834 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6835 Rep *rep_p = Rep::makeRep(basicAllocator);
6836
6837 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6839 basicAllocator,
6840 PtrUtil::unqualify(rep_p->ptr()),
6841 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6842 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6843 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03));
6844 proctor.release();
6845 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6846}
6847#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 3
6848
6849#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 4
6850template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6851 class ARGS_02,
6852 class ARGS_03,
6853 class ARGS_04>
6857bsl::allocate_shared(ALLOC basicAllocator,
6858 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6859 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6860 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
6862{
6863 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6864
6865 typedef BloombergLP::bslstl::
6866 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6867 Rep *rep_p = Rep::makeRep(basicAllocator);
6868
6869 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6871 basicAllocator,
6872 PtrUtil::unqualify(rep_p->ptr()),
6873 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6874 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6875 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6876 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04));
6877 proctor.release();
6878 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6879}
6880#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 4
6881
6882#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 5
6883template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6884 class ARGS_02,
6885 class ARGS_03,
6886 class ARGS_04,
6887 class ARGS_05>
6891bsl::allocate_shared(ALLOC basicAllocator,
6892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6893 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6894 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6895 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6896 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
6897{
6898 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6899
6900 typedef BloombergLP::bslstl::
6901 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6902 Rep *rep_p = Rep::makeRep(basicAllocator);
6903
6904 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6906 basicAllocator,
6907 PtrUtil::unqualify(rep_p->ptr()),
6908 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6909 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6910 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6911 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6912 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05));
6913 proctor.release();
6914 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6915}
6916#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 5
6917
6918#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 6
6919template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6920 class ARGS_02,
6921 class ARGS_03,
6922 class ARGS_04,
6923 class ARGS_05,
6924 class ARGS_06>
6928bsl::allocate_shared(ALLOC basicAllocator,
6929 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6930 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6931 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6932 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6933 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6934 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
6935{
6936 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6937
6938 typedef BloombergLP::bslstl::
6939 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6940 Rep *rep_p = Rep::makeRep(basicAllocator);
6941
6942 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6944 basicAllocator,
6945 PtrUtil::unqualify(rep_p->ptr()),
6946 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6947 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6948 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6949 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6950 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
6951 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06));
6952 proctor.release();
6953 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6954}
6955#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 6
6956
6957#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 7
6958template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
6959 class ARGS_02,
6960 class ARGS_03,
6961 class ARGS_04,
6962 class ARGS_05,
6963 class ARGS_06,
6964 class ARGS_07>
6968bsl::allocate_shared(ALLOC basicAllocator,
6969 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6970 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6971 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6972 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6973 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6974 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
6976{
6977 typedef BloombergLP::bslma::PointerUtil PtrUtil;
6978
6979 typedef BloombergLP::bslstl::
6980 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
6981 Rep *rep_p = Rep::makeRep(basicAllocator);
6982
6983 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
6985 basicAllocator,
6986 PtrUtil::unqualify(rep_p->ptr()),
6987 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6988 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6989 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6990 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6991 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
6992 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
6993 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07));
6994 proctor.release();
6995 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
6996}
6997#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 7
6998
6999#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 8
7000template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7001 class ARGS_02,
7002 class ARGS_03,
7003 class ARGS_04,
7004 class ARGS_05,
7005 class ARGS_06,
7006 class ARGS_07,
7007 class ARGS_08>
7011bsl::allocate_shared(ALLOC basicAllocator,
7012 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7013 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7014 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7015 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7016 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7017 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7018 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7019 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
7020{
7021 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7022
7023 typedef BloombergLP::bslstl::
7024 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7025 Rep *rep_p = Rep::makeRep(basicAllocator);
7026
7027 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7029 basicAllocator,
7030 PtrUtil::unqualify(rep_p->ptr()),
7031 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7032 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7033 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7034 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7035 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7036 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7037 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7038 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08));
7039 proctor.release();
7040 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7041}
7042#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 8
7043
7044#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 9
7045template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7046 class ARGS_02,
7047 class ARGS_03,
7048 class ARGS_04,
7049 class ARGS_05,
7050 class ARGS_06,
7051 class ARGS_07,
7052 class ARGS_08,
7053 class ARGS_09>
7057bsl::allocate_shared(ALLOC basicAllocator,
7058 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7059 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7060 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7061 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7062 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7063 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7064 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7065 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7066 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7067{
7068 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7069
7070 typedef BloombergLP::bslstl::
7071 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7072 Rep *rep_p = Rep::makeRep(basicAllocator);
7073
7074 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7076 basicAllocator,
7077 PtrUtil::unqualify(rep_p->ptr()),
7078 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7079 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7080 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7081 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7082 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7083 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7084 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7085 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7086 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09));
7087 proctor.release();
7088 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7089}
7090#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 9
7091
7092#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 10
7093template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7094 class ARGS_02,
7095 class ARGS_03,
7096 class ARGS_04,
7097 class ARGS_05,
7098 class ARGS_06,
7099 class ARGS_07,
7100 class ARGS_08,
7101 class ARGS_09,
7102 class ARGS_10>
7106bsl::allocate_shared(ALLOC basicAllocator,
7107 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7108 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7109 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7110 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7111 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7112 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7113 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7114 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7115 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7116 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
7117{
7118 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7119
7120 typedef BloombergLP::bslstl::
7121 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7122 Rep *rep_p = Rep::makeRep(basicAllocator);
7123
7124 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7126 basicAllocator,
7127 PtrUtil::unqualify(rep_p->ptr()),
7128 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7129 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7130 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7131 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7132 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7133 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7134 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7135 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7136 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7137 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10));
7138 proctor.release();
7139 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7140}
7141#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 10
7142
7143#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 11
7144template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7145 class ARGS_02,
7146 class ARGS_03,
7147 class ARGS_04,
7148 class ARGS_05,
7149 class ARGS_06,
7150 class ARGS_07,
7151 class ARGS_08,
7152 class ARGS_09,
7153 class ARGS_10,
7154 class ARGS_11>
7158bsl::allocate_shared(ALLOC basicAllocator,
7159 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7160 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7161 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7162 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7163 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7164 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7165 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7166 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7167 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7168 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
7169 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11)
7170{
7171 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7172
7173 typedef BloombergLP::bslstl::
7174 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7175 Rep *rep_p = Rep::makeRep(basicAllocator);
7176
7177 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7179 basicAllocator,
7180 PtrUtil::unqualify(rep_p->ptr()),
7181 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7182 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7183 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7184 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7185 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7186 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7187 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7188 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7189 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7190 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
7191 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11));
7192 proctor.release();
7193 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7194}
7195#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 11
7196
7197#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 12
7198template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7199 class ARGS_02,
7200 class ARGS_03,
7201 class ARGS_04,
7202 class ARGS_05,
7203 class ARGS_06,
7204 class ARGS_07,
7205 class ARGS_08,
7206 class ARGS_09,
7207 class ARGS_10,
7208 class ARGS_11,
7209 class ARGS_12>
7213bsl::allocate_shared(ALLOC basicAllocator,
7214 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7215 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7216 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7217 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7218 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7219 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
7224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
7225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12)
7226{
7227 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7228
7229 typedef BloombergLP::bslstl::
7230 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7231 Rep *rep_p = Rep::makeRep(basicAllocator);
7232
7233 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7235 basicAllocator,
7236 PtrUtil::unqualify(rep_p->ptr()),
7237 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7238 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7239 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7240 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7241 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7242 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7243 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7244 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7245 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7246 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
7247 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
7248 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12));
7249 proctor.release();
7250 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7251}
7252#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 12
7253
7254#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 13
7255template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7256 class ARGS_02,
7257 class ARGS_03,
7258 class ARGS_04,
7259 class ARGS_05,
7260 class ARGS_06,
7261 class ARGS_07,
7262 class ARGS_08,
7263 class ARGS_09,
7264 class ARGS_10,
7265 class ARGS_11,
7266 class ARGS_12,
7267 class ARGS_13>
7271bsl::allocate_shared(ALLOC basicAllocator,
7272 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7273 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7275 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7280 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7281 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
7282 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
7283 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
7284 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13)
7285{
7286 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7287
7288 typedef BloombergLP::bslstl::
7289 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7290 Rep *rep_p = Rep::makeRep(basicAllocator);
7291
7292 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7294 basicAllocator,
7295 PtrUtil::unqualify(rep_p->ptr()),
7296 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7297 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7298 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7299 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7300 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7301 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7302 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7303 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7304 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7305 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
7306 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
7307 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
7308 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13));
7309 proctor.release();
7310 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7311}
7312#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 13
7313
7314#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 14
7315template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7316 class ARGS_02,
7317 class ARGS_03,
7318 class ARGS_04,
7319 class ARGS_05,
7320 class ARGS_06,
7321 class ARGS_07,
7322 class ARGS_08,
7323 class ARGS_09,
7324 class ARGS_10,
7325 class ARGS_11,
7326 class ARGS_12,
7327 class ARGS_13,
7328 class ARGS_14>
7332bsl::allocate_shared(ALLOC basicAllocator,
7333 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7334 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7335 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7336 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7337 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7338 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7339 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7340 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7341 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7342 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
7343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
7344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
7345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
7346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14)
7347{
7348 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7349
7350 typedef BloombergLP::bslstl::
7351 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7352 Rep *rep_p = Rep::makeRep(basicAllocator);
7353
7354 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7356 basicAllocator,
7357 PtrUtil::unqualify(rep_p->ptr()),
7358 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7359 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7360 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7361 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7362 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7363 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7364 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7365 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7366 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7367 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
7368 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
7369 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
7370 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13),
7371 BSLS_COMPILERFEATURES_FORWARD(ARGS_14,args_14));
7372 proctor.release();
7373 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7374}
7375#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_F >= 14
7376
7377#else
7378// The generated code below is a workaround for the absence of perfect
7379// forwarding in some compilers.
7380
7381template<class ELEMENT_TYPE, class ALLOC, class... ARGS>
7385bsl::allocate_shared(ALLOC basicAllocator,
7387{
7388 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7389
7390 typedef BloombergLP::bslstl::
7391 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7392 Rep *rep_p = Rep::makeRep(basicAllocator);
7393
7394 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7396 basicAllocator,
7397 PtrUtil::unqualify(rep_p->ptr()),
7398 BSLS_COMPILERFEATURES_FORWARD(ARGS,args)...);
7399 proctor.release();
7400 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7401}
7402// }}} END GENERATED CODE
7403#endif
7404
7405template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
7406inline
7410bsl::allocate_shared(ALLOC basicAllocator)
7411{
7412 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7413 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
7415 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7416 typedef BloombergLP::bslstl::
7417 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7418
7419 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7420 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7421
7422 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7423 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
7424 static_cast<Element_type *> (rep_p->ptr()),
7425 numElements,
7426 ElementAllocatorType(basicAllocator));
7427 proctor.release();
7428
7429 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7430 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7431}
7432
7433template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
7434inline
7439 ALLOC basicAllocator,
7440 const typename bsl::remove_extent<ARRAY_TYPE>::type& value)
7441{
7442 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7443 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
7445 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7446 typedef BloombergLP::bslstl::
7447 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7448
7449 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7450 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7451
7452 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7453 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
7454 static_cast<Element_type *> (rep_p->ptr()),
7455 numElements,
7456 value,
7457 ElementAllocatorType(basicAllocator));
7458 proctor.release();
7459
7460 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7461 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7462}
7463
7464template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
7465inline
7469bsl::allocate_shared(ALLOC basicAllocator, size_t numElements)
7470{
7471 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
7473 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7474 typedef BloombergLP::bslstl::
7475 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7476
7477 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7478
7479 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7480 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
7481 static_cast<Element_type *> (rep_p->ptr()),
7482 numElements,
7483 ElementAllocatorType(basicAllocator));
7484 proctor.release();
7485
7486 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7487 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7488}
7489
7490template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
7491inline
7496 ALLOC basicAllocator,
7497 size_t numElements,
7498 const typename bsl::remove_extent<ARRAY_TYPE>::type& value)
7499{
7500 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
7502 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
7503 typedef BloombergLP::bslstl::
7504 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7505
7506 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7507
7508 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7509 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
7510 static_cast<Element_type *> (rep_p->ptr()),
7511 numElements,
7512 value,
7513 ElementAllocatorType(basicAllocator));
7514 proctor.release();
7515
7516 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7517 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7518}
7519
7520 // =========================================
7521 // allocate_shared_for_overwrite(ALLOC, ...)
7522 // =========================================
7523
7524template<class ELEMENT_TYPE, class ALLOC>
7525inline
7529bsl::allocate_shared_for_overwrite(ALLOC basicAllocator)
7530{
7531 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7532
7533 typedef BloombergLP::bslstl::
7534 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, ALLOC> Rep;
7535 Rep *rep_p = Rep::makeRep(basicAllocator);
7536
7537 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7538 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
7539 proctor.release();
7540
7541 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7542}
7543
7544template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
7545inline
7546typename bsl::enable_if<bsl::is_bounded_array<ARRAY_TYPE>::value &&
7547 !bsl::is_pointer<ALLOC>::value,
7548 bsl::shared_ptr<ARRAY_TYPE> >::type
7549bsl::allocate_shared_for_overwrite(ALLOC basicAllocator)
7550{
7551 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
7552 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7553
7554 typedef BloombergLP::bslstl::
7555 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7556
7557 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
7558 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7559
7560 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7561 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
7562 proctor.release();
7563
7564 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7565 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7566}
7567
7568template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
7569inline
7570typename bsl::enable_if<bsl::is_unbounded_array<ARRAY_TYPE>::value &&
7571 !bsl::is_pointer<ALLOC>::value,
7572 bsl::shared_ptr<ARRAY_TYPE> >::type
7573bsl::allocate_shared_for_overwrite(ALLOC basicAllocator, size_t numElements)
7574{
7575 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
7576 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7577
7578 typedef BloombergLP::bslstl::
7579 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, ALLOC> Rep;
7580
7581 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
7582
7583 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7584 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
7585 proctor.release();
7586
7587 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
7588 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
7589}
7590
7591 // =============================
7592 // allocate_shared(ALLOC *, ...)
7593 // =============================
7594
7595#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
7596// {{{ BEGIN GENERATED CODE
7597// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
7598#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
7599#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
7600#endif
7601#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G
7602#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G BSLSTL_SHAREDPTR_VARIADIC_LIMIT
7603#endif
7604#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 0
7605template<class ELEMENT_TYPE, class ALLOC>
7606inline
7609bsl::allocate_shared(ALLOC *basicAllocator)
7610{
7611 typedef bsl::allocator<char> AllocatorType;
7612 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7613 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7614
7615 typedef BloombergLP::bslstl::
7616 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7617 AllocatorType alloc(basicAllocator);
7618 Rep *rep_p = Rep::makeRep(alloc);
7619
7620 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7621 AllocatorTraits::construct(alloc,
7622 PtrUtil::unqualify(rep_p->ptr()));
7623 proctor.release();
7624 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7625}
7626#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 0
7627
7628#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 1
7629template<class ELEMENT_TYPE, class ALLOC, class ARGS_01>
7630inline
7633bsl::allocate_shared(ALLOC *basicAllocator,
7634 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
7635{
7636 typedef bsl::allocator<char> AllocatorType;
7637 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7638 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7639
7640 typedef BloombergLP::bslstl::
7641 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7642 AllocatorType alloc(basicAllocator);
7643 Rep *rep_p = Rep::makeRep(alloc);
7644
7645 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7646 AllocatorTraits::construct(alloc,
7647 PtrUtil::unqualify(rep_p->ptr()),
7648 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01));
7649 proctor.release();
7650 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7651}
7652#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 1
7653
7654#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 2
7655template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7656 class ARGS_02>
7657inline
7660bsl::allocate_shared(ALLOC *basicAllocator,
7661 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7662 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
7663{
7664 typedef bsl::allocator<char> AllocatorType;
7665 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7666 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7667
7668 typedef BloombergLP::bslstl::
7669 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7670 AllocatorType alloc(basicAllocator);
7671 Rep *rep_p = Rep::makeRep(alloc);
7672
7673 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7674 AllocatorTraits::construct(alloc,
7675 PtrUtil::unqualify(rep_p->ptr()),
7676 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7677 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02));
7678 proctor.release();
7679 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7680}
7681#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 2
7682
7683#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 3
7684template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7685 class ARGS_02,
7686 class ARGS_03>
7687inline
7690bsl::allocate_shared(ALLOC *basicAllocator,
7691 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7692 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7693 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
7694{
7695 typedef bsl::allocator<char> AllocatorType;
7696 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7697 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7698
7699 typedef BloombergLP::bslstl::
7700 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7701 AllocatorType alloc(basicAllocator);
7702 Rep *rep_p = Rep::makeRep(alloc);
7703
7704 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7705 AllocatorTraits::construct(alloc,
7706 PtrUtil::unqualify(rep_p->ptr()),
7707 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7708 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7709 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03));
7710 proctor.release();
7711 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7712}
7713#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 3
7714
7715#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 4
7716template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7717 class ARGS_02,
7718 class ARGS_03,
7719 class ARGS_04>
7720inline
7723bsl::allocate_shared(ALLOC *basicAllocator,
7724 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7725 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7726 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7727 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
7728{
7729 typedef bsl::allocator<char> AllocatorType;
7730 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7731 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7732
7733 typedef BloombergLP::bslstl::
7734 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7735 AllocatorType alloc(basicAllocator);
7736 Rep *rep_p = Rep::makeRep(alloc);
7737
7738 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7739 AllocatorTraits::construct(alloc,
7740 PtrUtil::unqualify(rep_p->ptr()),
7741 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7742 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7743 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7744 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04));
7745 proctor.release();
7746 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7747}
7748#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 4
7749
7750#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 5
7751template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7752 class ARGS_02,
7753 class ARGS_03,
7754 class ARGS_04,
7755 class ARGS_05>
7756inline
7759bsl::allocate_shared(ALLOC *basicAllocator,
7760 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7761 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7762 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7763 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7764 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
7765{
7766 typedef bsl::allocator<char> AllocatorType;
7767 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7768 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7769
7770 typedef BloombergLP::bslstl::
7771 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7772 AllocatorType alloc(basicAllocator);
7773 Rep *rep_p = Rep::makeRep(alloc);
7774
7775 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7776 AllocatorTraits::construct(alloc,
7777 PtrUtil::unqualify(rep_p->ptr()),
7778 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7779 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7780 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7781 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7782 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05));
7783 proctor.release();
7784 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7785}
7786#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 5
7787
7788#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 6
7789template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7790 class ARGS_02,
7791 class ARGS_03,
7792 class ARGS_04,
7793 class ARGS_05,
7794 class ARGS_06>
7795inline
7798bsl::allocate_shared(ALLOC *basicAllocator,
7799 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7800 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7801 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7802 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7803 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7804 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
7805{
7806 typedef bsl::allocator<char> AllocatorType;
7807 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7808 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7809
7810 typedef BloombergLP::bslstl::
7811 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7812 AllocatorType alloc(basicAllocator);
7813 Rep *rep_p = Rep::makeRep(alloc);
7814
7815 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7816 AllocatorTraits::construct(alloc,
7817 PtrUtil::unqualify(rep_p->ptr()),
7818 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7819 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7820 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7821 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7822 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7823 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06));
7824 proctor.release();
7825 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7826}
7827#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 6
7828
7829#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 7
7830template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7831 class ARGS_02,
7832 class ARGS_03,
7833 class ARGS_04,
7834 class ARGS_05,
7835 class ARGS_06,
7836 class ARGS_07>
7837inline
7840bsl::allocate_shared(ALLOC *basicAllocator,
7841 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7842 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7843 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7844 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7845 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7846 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7847 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
7848{
7849 typedef bsl::allocator<char> AllocatorType;
7850 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7851 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7852
7853 typedef BloombergLP::bslstl::
7854 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7855 AllocatorType alloc(basicAllocator);
7856 Rep *rep_p = Rep::makeRep(alloc);
7857
7858 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7859 AllocatorTraits::construct(alloc,
7860 PtrUtil::unqualify(rep_p->ptr()),
7861 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7862 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7863 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7864 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7865 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7866 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7867 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07));
7868 proctor.release();
7869 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7870}
7871#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 7
7872
7873#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 8
7874template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7875 class ARGS_02,
7876 class ARGS_03,
7877 class ARGS_04,
7878 class ARGS_05,
7879 class ARGS_06,
7880 class ARGS_07,
7881 class ARGS_08>
7882inline
7885bsl::allocate_shared(ALLOC *basicAllocator,
7886 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7887 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7888 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7889 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7890 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7891 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7893 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
7894{
7895 typedef bsl::allocator<char> AllocatorType;
7896 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7897 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7898
7899 typedef BloombergLP::bslstl::
7900 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7901 AllocatorType alloc(basicAllocator);
7902 Rep *rep_p = Rep::makeRep(alloc);
7903
7904 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7905 AllocatorTraits::construct(alloc,
7906 PtrUtil::unqualify(rep_p->ptr()),
7907 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7908 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7909 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7910 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7911 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7912 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7913 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7914 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08));
7915 proctor.release();
7916 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7917}
7918#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 8
7919
7920#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 9
7921template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7922 class ARGS_02,
7923 class ARGS_03,
7924 class ARGS_04,
7925 class ARGS_05,
7926 class ARGS_06,
7927 class ARGS_07,
7928 class ARGS_08,
7929 class ARGS_09>
7930inline
7933bsl::allocate_shared(ALLOC *basicAllocator,
7934 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7935 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7936 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7937 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7938 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7939 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7940 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7941 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7942 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7943{
7944 typedef bsl::allocator<char> AllocatorType;
7945 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7946 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7947
7948 typedef BloombergLP::bslstl::
7949 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
7950 AllocatorType alloc(basicAllocator);
7951 Rep *rep_p = Rep::makeRep(alloc);
7952
7953 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
7954 AllocatorTraits::construct(alloc,
7955 PtrUtil::unqualify(rep_p->ptr()),
7956 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7957 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7958 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7959 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7960 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7961 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7962 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7963 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7964 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09));
7965 proctor.release();
7966 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
7967}
7968#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 9
7969
7970#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 10
7971template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
7972 class ARGS_02,
7973 class ARGS_03,
7974 class ARGS_04,
7975 class ARGS_05,
7976 class ARGS_06,
7977 class ARGS_07,
7978 class ARGS_08,
7979 class ARGS_09,
7980 class ARGS_10>
7981inline
7984bsl::allocate_shared(ALLOC *basicAllocator,
7985 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7986 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7987 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7988 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7989 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7990 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7991 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7992 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7993 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7994 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
7995{
7996 typedef bsl::allocator<char> AllocatorType;
7997 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
7998 typedef BloombergLP::bslma::PointerUtil PtrUtil;
7999
8000 typedef BloombergLP::bslstl::
8001 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8002 AllocatorType alloc(basicAllocator);
8003 Rep *rep_p = Rep::makeRep(alloc);
8004
8005 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8006 AllocatorTraits::construct(alloc,
8007 PtrUtil::unqualify(rep_p->ptr()),
8008 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
8009 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
8010 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
8011 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
8012 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
8013 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
8014 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
8015 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
8016 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
8017 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10));
8018 proctor.release();
8019 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8020}
8021#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 10
8022
8023#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 11
8024template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
8025 class ARGS_02,
8026 class ARGS_03,
8027 class ARGS_04,
8028 class ARGS_05,
8029 class ARGS_06,
8030 class ARGS_07,
8031 class ARGS_08,
8032 class ARGS_09,
8033 class ARGS_10,
8034 class ARGS_11>
8035inline
8038bsl::allocate_shared(ALLOC *basicAllocator,
8039 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
8040 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8041 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8042 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8043 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8044 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8045 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8046 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8047 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8048 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8049 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11)
8050{
8051 typedef bsl::allocator<char> AllocatorType;
8052 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
8053 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8054
8055 typedef BloombergLP::bslstl::
8056 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8057 AllocatorType alloc(basicAllocator);
8058 Rep *rep_p = Rep::makeRep(alloc);
8059
8060 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8061 AllocatorTraits::construct(alloc,
8062 PtrUtil::unqualify(rep_p->ptr()),
8063 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
8064 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
8065 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
8066 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
8067 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
8068 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
8069 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
8070 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
8071 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
8072 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
8073 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11));
8074 proctor.release();
8075 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8076}
8077#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 11
8078
8079#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 12
8080template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
8081 class ARGS_02,
8082 class ARGS_03,
8083 class ARGS_04,
8084 class ARGS_05,
8085 class ARGS_06,
8086 class ARGS_07,
8087 class ARGS_08,
8088 class ARGS_09,
8089 class ARGS_10,
8090 class ARGS_11,
8091 class ARGS_12>
8092inline
8095bsl::allocate_shared(ALLOC *basicAllocator,
8096 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
8097 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8098 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8099 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8100 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8101 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8102 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8103 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8104 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8105 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8106 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
8107 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12)
8108{
8109 typedef bsl::allocator<char> AllocatorType;
8110 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
8111 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8112
8113 typedef BloombergLP::bslstl::
8114 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8115 AllocatorType alloc(basicAllocator);
8116 Rep *rep_p = Rep::makeRep(alloc);
8117
8118 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8119 AllocatorTraits::construct(alloc,
8120 PtrUtil::unqualify(rep_p->ptr()),
8121 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
8122 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
8123 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
8124 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
8125 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
8126 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
8127 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
8128 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
8129 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
8130 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
8131 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
8132 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12));
8133 proctor.release();
8134 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8135}
8136#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 12
8137
8138#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 13
8139template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
8140 class ARGS_02,
8141 class ARGS_03,
8142 class ARGS_04,
8143 class ARGS_05,
8144 class ARGS_06,
8145 class ARGS_07,
8146 class ARGS_08,
8147 class ARGS_09,
8148 class ARGS_10,
8149 class ARGS_11,
8150 class ARGS_12,
8151 class ARGS_13>
8152inline
8155bsl::allocate_shared(ALLOC *basicAllocator,
8156 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
8157 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8158 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8159 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8160 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8161 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8162 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8163 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8164 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8165 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8166 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
8167 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
8168 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13)
8169{
8170 typedef bsl::allocator<char> AllocatorType;
8171 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
8172 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8173
8174 typedef BloombergLP::bslstl::
8175 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8176 AllocatorType alloc(basicAllocator);
8177 Rep *rep_p = Rep::makeRep(alloc);
8178
8179 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8180 AllocatorTraits::construct(alloc,
8181 PtrUtil::unqualify(rep_p->ptr()),
8182 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
8183 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
8184 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
8185 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
8186 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
8187 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
8188 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
8189 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
8190 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
8191 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
8192 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
8193 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
8194 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13));
8195 proctor.release();
8196 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8197}
8198#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 13
8199
8200#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 14
8201template<class ELEMENT_TYPE, class ALLOC, class ARGS_01,
8202 class ARGS_02,
8203 class ARGS_03,
8204 class ARGS_04,
8205 class ARGS_05,
8206 class ARGS_06,
8207 class ARGS_07,
8208 class ARGS_08,
8209 class ARGS_09,
8210 class ARGS_10,
8211 class ARGS_11,
8212 class ARGS_12,
8213 class ARGS_13,
8214 class ARGS_14>
8215inline
8218bsl::allocate_shared(ALLOC *basicAllocator,
8219 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
8220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8226 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8227 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8228 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8229 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
8230 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
8231 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
8232 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14)
8233{
8234 typedef bsl::allocator<char> AllocatorType;
8235 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
8236 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8237
8238 typedef BloombergLP::bslstl::
8239 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8240 AllocatorType alloc(basicAllocator);
8241 Rep *rep_p = Rep::makeRep(alloc);
8242
8243 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8244 AllocatorTraits::construct(alloc,
8245 PtrUtil::unqualify(rep_p->ptr()),
8246 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
8247 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
8248 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
8249 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
8250 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
8251 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
8252 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
8253 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
8254 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
8255 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10),
8256 BSLS_COMPILERFEATURES_FORWARD(ARGS_11,args_11),
8257 BSLS_COMPILERFEATURES_FORWARD(ARGS_12,args_12),
8258 BSLS_COMPILERFEATURES_FORWARD(ARGS_13,args_13),
8259 BSLS_COMPILERFEATURES_FORWARD(ARGS_14,args_14));
8260 proctor.release();
8261 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8262}
8263#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_G >= 14
8264
8265#else
8266// The generated code below is a workaround for the absence of perfect
8267// forwarding in some compilers.
8268template<class ELEMENT_TYPE, class ALLOC, class... ARGS>
8269inline
8272bsl::allocate_shared(ALLOC *basicAllocator,
8274{
8275 typedef bsl::allocator<char> AllocatorType;
8276 typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;
8277 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8278
8279 typedef BloombergLP::bslstl::
8280 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8281 AllocatorType alloc(basicAllocator);
8282 Rep *rep_p = Rep::makeRep(alloc);
8283
8284 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8285 AllocatorTraits::construct(alloc,
8286 PtrUtil::unqualify(rep_p->ptr()),
8287 BSLS_COMPILERFEATURES_FORWARD(ARGS,args)...);
8288 proctor.release();
8289 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8290}
8291// }}} END GENERATED CODE
8292#endif
8293
8294template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
8295inline
8298bsl::allocate_shared(ALLOC *basicAllocator)
8299{
8300 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
8301 typedef bsl::allocator<char> AllocatorType;
8302 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
8303 ARRAY_TYPE,
8304 AllocatorType> Rep;
8305
8306 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
8307 AllocatorType alloc(basicAllocator);
8308 Rep *rep_p = Rep::makeRep(alloc, numElements);
8309
8310 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8311 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
8312 numElements,
8313 basicAllocator);
8314 proctor.release();
8315
8316 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8317 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8318}
8319
8320template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
8321inline
8325 ALLOC *basicAllocator,
8326 const typename bsl::remove_extent<ARRAY_TYPE>::type& value)
8327{
8328 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
8329 typedef bsl::allocator<char> AllocatorType;
8330 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
8331 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
8332 ARRAY_TYPE,
8333 AllocatorType> Rep;
8334
8335 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
8336 AllocatorType alloc(basicAllocator);
8337 Rep *rep_p = Rep::makeRep(alloc, numElements);
8338
8339 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8340 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
8341 static_cast<Element_type *> (rep_p->ptr()),
8342 numElements,
8343 value,
8344 basicAllocator);
8345 proctor.release();
8346
8347 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8348 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8349}
8350
8351template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
8352inline
8355bsl::allocate_shared(ALLOC *basicAllocator, size_t numElements)
8356{
8357 typedef bsl::allocator<char> AllocatorType;
8358 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
8359 ARRAY_TYPE,
8360 AllocatorType> Rep;
8361 AllocatorType alloc(basicAllocator);
8362 Rep *rep_p = Rep::makeRep(alloc, numElements);
8363
8364 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8365 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(rep_p->ptr(),
8366 numElements,
8367 basicAllocator);
8368 proctor.release();
8369
8370 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8371 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8372}
8373
8374template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
8375inline
8379 ALLOC *basicAllocator,
8380 size_t numElements,
8381 const typename bsl::remove_extent<ARRAY_TYPE>::type& value)
8382{
8383 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
8384 typedef bsl::allocator<char> AllocatorType;
8385 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
8386 ARRAY_TYPE,
8387 AllocatorType> Rep;
8388 AllocatorType alloc(basicAllocator);
8389 Rep *rep_p = Rep::makeRep(alloc, numElements);
8390
8391 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8392 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
8393 static_cast<Element_type *> (rep_p->ptr()),
8394 numElements,
8395 value,
8396 basicAllocator);
8397 proctor.release();
8398
8399 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8400 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8401}
8402
8403 // ===========================================
8404 // allocate_shared_for_overwrite(ALLOC *, ...)
8405 // ===========================================
8406
8407template<class ELEMENT_TYPE, class ALLOC>
8408inline
8411bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator)
8412{
8413 typedef bsl::allocator<char> AllocatorType;
8414 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8415
8416 typedef BloombergLP::bslstl::
8417 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8418 AllocatorType alloc(basicAllocator);
8419 Rep *rep_p = Rep::makeRep(alloc);
8420
8421 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8422 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
8423 proctor.release();
8424
8425 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8426}
8427
8428
8429template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[N]
8430inline
8431typename bsl::enable_if<bsl::is_bounded_array<ARRAY_TYPE>::value,
8432 bsl::shared_ptr<ARRAY_TYPE> >::type
8433bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator)
8434{
8435 typedef bsl::allocator<char> AllocatorType;
8436 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
8437 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8438
8439 typedef BloombergLP::bslstl::
8440 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
8441
8442 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
8443 AllocatorType alloc(basicAllocator);
8444 Rep *rep_p = Rep::makeRep(alloc, numElements);
8445
8446 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8447 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
8448 proctor.release();
8449
8450 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8451 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8452}
8453
8454template<class ARRAY_TYPE, class ALLOC> // ARRAY_TYPE is T[]
8455inline
8456typename bsl::enable_if<bsl::is_unbounded_array<ARRAY_TYPE>::value,
8457 bsl::shared_ptr<ARRAY_TYPE> >::type
8458bsl::allocate_shared_for_overwrite(ALLOC *basicAllocator, size_t numElements)
8459{
8460 typedef bsl::allocator<char> AllocatorType;
8461 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
8462 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8463
8464 typedef BloombergLP::bslstl::
8465 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
8466 AllocatorType alloc(basicAllocator);
8467 Rep *rep_p = Rep::makeRep(alloc, numElements);
8468
8469 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8470 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
8471 proctor.release();
8472
8473 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
8474 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
8475}
8476
8477 // ================
8478 // make_shared(...)
8479 // ================
8480
8481#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
8482// {{{ BEGIN GENERATED CODE
8483// Command line: sim_cpp11_features.pl bslstl_sharedptr.h
8484#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT
8485#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT 14
8486#endif
8487#ifndef BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H
8488#define BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H BSLSTL_SHAREDPTR_VARIADIC_LIMIT
8489#endif
8490
8491#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 0
8492template<class ELEMENT_TYPE>
8493inline
8497{
8498 typedef bsl::allocator<char> AllocatorType;
8499 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8500
8501 typedef BloombergLP::bslstl::
8502 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8503
8504 AllocatorType basicAllocator;
8505 Rep *rep_p = Rep::makeRep(basicAllocator);
8506
8507 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8508 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8509 );
8510 proctor.release();
8511
8512 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8513}
8514#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 0
8515
8516#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 1
8517template<class ELEMENT_TYPE, class ARGS_01>
8518inline
8522{
8523 typedef bsl::allocator<char> AllocatorType;
8524 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8525
8526 typedef BloombergLP::bslstl::
8527 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8528
8529 AllocatorType basicAllocator;
8530 Rep *rep_p = Rep::makeRep(basicAllocator);
8531
8532 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8533 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8534 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
8535 proctor.release();
8536
8537 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8538}
8539#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 1
8540
8541#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 2
8542template<class ELEMENT_TYPE, class ARGS_01,
8543 class ARGS_02>
8544inline
8548 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
8549{
8550 typedef bsl::allocator<char> AllocatorType;
8551 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8552
8553 typedef BloombergLP::bslstl::
8554 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8555
8556 AllocatorType basicAllocator;
8557 Rep *rep_p = Rep::makeRep(basicAllocator);
8558
8559 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8560 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8561 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8562 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
8563 proctor.release();
8564
8565 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8566}
8567#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 2
8568
8569#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 3
8570template<class ELEMENT_TYPE, class ARGS_01,
8571 class ARGS_02,
8572 class ARGS_03>
8573inline
8577 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8578 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
8579{
8580 typedef bsl::allocator<char> AllocatorType;
8581 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8582
8583 typedef BloombergLP::bslstl::
8584 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8585
8586 AllocatorType basicAllocator;
8587 Rep *rep_p = Rep::makeRep(basicAllocator);
8588
8589 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8590 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8591 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8592 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8593 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
8594 proctor.release();
8595
8596 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8597}
8598#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 3
8599
8600#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 4
8601template<class ELEMENT_TYPE, class ARGS_01,
8602 class ARGS_02,
8603 class ARGS_03,
8604 class ARGS_04>
8605inline
8609 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8610 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8611 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
8612{
8613 typedef bsl::allocator<char> AllocatorType;
8614 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8615
8616 typedef BloombergLP::bslstl::
8617 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8618
8619 AllocatorType basicAllocator;
8620 Rep *rep_p = Rep::makeRep(basicAllocator);
8621
8622 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8623 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8624 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8625 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8626 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8627 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
8628 proctor.release();
8629
8630 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8631}
8632#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 4
8633
8634#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 5
8635template<class ELEMENT_TYPE, class ARGS_01,
8636 class ARGS_02,
8637 class ARGS_03,
8638 class ARGS_04,
8639 class ARGS_05>
8640inline
8644 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8645 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8646 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8647 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
8648{
8649 typedef bsl::allocator<char> AllocatorType;
8650 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8651
8652 typedef BloombergLP::bslstl::
8653 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8654
8655 AllocatorType basicAllocator;
8656 Rep *rep_p = Rep::makeRep(basicAllocator);
8657
8658 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8659 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8660 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8661 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8662 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8663 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8664 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
8665 proctor.release();
8666
8667 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8668}
8669#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 5
8670
8671#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 6
8672template<class ELEMENT_TYPE, class ARGS_01,
8673 class ARGS_02,
8674 class ARGS_03,
8675 class ARGS_04,
8676 class ARGS_05,
8677 class ARGS_06>
8678inline
8682 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8683 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8684 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8685 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8686 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
8687{
8688 typedef bsl::allocator<char> AllocatorType;
8689 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8690
8691 typedef BloombergLP::bslstl::
8692 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8693
8694 AllocatorType basicAllocator;
8695 Rep *rep_p = Rep::makeRep(basicAllocator);
8696
8697 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8698 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8699 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8700 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8701 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8702 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8703 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8704 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
8705 proctor.release();
8706
8707 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8708}
8709#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 6
8710
8711#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 7
8712template<class ELEMENT_TYPE, class ARGS_01,
8713 class ARGS_02,
8714 class ARGS_03,
8715 class ARGS_04,
8716 class ARGS_05,
8717 class ARGS_06,
8718 class ARGS_07>
8719inline
8723 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8724 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8725 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8726 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8727 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8728 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
8729{
8730 typedef bsl::allocator<char> AllocatorType;
8731 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8732
8733 typedef BloombergLP::bslstl::
8734 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8735
8736 AllocatorType basicAllocator;
8737 Rep *rep_p = Rep::makeRep(basicAllocator);
8738
8739 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8740 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8741 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8742 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8743 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8744 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8745 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8746 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8747 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
8748 proctor.release();
8749
8750 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8751}
8752#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 7
8753
8754#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 8
8755template<class ELEMENT_TYPE, class ARGS_01,
8756 class ARGS_02,
8757 class ARGS_03,
8758 class ARGS_04,
8759 class ARGS_05,
8760 class ARGS_06,
8761 class ARGS_07,
8762 class ARGS_08>
8763inline
8767 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8768 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8769 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8770 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8771 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8772 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8773 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
8774{
8775 typedef bsl::allocator<char> AllocatorType;
8776 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8777
8778 typedef BloombergLP::bslstl::
8779 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8780
8781 AllocatorType basicAllocator;
8782 Rep *rep_p = Rep::makeRep(basicAllocator);
8783
8784 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8785 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8786 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8787 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8788 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8789 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8790 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8791 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8792 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8793 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
8794 proctor.release();
8795
8796 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8797}
8798#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 8
8799
8800#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 9
8801template<class ELEMENT_TYPE, class ARGS_01,
8802 class ARGS_02,
8803 class ARGS_03,
8804 class ARGS_04,
8805 class ARGS_05,
8806 class ARGS_06,
8807 class ARGS_07,
8808 class ARGS_08,
8809 class ARGS_09>
8810inline
8814 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8815 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8816 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8817 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8818 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8819 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8820 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8821 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
8822{
8823 typedef bsl::allocator<char> AllocatorType;
8824 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8825
8826 typedef BloombergLP::bslstl::
8827 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8828
8829 AllocatorType basicAllocator;
8830 Rep *rep_p = Rep::makeRep(basicAllocator);
8831
8832 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8833 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8834 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8835 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8836 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8837 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8838 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8839 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8840 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8841 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8842 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
8843 proctor.release();
8844
8845 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8846}
8847#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 9
8848
8849#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 10
8850template<class ELEMENT_TYPE, class ARGS_01,
8851 class ARGS_02,
8852 class ARGS_03,
8853 class ARGS_04,
8854 class ARGS_05,
8855 class ARGS_06,
8856 class ARGS_07,
8857 class ARGS_08,
8858 class ARGS_09,
8859 class ARGS_10>
8860inline
8864 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8865 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8866 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8867 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8868 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8869 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8870 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8871 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8872 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
8873{
8874 typedef bsl::allocator<char> AllocatorType;
8875 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8876
8877 typedef BloombergLP::bslstl::
8878 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8879
8880 AllocatorType basicAllocator;
8881 Rep *rep_p = Rep::makeRep(basicAllocator);
8882
8883 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8884 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8885 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8886 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8887 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8888 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8889 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8890 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8891 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8892 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8893 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
8894 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
8895 proctor.release();
8896
8897 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8898}
8899#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 10
8900
8901#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 11
8902template<class ELEMENT_TYPE, class ARGS_01,
8903 class ARGS_02,
8904 class ARGS_03,
8905 class ARGS_04,
8906 class ARGS_05,
8907 class ARGS_06,
8908 class ARGS_07,
8909 class ARGS_08,
8910 class ARGS_09,
8911 class ARGS_10,
8912 class ARGS_11>
8913inline
8917 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8918 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8919 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8920 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8921 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8922 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8923 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8924 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8925 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8926 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11)
8927{
8928 typedef bsl::allocator<char> AllocatorType;
8929 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8930
8931 typedef BloombergLP::bslstl::
8932 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8933
8934 AllocatorType basicAllocator;
8935 Rep *rep_p = Rep::makeRep(basicAllocator);
8936
8937 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8938 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8939 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8940 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8941 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8942 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8943 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8944 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8945 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8946 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8947 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
8948 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10),
8949 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, args_11));
8950 proctor.release();
8951
8952 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
8953}
8954#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 11
8955
8956#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 12
8957template<class ELEMENT_TYPE, class ARGS_01,
8958 class ARGS_02,
8959 class ARGS_03,
8960 class ARGS_04,
8961 class ARGS_05,
8962 class ARGS_06,
8963 class ARGS_07,
8964 class ARGS_08,
8965 class ARGS_09,
8966 class ARGS_10,
8967 class ARGS_11,
8968 class ARGS_12>
8969inline
8973 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8974 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8976 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8977 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8978 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8979 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8980 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8981 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
8982 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
8983 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12)
8984{
8985 typedef bsl::allocator<char> AllocatorType;
8986 typedef BloombergLP::bslma::PointerUtil PtrUtil;
8987
8988 typedef BloombergLP::bslstl::
8989 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
8990
8991 AllocatorType basicAllocator;
8992 Rep *rep_p = Rep::makeRep(basicAllocator);
8993
8994 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
8995 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
8996 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8997 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8998 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8999 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
9000 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
9001 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
9002 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
9003 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
9004 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
9005 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10),
9006 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, args_11),
9007 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, args_12));
9008 proctor.release();
9009
9010 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
9011}
9012#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 12
9013
9014#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 13
9015template<class ELEMENT_TYPE, class ARGS_01,
9016 class ARGS_02,
9017 class ARGS_03,
9018 class ARGS_04,
9019 class ARGS_05,
9020 class ARGS_06,
9021 class ARGS_07,
9022 class ARGS_08,
9023 class ARGS_09,
9024 class ARGS_10,
9025 class ARGS_11,
9026 class ARGS_12,
9027 class ARGS_13>
9028inline
9032 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
9033 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
9034 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
9035 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
9036 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
9037 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
9038 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
9039 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
9040 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
9041 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
9042 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
9043 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13)
9044{
9045 typedef bsl::allocator<char> AllocatorType;
9046 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9047
9048 typedef BloombergLP::bslstl::
9049 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
9050
9051 AllocatorType basicAllocator;
9052 Rep *rep_p = Rep::makeRep(basicAllocator);
9053
9054 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9055 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
9056 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
9057 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
9058 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
9059 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
9060 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
9061 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
9062 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
9063 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
9064 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
9065 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10),
9066 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, args_11),
9067 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, args_12),
9068 BSLS_COMPILERFEATURES_FORWARD(ARGS_13, args_13));
9069 proctor.release();
9070
9071 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
9072}
9073#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 13
9074
9075#if BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 14
9076template<class ELEMENT_TYPE, class ARGS_01,
9077 class ARGS_02,
9078 class ARGS_03,
9079 class ARGS_04,
9080 class ARGS_05,
9081 class ARGS_06,
9082 class ARGS_07,
9083 class ARGS_08,
9084 class ARGS_09,
9085 class ARGS_10,
9086 class ARGS_11,
9087 class ARGS_12,
9088 class ARGS_13,
9089 class ARGS_14>
9090inline
9094 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
9095 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
9096 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
9097 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
9098 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
9099 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
9100 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
9101 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
9102 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10,
9103 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_11) args_11,
9104 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_12) args_12,
9105 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_13) args_13,
9106 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_14) args_14)
9107{
9108 typedef bsl::allocator<char> AllocatorType;
9109 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9110
9111 typedef BloombergLP::bslstl::
9112 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
9113
9114 AllocatorType basicAllocator;
9115 Rep *rep_p = Rep::makeRep(basicAllocator);
9116
9117 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9118 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
9119 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
9120 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
9121 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
9122 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
9123 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
9124 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
9125 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
9126 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
9127 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
9128 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10),
9129 BSLS_COMPILERFEATURES_FORWARD(ARGS_11, args_11),
9130 BSLS_COMPILERFEATURES_FORWARD(ARGS_12, args_12),
9131 BSLS_COMPILERFEATURES_FORWARD(ARGS_13, args_13),
9132 BSLS_COMPILERFEATURES_FORWARD(ARGS_14, args_14));
9133 proctor.release();
9134
9135 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
9136}
9137#endif // BSLSTL_SHAREDPTR_VARIADIC_LIMIT_H >= 14
9138
9139#else
9140// The generated code below is a workaround for the absence of perfect
9141// forwarding in some compilers.
9142
9143template<class ELEMENT_TYPE, class... ARGS>
9144inline
9148{
9149 typedef bsl::allocator<char> AllocatorType;
9150 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9151
9152 typedef BloombergLP::bslstl::
9153 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
9154
9155 AllocatorType basicAllocator;
9156 Rep *rep_p = Rep::makeRep(basicAllocator);
9157
9158 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9159 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE(
9160 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
9161 proctor.release();
9162
9163 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
9164}
9165// }}} END GENERATED CODE
9166#endif
9167
9168template<class ARRAY_TYPE> // ARRAY_TYPE is T[N]
9169inline
9173{
9174 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
9175 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
9176 typedef bsl::allocator<char> AllocatorType;
9178 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
9179 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
9180 ARRAY_TYPE,
9181 AllocatorType> Rep;
9182
9183 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
9184 AllocatorType basicAllocator;
9185 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9186
9187 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9188 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
9189 rep_p->ptr(),
9190 numElements,
9191 ElementAllocatorType(basicAllocator));
9192 proctor.release();
9193
9194 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9195 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9196}
9197
9198template<class ARRAY_TYPE> // ARRAY_TYPE is T[N]
9199inline
9203{
9204 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
9205 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
9206 typedef bsl::allocator<char> AllocatorType;
9208 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
9209 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
9210 ARRAY_TYPE,
9211 AllocatorType> Rep;
9212
9213 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
9214 AllocatorType basicAllocator;
9215 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9216
9217 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9218 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
9219 rep_p->ptr(),
9220 numElements,
9221 value,
9222 ElementAllocatorType(basicAllocator));
9223 proctor.release();
9224
9225 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9226 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9227}
9228
9229template<class ARRAY_TYPE> // ARRAY_TYPE is T[]
9230inline
9233bsl::make_shared(size_t numElements)
9234{
9235 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
9236 typedef bsl::allocator<char> AllocatorType;
9238 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
9239 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
9240 ARRAY_TYPE,
9241 AllocatorType> Rep;
9242
9243 AllocatorType basicAllocator;
9244 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9245
9246 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9247 BloombergLP::bslalg::ArrayPrimitives::defaultConstruct(
9248 rep_p->ptr(),
9249 numElements,
9250 ElementAllocatorType(basicAllocator));
9251 proctor.release();
9252
9253 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9254 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9255}
9256
9257template<class ARRAY_TYPE> // ARRAY_TYPE is T[]
9258inline
9262 size_t numElements,
9263 const typename bsl::remove_extent<ARRAY_TYPE>::type& value)
9264{
9265 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
9266 typedef bsl::allocator<char> AllocatorType;
9268 rebind_traits<Element_type>::allocator_type ElementAllocatorType;
9269 typedef BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep<
9270 ARRAY_TYPE,
9271 AllocatorType> Rep;
9272
9273 AllocatorType basicAllocator;
9274 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9275
9276 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9277 BloombergLP::bslalg::ArrayPrimitives::uninitializedFillN(
9278 rep_p->ptr(),
9279 numElements,
9280 value,
9281 ElementAllocatorType(basicAllocator));
9282 proctor.release();
9283
9284 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9285 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9286}
9287
9288 // ==============================
9289 // make_shared_for_overwrite(...)
9290 // ==============================
9291
9292template<class ELEMENT_TYPE>
9293inline
9297{
9298 typedef bsl::allocator<char> AllocatorType;
9299 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9300
9301 typedef BloombergLP::bslstl::
9302 SharedPtrAllocateInplaceRep<ELEMENT_TYPE, AllocatorType> Rep;
9303
9304 AllocatorType basicAllocator;
9305 Rep *rep_p = Rep::makeRep(basicAllocator);
9306
9307 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9308 ::new (PtrUtil::voidify(rep_p->ptr())) ELEMENT_TYPE;
9309 proctor.release();
9310
9311 return shared_ptr<ELEMENT_TYPE>(rep_p->ptr(), rep_p);
9312}
9313
9314template<class ARRAY_TYPE> // ARRAY_TYPE is T[N]
9315inline
9316typename bsl::enable_if<bsl::is_bounded_array<ARRAY_TYPE>::value,
9317 bsl::shared_ptr<ARRAY_TYPE> >::type
9318bsl::make_shared_for_overwrite()
9319{
9320 typedef bsl::allocator<char> AllocatorType;
9321 typedef BloombergLP::bslstl::SharedPtr_ImpUtil ImpUtil;
9322 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9323
9324 typedef BloombergLP::bslstl::
9325 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
9326
9327 const size_t numElements = ImpUtil::Extent<ARRAY_TYPE>::value;
9328 AllocatorType basicAllocator;
9329 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9330
9331 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9332 ::new (PtrUtil::voidify(rep_p->ptr())) ARRAY_TYPE;
9333
9334 proctor.release();
9335
9336 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9337 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9338}
9339
9340template<class ARRAY_TYPE> // ARRAY_TYPE is T[]
9341inline
9342typename bsl::enable_if<bsl::is_unbounded_array<ARRAY_TYPE>::value,
9343 bsl::shared_ptr<ARRAY_TYPE> >::type
9344bsl::make_shared_for_overwrite(size_t numElements)
9345{
9346 typedef bsl::allocator<char> AllocatorType;
9347 typedef typename bsl::remove_extent<ARRAY_TYPE>::type Element_type;
9348 typedef BloombergLP::bslma::PointerUtil PtrUtil;
9349
9350 typedef BloombergLP::bslstl::
9351 SharedPtrArrayAllocateInplaceRep<ARRAY_TYPE, AllocatorType> Rep;
9352
9353 AllocatorType basicAllocator;
9354 Rep *rep_p = Rep::makeRep(basicAllocator, numElements);
9355
9356 BloombergLP::bslstl::SharedPtr_RepProctor proctor(rep_p);
9357 ::new (PtrUtil::voidify(rep_p->ptr())) Element_type[numElements];
9358
9359 proctor.release();
9360
9361 BloombergLP::bslma::SharedPtrRep *upcastRep = rep_p;
9362 return shared_ptr<ARRAY_TYPE>(rep_p->ptr(), upcastRep);
9363}
9364
9365// ============================================================================
9366// TYPE TRAITS
9367// ============================================================================
9368
9369// Type traits for smart pointers:
9370//: o 'shared_ptr' has pointer semantics, but 'weak_ptr' does not.
9371//:
9372//: o Although 'shared_ptr' constructs with an allocator, it does not 'use' an
9373//: allocator in the manner of the 'UsesBslmaAllocator' trait, and should be
9374//: explicitly specialized as a clear sign to code inspection tools.
9375//:
9376//: o Smart pointers are bitwise-movable as long as there is no opportunity for
9377//: holding a pointer to internal state in the immediate object itself. As
9378//: 'd_ptr_p' is never exposed by reference, it is not possible to create an
9379//: internal pointer, so the trait should be 'true'.
9380
9381
9382
9383namespace bslma {
9384
9385template <class ELEMENT_TYPE>
9386struct UsesBslmaAllocator< ::bsl::shared_ptr<ELEMENT_TYPE> >
9388{};
9389
9390} // close namespace bslma
9391
9392namespace bslmf {
9393
9394template <class ELEMENT_TYPE>
9395struct HasPointerSemantics< ::bsl::shared_ptr<ELEMENT_TYPE> >
9397{};
9398
9399template <class ELEMENT_TYPE>
9400struct IsBitwiseMoveable< ::bsl::shared_ptr<ELEMENT_TYPE> >
9402{};
9403
9404template <class ELEMENT_TYPE>
9405struct IsBitwiseMoveable< ::bsl::weak_ptr<ELEMENT_TYPE> >
9407{};
9408
9409} // close namespace bslmf
9410
9411
9412
9413#if defined(BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC)
9414# pragma GCC diagnostic pop
9415#endif
9416
9417#undef BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE
9418#undef BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE
9419
9420#undef BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE
9421#undef BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE
9422
9423#undef BSLSTL_SHAREDPTR_DECLARE_IF_DELETER
9424#undef BSLSTL_SHAREDPTR_DEFINE_IF_DELETER
9425
9426#undef BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER
9427#undef BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER
9428
9429#undef BSLSTL_SHAREDPTR_MSVC_DECLTYPE_WORKAROUND
9430
9431#undef BSLSTL_SHAREDPTR_SFINAE_DISCARD
9432
9433#else // if ! defined(DEFINED_BSLSTL_SHAREDPTR_H)
9434# error Not valid except when included from bslstl_sharedptr.h
9435#endif // ! defined(COMPILING_BSLSTL_SHAREDPTR_H)
9436
9437#endif // ! defined(INCLUDED_BSLSTL_SHAREDPTR_CPP03)
9438
9439// ----------------------------------------------------------------------------
9440// Copyright 2023 Bloomberg Finance L.P.
9441//
9442// Licensed under the Apache License, Version 2.0 (the "License");
9443// you may not use this file except in compliance with the License.
9444// You may obtain a copy of the License at
9445//
9446// http://www.apache.org/licenses/LICENSE-2.0
9447//
9448// Unless required by applicable law or agreed to in writing, software
9449// distributed under the License is distributed on an "AS IS" BASIS,
9450// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9451// See the License for the specific language governing permissions and
9452// limitations under the License.
9453// ----------------------------- END-OF-FILE ----------------------------------
9454
9455/** @} */
9456/** @} */
9457/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
Definition bslma_bslallocator.h:588
Definition bslstl_sharedptr.h:4073
bsl::weak_ptr< ELEMENT_TYPE > weak_from_this() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:4781
bsl::shared_ptr< ELEMENT_TYPE > shared_from_this()
Definition bslstl_sharedptr.h:4765
enable_shared_from_this() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:4730
friend struct BloombergLP::bslstl::SharedPtr_ImpUtil
Definition bslstl_sharedptr.h:4079
Definition bslstl_sharedptr.h:1838
BloombergLP::bslma::SharedPtrRep * rep() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5761
element_type * ptr() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5779
shared_ptr & operator=(const shared_ptr &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5327
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5449
size_t owner_hash() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5721
long use_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5735
weak_ptr< ELEMENT_TYPE > weak_type
Definition bslstl_sharedptr.h:1854
pair< element_type *, BloombergLP::bslma::SharedPtrRep * > release() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5583
void load(COMPATIBLE_TYPE *ptr)
Definition bslstl_sharedptr.h:5604
friend class shared_ptr
Definition bslstl_sharedptr.h:1875
friend struct BloombergLP::bslstl::SharedPtr_ImpUtil
Definition bslstl_sharedptr.h:1877
element_type * get() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5665
bsl::remove_extent< ELEMENT_TYPE >::type element_type
Definition bslstl_sharedptr.h:1850
BloombergLP::bslma::ManagedPtr< ELEMENT_TYPE > managedPtr() const
Definition bslstl_sharedptr.h:5743
void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5596
void loadAlias(const shared_ptr< ANY_TYPE > &source, ELEMENT_TYPE *object)
Definition bslstl_sharedptr.h:5570
~shared_ptr()
Definition bslstl_sharedptr.h:5317
int numReferences() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5771
void createInplace()
Definition bslstl_sharedptr.h:5539
bool owner_before(const shared_ptr< ANY_TYPE > &other) const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5683
Definition bslstl_sharedptr.h:3773
shared_ptr< ELEMENT_TYPE > lock() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6031
friend class weak_ptr
Definition bslstl_sharedptr.h:3798
~weak_ptr()
Definition bslstl_sharedptr.h:5876
size_t owner_hash() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6089
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5992
bool owner_before(const shared_ptr< ANY_TYPE > &other) const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6048
long use_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6104
BloombergLP::bslma::SharedPtrRep * rep() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6096
shared_ptr< ELEMENT_TYPE > acquireSharedPtr() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6113
bsl::remove_extent< ELEMENT_TYPE >::type element_type
Definition bslstl_sharedptr.h:3812
friend struct BloombergLP::bslstl::SharedPtr_ImpUtil
Definition bslstl_sharedptr.h:3800
int numReferences() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6121
weak_ptr & operator=(BloombergLP::bslmf::MovableRef< weak_ptr > rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5901
bool expired() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6025
Definition bslma_allocator.h:545
Definition bslma_sharedptrrep.h:338
void releaseWeakRef()
Definition bslma_sharedptrrep.h:588
virtual void disposeRep()=0
int numReferences() const
Definition bslma_sharedptrrep.h:611
void acquireRef()
Definition bslma_sharedptrrep.h:568
void release() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:6288
~SharedPtr_RepProctor()
Definition bslstl_sharedptr.h:6279
static const t_TYPE value
Definition bslmf_integralconstant.h:267
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_DEPRECATE_FEATURE(UOR, FEATURE, MESSAGE)
Definition bsls_deprecatefeature.h:387
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:624
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLSTL_SHAREDPTR_DEFINE_IF_DELETER(FUNCTOR, ARGUMENT)
Definition bslstl_sharedptr.h:1714
#define BSLSTL_SHAREDPTR_DECLARE_IF_NULLPTR_DELETER(FUNCTOR)
Definition bslstl_sharedptr.h:1716
#define BSLSTL_SHAREDPTR_DEFINE_IF_NULLPTR_DELETER(FUNCTOR)
Definition bslstl_sharedptr.h:1717
#define BSLSTL_SHAREDPTR_DEFINE_IF_COMPATIBLE
Definition bslstl_sharedptr.h:1711
#define BSLSTL_SHAREDPTR_DEFINE_IF_CONVERTIBLE
Definition bslstl_sharedptr.h:1708
#define BSLSTL_SHAREDPTR_DECLARE_IF_CONVERTIBLE
Definition bslstl_sharedptr.h:1707
#define BSLSTL_SHAREDPTR_DECLARE_IF_DELETER(FUNCTOR, ARGUMENT)
Definition bslstl_sharedptr.h:1713
#define BSLSTL_SHAREDPTR_DECLARE_IF_COMPATIBLE
Definition bslstl_sharedptr.h:1710
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
bool operator<(const MetricId &lhs, const MetricId &rhs)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
bool operator>=(const Guid &lhs, const Guid &rhs)
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const BigEndianInt16 &object)
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
Definition bdlat_valuetypefunctions.h:939
BloombergLP::bsls::Nullptr_Impl::Type nullptr_t
Definition bsls_nullptr.h:283
enable_if< is_bounded_array< ARRAY_TYPE >::value, shared_ptr< ARRAY_TYPE > >::type make_shared()
shared_ptr< TO_TYPE > const_pointer_cast(const shared_ptr< FROM_TYPE > &source) BSLS_KEYWORD_NOEXCEPT
shared_ptr< TO_TYPE > dynamic_pointer_cast(const shared_ptr< FROM_TYPE > &source) BSLS_KEYWORD_NOEXCEPT
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
bool operator<(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition bslstl_array.h:959
bool operator>(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
BSLS_KEYWORD_CONSTEXPR_CPP14 TYPE & get(array< TYPE, SIZE > &a) BSLS_KEYWORD_NOEXCEPT
DELETER * get_deleter(const shared_ptr< ELEMENT_TYPE > &p) BSLS_KEYWORD_NOEXCEPT
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
shared_ptr< TO_TYPE > reinterpret_pointer_cast(const shared_ptr< FROM_TYPE > &source) BSLS_KEYWORD_NOEXCEPT
shared_ptr< TO_TYPE > static_pointer_cast(const shared_ptr< FROM_TYPE > &source) BSLS_KEYWORD_NOEXCEPT
enable_if<!is_array< ELEMENT_TYPE >::value &&!is_pointer< ALLOC >::value, shared_ptr< ELEMENT_TYPE > >::type allocate_shared(ALLOC basicAllocator, ARGS &&... args)
bool operator==(const memory_resource &a, const memory_resource &b)
std::basic_ostream< CHAR_TYPE, TRAITS > & operator<<(std::basic_ostream< CHAR_TYPE, TRAITS > &os, const bitset< N > &x)
Definition bslstl_bitset.h:1417
enable_if<!is_array< ELEMENT_TYPE >::value, shared_ptr< ELEMENT_TYPE > >::type make_shared_for_overwrite()
ALLOCATOR & lhs
Definition bslstl_string.h:3917
bool operator!=(const memory_resource &a, const memory_resource &b)
enable_if<!is_array< ELEMENT_TYPE >::value &&!is_pointer< ALLOC >::value, shared_ptr< ELEMENT_TYPE > >::type allocate_shared_for_overwrite(ALLOC basicAllocator)
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
Definition bslstl_algorithm.h:84
BloombergLP::bslmf::AddPointer_Impl< t_TYPE >::type type
Definition bslmf_addpointer.h:181
Definition bslma_allocatortraits.h:1089
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1527
Definition bslmf_conditional.h:123
Definition bslmf_enableif.h:530
Definition bslmf_integralconstant.h:261
Definition bslmf_isarray.h:168
Definition bslmf_isconvertible.h:875
Definition bslmf_isnothrowmoveconstructible.h:361
Definition bslmf_ispointer.h:138
t_TYPE type
Definition bslmf_removeextent.h:134
void operator()(const volatile void *) const BSLS_KEYWORD_NOEXCEPT
No-Op.
Definition bslstl_sharedptr.h:6238
static void staticCast(bsl::shared_ptr< TARGET > *target, const bsl::shared_ptr< SOURCE > &source)
Definition bslstl_sharedptr.h:6214
static void constCast(bsl::shared_ptr< TARGET > *target, const bsl::shared_ptr< SOURCE > &source)
Definition bslstl_sharedptr.h:6166
static void dynamicCast(bsl::shared_ptr< TARGET > *target, const bsl::shared_ptr< SOURCE > &source)
Definition bslstl_sharedptr.h:6186
void operator()(ANY_TYPE *ptr) const BSLS_KEYWORD_NOEXCEPT
Call delete with the specified ptr.
static void loadEnableSharedFromThis(const bsl::enable_shared_from_this< ENABLE_TYPE > *result, bsl::shared_ptr< SHARED_TYPE > *sharedPtr)
Definition bslstl_sharedptr.h:6138