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