BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslalg_constructorproxy.h
Go to the documentation of this file.
1/// @file bslalg_constructorproxy.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslalg_constructorproxy.h -*-C++-*-
8#ifndef INCLUDED_BSLALG_CONSTRUCTORPROXY
9#define INCLUDED_BSLALG_CONSTRUCTORPROXY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslalg_constructorproxy bslalg_constructorproxy
15/// @brief Provide a proxy for constructing and destroying objects.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslalg
19/// @{
20/// @addtogroup bslalg_constructorproxy
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslalg_constructorproxy-purpose"> Purpose</a>
25/// * <a href="#bslalg_constructorproxy-classes"> Classes </a>
26/// * <a href="#bslalg_constructorproxy-description"> Description </a>
27/// * <a href="#bslalg_constructorproxy-usage"> Usage </a>
28/// * <a href="#bslalg_constructorproxy-example-1-conditionally-pass-an-allocator-to-a-template-member-ctor"> Example 1: Conditionally pass an allocator to a template member ctor </a>
29///
30/// # Purpose {#bslalg_constructorproxy-purpose}
31/// Provide a proxy for constructing and destroying objects.
32///
33/// # Classes {#bslalg_constructorproxy-classes}
34///
35/// - bslalg::ConstructorProxy: proxy for constructing and destroying objects
36///
37/// @see bslma_allocator
38///
39/// # Description {#bslalg_constructorproxy-description}
40/// This component provides a proxy class template,
41/// `bslalg::ConstructorProxy`, for creating a proxied object of parameter type
42/// `OBJECT_TYPE` using a uniform constructor syntax, regardless of whether
43/// `OBJECT_TYPE` is allocator-aware (AA) -- i.e., uses an allocator to supply
44/// memory. This proxy is useful in generic programming situations where an
45/// object of a given type must be constructed, but it is not known in advance
46/// which allocator model the object supports, if any. In these situations,
47/// client code unconditionally passes an allocator as the last argument to the
48/// `ConstructorProxy` constructor; the constructor forwards the allocator to
49/// the proxied object if `OBJECT_TYPE` is AA and discards it otherwise.
50///
51/// The proxied object is owned by the `ConstructorProxy` object. Modifiable
52/// and non-modifiable access to the proxied object may be obtained using the
53/// overloaded `object` methods. When the proxy is destroyed, it automatically
54/// destroys its proxied object.
55///
56/// See the `bslma` package-level documentation for more information about using
57/// allocators.
58///
59/// ## Usage {#bslalg_constructorproxy-usage}
60///
61///
62/// ### Example 1: Conditionally pass an allocator to a template member ctor {#bslalg_constructorproxy-example-1-conditionally-pass-an-allocator-to-a-template-member-ctor}
63///
64///
65/// In this example, we create a key-value class template consisting of a
66/// string key paired with a value of template-parameter type. Since the value
67/// type might be allocator aware (AA), we want to ensure that our key-value
68/// class template can pass an allocator to its value-type constructor.
69///
70/// First, we define a simple AA string class that will be our value type for
71/// testing:
72/// @code
73/// #include <bslma_bslallocator.h>
74/// #include <bslma_allocatorutil.h>
75/// #include <cstring>
76///
77/// // Basic allocator-aware string class.
78/// class String {
79///
80/// // DATA
81/// bsl::allocator<char> d_allocator;
82/// std::size_t d_length;
83/// char *d_data;
84///
85/// public:
86/// // TYPES
87/// typedef bsl::allocator<char> allocator_type;
88///
89/// // CREATORS
90/// String(const char *str = "",
91/// const allocator_type& a = allocator_type()); // IMPLICIT
92/// String(const String& original,
93/// const allocator_type& a = allocator_type());
94/// ~String();
95///
96/// // MANIPULATORS
97/// String& operator=(const String& rhs);
98///
99/// // ACCESSORS
100/// const char* c_str() const { return d_data; }
101/// allocator_type get_allocator() const { return d_allocator; }
102/// std::size_t size() const { return d_length; }
103/// };
104///
105/// // FREE FUNCTIONS
106/// bool operator==(const String& a, const String& b);
107/// bool operator!=(const String& a, const String& b);
108/// @endcode
109/// Next, we define the constructors, destructor, and equality-comparison
110/// operators. For brevity, we've omitted the implementation of the assignment
111/// operator, which is not used in this example:
112/// @code
113/// String::String(const char *str, const allocator_type& a)
114/// : d_allocator(a), d_length(std::strlen(str))
115/// {
116/// d_data = static_cast<char *>(
117/// bslma::AllocatorUtil::allocateBytes(a, d_length + 1));
118/// std::memcpy(d_data, str, d_length + 1);
119/// }
120///
121/// String::String(const String& original, const allocator_type& a)
122/// : d_allocator(a), d_length(original.d_length)
123/// {
124/// d_data = static_cast<char *>(
125/// bslma::AllocatorUtil::allocateBytes(a, d_length + 1));
126/// std::memcpy(d_data, original.c_str(), d_length);
127/// d_data[d_length] = '\0';
128/// }
129///
130/// String::~String()
131/// {
132/// bslma::AllocatorUtil::deallocateBytes(d_allocator, d_data, d_length+1);
133/// }
134///
135/// bool operator==(const String& a, const String& b)
136/// {
137/// return (a.size() == b.size() &&
138/// 0 == std::memcmp(a.c_str(), b.c_str(), a.size()));
139/// }
140///
141/// bool operator!=(const String& a, const String& b)
142/// {
143/// return ! (a == b);
144/// }
145/// @endcode
146/// Now we are ready to define our key-value template. The data portion of the
147/// template needs a member for the key and one for the value. Rather than
148/// defining the value member as simply a member variable of `TYPE`, we use
149/// `bslalg::ConstructorProxy` to ensure that we will be able to construct it in
150/// a uniform way even though we do not know whether or not it is
151/// allocator-aware:
152/// @code
153/// #include <bslalg_constructorproxy.h>
154///
155/// /// Key-value pair with string key and arbitrary value type.
156/// template <class TYPE>
157/// class KeyValue {
158///
159/// // DATA
160/// String d_key;
161/// bslalg::ConstructorProxy<TYPE> d_valueProxy;
162/// @endcode
163/// Next, we declare the creators and manipulators typical of an AA attribute
164/// class:
165/// @code
166/// public:
167/// typedef bsl::allocator<> allocator_type;
168///
169/// // CREATORS
170/// KeyValue(const String& k,
171/// const TYPE& v,
172/// const allocator_type& a = allocator_type());
173/// KeyValue(const KeyValue& original,
174/// const allocator_type& a = allocator_type());
175/// ~KeyValue();
176///
177/// // MANIPULATORS
178/// KeyValue& operator=(const KeyValue& rhs);
179/// @endcode
180/// Next, we declare the accessors and, for convenience in this example, define
181/// them inline. Note that the `value` accessor extracts the proxied object
182/// from the `d_valueProxy` member:
183/// @code
184/// // ACCESSORS
185/// allocator_type get_allocator() const { return d_key.get_allocator(); }
186/// const String& key() const { return d_key; }
187/// const TYPE& value() const { return d_valueProxy.object(); }
188/// };
189/// @endcode
190/// Next, we define the value constructor, which passes its allocator argument
191/// to both data members' constructors. Note that the `d_valueProxy`,
192/// constructor always expects an allocator argument, even if `TYPE` is not AA:
193/// @code
194/// template <class TYPE>
195/// KeyValue<TYPE>::KeyValue(const String& k,
196/// const TYPE& v,
197/// const allocator_type& a)
198/// : d_key(k, a), d_valueProxy(v, a)
199/// {
200/// }
201/// @endcode
202/// Next, we define the copy constructor and assignment operator. Since
203/// `bslalg::ConstructorProxy` is not copyable, we must manually extract the
204/// proxied object in the assignment operator. This extraction is not needed in
205/// the copy constructor because the single-value proxy constructor
206/// automatically "unwraps" its argument when presented with an instantiation of
207/// `bslalg::ConstructorProxy`:
208/// @code
209/// template <class TYPE>
210/// KeyValue<TYPE>::KeyValue(const KeyValue& original,
211/// const allocator_type& a)
212/// : d_key(original.d_key, a)
213/// , d_valueProxy(original.d_valueProxy, a) // Automatically unwrapped
214/// {
215/// }
216///
217/// template <class TYPE>
218/// KeyValue<TYPE>& KeyValue<TYPE>::operator=(const KeyValue& rhs)
219/// {
220/// d_key = rhs.d_key;
221/// d_valueProxy.object() = rhs.d_valueProxy.object();
222/// return *this;
223/// }
224/// @endcode
225/// Last, we define the destructor, which does nothing explicit (and could
226/// therefore have been defaulted), because both `String` and `ConstructorProxy`
227/// clean up after themselves:
228/// @code
229/// template <class TYPE>
230/// KeyValue<TYPE>::~KeyValue()
231/// {
232/// }
233/// @endcode
234/// Now we can illustrate the use of our key-value pair by defining a string-int
235/// pair and constructing it with a test allocator. Note that the allocator was
236/// passed to the (`String`) key, as we would expect:
237/// @code
238/// #include <bslma_testallocator.h>
239///
240/// int main()
241/// {
242/// bslma::TestAllocator ta;
243///
244/// KeyValue<int> kv1("hello", 2023, &ta);
245/// assert("hello" == kv1.key());
246/// assert(2023 == kv1.value());
247/// assert(&ta == kv1.get_allocator());
248/// assert(&ta == kv1.key().get_allocator());
249/// @endcode
250/// Next, we define a string-string pair and show that the allocator was
251/// passed to *both* the key and value parts of the pair:
252/// @code
253/// KeyValue<String> kv2("March", "Madness", &ta);
254/// assert("March" == kv2.key());
255/// assert("Madness" == kv2.value());
256/// assert(&ta == kv2.get_allocator());
257/// assert(&ta == kv2.key().get_allocator());
258/// assert(&ta == kv2.value().get_allocator());
259/// @endcode
260/// Finally, we declare a `bslalg::ConstructorProxy` of `KeyValue` and show how
261/// we can pass more than one argument (up to 14) -- in addition to the
262/// allocator -- to the proxied type's constructor:
263/// @code
264/// typedef KeyValue<int> UnitVal;
265///
266/// bslalg::ConstructorProxy<UnitVal> uvProxy("km", 14, &ta);
267/// UnitVal& uv = uvProxy.object();
268/// assert("km" == uv.key());
269/// assert(14 == uv.value());
270/// assert(&ta == uv.get_allocator());
271/// }
272/// @endcode
273/// @}
274/** @} */
275/** @} */
276
277/** @addtogroup bsl
278 * @{
279 */
280/** @addtogroup bslalg
281 * @{
282 */
283/** @addtogroup bslalg_constructorproxy
284 * @{
285 */
286
287#include <bslscm_version.h>
288
289#include <bslma_aamodel.h>
292#include <bslma_isstdallocator.h>
294
296#include <bslmf_movableref.h>
298#include <bslmf_util.h> // 'forward(V)' for C++03
299
301#include <bsls_keyword.h>
302#include <bsls_objectbuffer.h>
303#include <bsls_util.h> // 'forward<T>(V)' for C++11
304
305#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
307#include <bslmf_enableif.h>
309#include <bslmf_issame.h>
310#include <bslmf_removecvref.h>
311#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
312
313
314namespace bslalg {
315
316// FORWARD DECLARATIONS
317template <class OBJECT_TYPE> class ConstructorProxy;
318template <class TYPE = bsl::polymorphic_allocator<>::value_type>
319class ConstructorProxy_PolymorphicAllocator;
320template <class TYPE, class AAMODEL = typename bslma::AAModel<TYPE>::type >
321struct ConstructorProxy_AllocatorType;
322
323 // ===============================
324 // struct ConstructorProxy_ImpUtil
325 // ===============================
326
327/// Component-private utility class for implementation methods.
328///
329/// See @ref bslalg_constructorproxy
331
332 // CLASS METHODS
333
334 /// If the specified 'obj' is a specialization of 'ConstructorProxy',
335 /// return the object stored within 'obj'; otherwise return 'obj' unchanged.
336 ///
337 /// \note Note that the value category (i.e., lvalue vs. xvalue)
338 /// of 'obj' is retained.
339 template <class TYPE>
340 static TYPE& unproxy(TYPE& obj);
341 template <class TYPE>
342 static TYPE& unproxy(ConstructorProxy<TYPE>& obj);
343 template <class TYPE>
344 static const TYPE& unproxy(const TYPE& obj);
345 template <class TYPE>
346 static const TYPE& unproxy(const ConstructorProxy<TYPE>& obj);
347
348#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
349 template <class TYPE>
350 static TYPE&& unproxy(TYPE&& obj);
351 template <class TYPE>
352 static TYPE&& unproxy(ConstructorProxy<TYPE>&& obj);
353#else
354 template <class TYPE>
356 template <class TYPE>
359#endif
360};
361
362 // ===============================
363 // class template ConstructorProxy
364 // ===============================
365
366/// This class acts as a proxy for constructing and destroying an object of
367/// parameterized `OBJECT_TYPE`, where `OBJECT_TYPE` may or may not use a
368/// `bslma` allocator for supplying memory. The constructors for this proxy
369/// class take a `bslma::Allocator *`. If `OBJECT_TYPE` has the
370/// `bslma::UsesBslmaAllocator` trait declared, then the supplied
371/// allocator will be used to construct the proxied object. Otherwise, the
372/// allocator is ignored.
373///
374/// See @ref bslalg_constructorproxy
375template <class OBJECT_TYPE>
377
378 // PRIVATE TYPES
379 typedef typename
381
382 // DATA
383 bsls::ObjectBuffer<OBJECT_TYPE> d_objectBuffer; // footprint of proxied
384 // object (raw buffer)
385
386 // PRIVATE CLASS METHODS
387
388 /// Unwrap the specified `alloc`, returning the underlying allocator
389 /// used to construct `OBJECT_TYPE`, if any.
391 unwrapAlloc(const CtorAllocArgT& alloc);
392
393 private:
394 // NOT IMPLEMENTED
397
398 public:
399 // TYPES
400 typedef OBJECT_TYPE ValueType;
401
402 /// Minimally picky allocator type that can be used to construct a
403 /// `ConstructorProxy`. Choose `bsl::polymorphic_allocator` If
404 /// `OBJECT_TYPE` is not AA, `bsl::allocator<char>` if `OBJECT_TYPE` is
405 /// *legacy-AA*, and `OBJECT_TYPE::allocator_type` otherwise.
406 typedef typename
408
409 // CREATORS
410
411 /// Construct a proxy, passing no arguments except possibly a specified
412 /// `allocator` to the constructor of the proxied object. If
413 /// `OBJECT_TYPE` is allocator aware and `allocator_type` is a
414 /// compatible allocator type, pass `allocator` to the proxied object
415 /// constructor; otherwise ignore `allocator`. A compilation error will
416 /// result unless `OBJECT_TYPE` has an (extended) default constructor.
417 explicit ConstructorProxy(const CtorAllocArgT& allocator);
418
419 /// Construct a proxy, passing a single argument and possibly a
420 /// specified `allocator` to the constructor of the proxied object,
421 /// where the non-allocator argument is the specified `a01` argument if
422 /// `ARG01` is not a specialization of `ConstructorProxy`, and
423 /// `a01.object()` if it is such a specialization. If `OBJECT_TYPE` is
424 /// allocator aware and `allocator_type` is a compatible allocator type,
425 /// pass `allocator` to the proxied object's constructor; otherwise
426 /// ignore `allocator`. A compilation error will result unless
427 /// `OBJECT_TYPE` has a constructor with a signature compatible with `OBJECT_TYPE(ARG01&&)`.
428 ///
429 /// \note Note that, if `ARG01` is
430 /// `ConstructorProxy<OBJECT_TYPE>`, then these constructors take on the
431 /// rolls of the extended copy and extended move constructors.
432 template <class ARG01>
434 const CtorAllocArgT& allocator);
435 template <class ARG01>
437 const CtorAllocArgT& allocator);
438
439 /// Construct a proxy, forwarding the specified `a01` up to the
440 /// specified `a14` arguments and possibly a specified `allocator` to
441 /// the constructor of the proxied object. If `OBJECT_TYPE` is
442 /// allocator aware and `allocator_type` is a compatible allocator type,
443 /// pass `allocator` to the proxied object's constructor; otherwise
444 /// ignore `allocator`. A compilation error will result unless
445 /// `OBJECT_TYPE` has a constructor with a signature compatible with `OBJECT_TYPE(ARG01&&, ARG2&&, ...)`.
446 ///
447 /// \note Note that, in C++03, non-const
448 /// lvalue arguments will be forwarded as `const` lvalue references.
449 template <class ARG01, class ARG02>
452 const CtorAllocArgT& allocator);
453 template <class ARG01, class ARG02, class ARG03>
457 const CtorAllocArgT& allocator);
458 template <class ARG01, class ARG02, class ARG03, class ARG04>
463 const CtorAllocArgT& allocator);
464 template <class ARG01, class ARG02, class ARG03, class ARG04,
465 class ARG05>
471 const CtorAllocArgT& allocator);
472 template <class ARG01, class ARG02, class ARG03, class ARG04,
473 class ARG05, class ARG06>
480 const CtorAllocArgT& allocator);
481 template <class ARG01, class ARG02, class ARG03, class ARG04,
482 class ARG05, class ARG06, class ARG07>
490 const CtorAllocArgT& allocator);
491 template <class ARG01, class ARG02, class ARG03, class ARG04,
492 class ARG05, class ARG06, class ARG07, class ARG08>
501 const CtorAllocArgT& allocator);
502 template <class ARG01, class ARG02, class ARG03, class ARG04,
503 class ARG05, class ARG06, class ARG07, class ARG08,
504 class ARG09>
514 const CtorAllocArgT& allocator);
515 template <class ARG01, class ARG02, class ARG03, class ARG04,
516 class ARG05, class ARG06, class ARG07, class ARG08,
517 class ARG09, class ARG10>
528 const CtorAllocArgT& allocator);
529 template <class ARG01, class ARG02, class ARG03, class ARG04,
530 class ARG05, class ARG06, class ARG07, class ARG08,
531 class ARG09, class ARG10, class ARG11>
543 const CtorAllocArgT& allocator);
544 template <class ARG01, class ARG02, class ARG03, class ARG04,
545 class ARG05, class ARG06, class ARG07, class ARG08,
546 class ARG09, class ARG10, class ARG11, class ARG12>
559 const CtorAllocArgT& allocator);
560 template <class ARG01, class ARG02, class ARG03, class ARG04,
561 class ARG05, class ARG06, class ARG07, class ARG08,
562 class ARG09, class ARG10, class ARG11, class ARG12,
563 class ARG13>
577 const CtorAllocArgT& allocator);
578 template <class ARG01, class ARG02, class ARG03, class ARG04,
579 class ARG05, class ARG06, class ARG07, class ARG08,
580 class ARG09, class ARG10, class ARG11, class ARG12,
581 class ARG13, class ARG14>
596 const CtorAllocArgT& allocator);
597
598 /// Destroy this proxy and the object held by this proxy.
600
601 // MANIPULATORS
602
603 /// Return a reference to the modifiable object held by this proxy.
605
606 // ACCESSORS
607
608 /// Return a reference to the non-modifiable object held by this proxy.
609 const OBJECT_TYPE& object() const BSLS_KEYWORD_NOEXCEPT;
610};
611
612// ============================================================================
613// INLINE FUNCTION DEFINITIONS
614// ============================================================================
615
616 // -----------------------------------------------------
617 // struct template ConstructorProxy_PolymorphicAllocator
618 // -----------------------------------------------------
619
620/// Wrapper around `bsl::polymorphic_allocator` that can tolerate being
621/// constructed with a null pointer.
622template <class TYPE>
624 : public bsl::polymorphic_allocator<TYPE> {
625
627
628 public:
629 // TRAITS
634
635 // CREATORS
636
637 /// Construct from the address of a `memory_resource` optionally
638 /// specified by `r`. If `r` is null or not specified, construct from
639 /// the default allocator.
641 // IMPLICIT
642 : Base(r ? Base(r) : Base()) { }
643
644 /// Create an allocator using the same `memory_resource` as the
645 /// specified `other` allocator.
646 template <class T2>
648 const bsl::polymorphic_allocator<T2> &other) // IMPLICIT
649 : Base(other) { }
650
654};
655
656 // ----------------------------------------------
657 // struct template ConstructorProxy_AllocatorType
658 // ----------------------------------------------
659
660/// Metafunction to determine the allocator type for a specified template
661/// parameter `TYPE` using the specified template parater `AAMODEL` for
662/// constructors. This primary template yields a nested `type` of
663/// `bsl::polymorphic_allocator`, which is the most permisive type to use as
664/// a constructor parameter, and an `ArgType` allocator constructor argument
665/// that is a wrapper around `polymorphic_allocator` that tolerates being
666/// constructed with a null pointer. However, if `AAMODEL` is `AAModelNone`
667/// or `AAModelStl`, the allocator constructor argument is ignored and not
668/// passed to the proxied object.
669template <class TYPE, class AAMODEL>
677
678/// Specialization for a bsl-AA `TYPE`.
679template <class TYPE>
680struct ConstructorProxy_AllocatorType<TYPE, bslma::AAModelBsl>
681{
682
683 // TYPES
686};
687
688/// Specialization for a legacy-AA `TYPE`. The proxy type will be bsl-AA.
689template <class TYPE>
690struct ConstructorProxy_AllocatorType<TYPE, bslma::AAModelLegacy>
691{
692
693 // TYPES
696};
697
698
699 // -------------------------------
700 // struct ConstructorProxy_ImpUtil
701 // -------------------------------
702
703// PRIVATE METHODS
704template <class TYPE>
705inline
707{
708 return obj;
709}
710
711template <class TYPE>
712inline
717
718template <class TYPE>
719inline
720const TYPE& ConstructorProxy_ImpUtil::unproxy(const TYPE& obj)
721{
722 return obj;
723}
724
725template <class TYPE>
726inline
727const TYPE&
732
733#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
734
735template <class TYPE>
736inline
737TYPE&& ConstructorProxy_ImpUtil::unproxy(TYPE&& obj)
738{
739 return bslmf::MovableRefUtil::move(obj);
740}
741
742template <class TYPE>
743inline
744TYPE&& ConstructorProxy_ImpUtil::unproxy(ConstructorProxy<TYPE>&& obj)
745{
746 return bslmf::MovableRefUtil::move(obj.object());
747}
748
749#else // if !BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
750
751template <class TYPE>
752inline
758
759template <class TYPE>
760inline
767
768#endif // !BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
769
770
771 // -------------------------------
772 // class template ConstructorProxy
773 // -------------------------------
774
775// PRIVATE CLASS METHODS
776template <class OBJECT_TYPE>
777inline
779ConstructorProxy<OBJECT_TYPE>::unwrapAlloc(const CtorAllocArgT& alloc)
780{
781 return alloc;
782}
783
784// CREATORS
785template <class OBJECT_TYPE>
786inline
791
792template <class OBJECT_TYPE>
793template <class ARG01>
794inline
796 ARG01& a01,
797 const CtorAllocArgT& allocator)
798{
800 allocator,
802}
803
804template <class OBJECT_TYPE>
805template <class ARG01>
806inline
817
818template <class OBJECT_TYPE>
819template <class ARG01, class ARG02>
820inline
832
833template <class OBJECT_TYPE>
834template <class ARG01, class ARG02, class ARG03>
835inline
849
850template <class OBJECT_TYPE>
851template <class ARG01, class ARG02, class ARG03, class ARG04>
852inline
868
869template <class OBJECT_TYPE>
870template <class ARG01, class ARG02, class ARG03, class ARG04,
871 class ARG05>
872inline
890
891template <class OBJECT_TYPE>
892template <class ARG01, class ARG02, class ARG03, class ARG04,
893 class ARG05, class ARG06>
894inline
914
915template <class OBJECT_TYPE>
916template <class ARG01, class ARG02, class ARG03, class ARG04,
917 class ARG05, class ARG06, class ARG07>
918inline
940
941template <class OBJECT_TYPE>
942template <class ARG01, class ARG02, class ARG03, class ARG04,
943 class ARG05, class ARG06, class ARG07, class ARG08>
944inline
968
969template <class OBJECT_TYPE>
970template <class ARG01, class ARG02, class ARG03, class ARG04,
971 class ARG05, class ARG06, class ARG07, class ARG08,
972 class ARG09>
973inline
999
1000template <class OBJECT_TYPE>
1001template <class ARG01, class ARG02, class ARG03, class ARG04,
1002 class ARG05, class ARG06, class ARG07, class ARG08,
1003 class ARG09, class ARG10>
1004inline
1032
1033template <class OBJECT_TYPE>
1034template <class ARG01, class ARG02, class ARG03, class ARG04,
1035 class ARG05, class ARG06, class ARG07, class ARG08,
1036 class ARG09, class ARG10, class ARG11>
1037inline
1067
1068template <class OBJECT_TYPE>
1069template <class ARG01, class ARG02, class ARG03, class ARG04,
1070 class ARG05, class ARG06, class ARG07, class ARG08,
1071 class ARG09, class ARG10, class ARG11, class ARG12>
1072inline
1104
1105template <class OBJECT_TYPE>
1106template <class ARG01, class ARG02, class ARG03, class ARG04,
1107 class ARG05, class ARG06, class ARG07, class ARG08,
1108 class ARG09, class ARG10, class ARG11, class ARG12,
1109 class ARG13>
1110inline
1144
1145template <class OBJECT_TYPE>
1146template <class ARG01, class ARG02, class ARG03, class ARG04,
1147 class ARG05, class ARG06, class ARG07, class ARG08,
1148 class ARG09, class ARG10, class ARG11, class ARG12,
1149 class ARG13, class ARG14>
1150inline
1166 const CtorAllocArgT& allocator)
1167{
1169 d_objectBuffer.address(),
1170 allocator,
1184 BSLS_COMPILERFEATURES_FORWARD(ARG14, a14));
1185}
1186
1187template <class OBJECT_TYPE>
1188inline
1190{
1191 bslma::DestructionUtil::destroy(d_objectBuffer.address());
1192}
1193
1194// MANIPULATORS
1195template <class OBJECT_TYPE>
1196inline
1198{
1199 return d_objectBuffer.object();
1200}
1201
1202// ACCESSORS
1203template <class OBJECT_TYPE>
1204inline
1207{
1208 return d_objectBuffer.object();
1209}
1210
1211} // close package namespace
1212
1213// ============================================================================
1214// TYPE TRAITS
1215// ============================================================================
1216
1217namespace bslmf {
1218
1219template <class OBJECT_TYPE>
1220struct IsBitwiseMoveable<bslalg::ConstructorProxy<OBJECT_TYPE> > :
1221 IsBitwiseMoveable<OBJECT_TYPE>::type
1222{};
1223
1224} // close namespace bslmf
1225
1226#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
1227// ============================================================================
1228// BACKWARD COMPATIBILITY
1229// ============================================================================
1230
1231#ifdef bslalg_ConstructorProxy
1232#undef bslalg_ConstructorProxy
1233#endif
1234/// This alias is defined for backward compatibility.
1235#define bslalg_ConstructorProxy bslalg::ConstructorProxy
1236#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
1237
1238
1239
1240#endif
1241
1242// ----------------------------------------------------------------------------
1243// Copyright 2013 Bloomberg Finance L.P.
1244//
1245// Licensed under the Apache License, Version 2.0 (the "License");
1246// you may not use this file except in compliance with the License.
1247// You may obtain a copy of the License at
1248//
1249// http://www.apache.org/licenses/LICENSE-2.0
1250//
1251// Unless required by applicable law or agreed to in writing, software
1252// distributed under the License is distributed on an "AS IS" BASIS,
1253// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1254// See the License for the specific language governing permissions and
1255// limitations under the License.
1256// ----------------------------- END-OF-FILE ----------------------------------
1257
1258/** @} */
1259/** @} */
1260/** @} */
Definition bslma_bslallocator.h:588
Definition bslma_memoryresource.h:443
Definition bslma_polymorphicallocator.h:460
Definition bslalg_constructorproxy.h:624
ConstructorProxy_PolymorphicAllocator(bsl::memory_resource *r=0)
Definition bslalg_constructorproxy.h:640
BSLMF_NESTED_TRAIT_DECLARATION_IF(ConstructorProxy_PolymorphicAllocator, bslma::UsesBslmaAllocator, false)
BSLMF_NESTED_TRAIT_DECLARATION(ConstructorProxy_PolymorphicAllocator, bslma::IsStdAllocator)
ConstructorProxy_PolymorphicAllocator(const bsl::polymorphic_allocator< T2 > &other)
Definition bslalg_constructorproxy.h:647
ConstructorProxy_PolymorphicAllocator(const ConstructorProxy_PolymorphicAllocator &)=default
Definition bslalg_constructorproxy.h:376
~ConstructorProxy()
Destroy this proxy and the object held by this proxy.
Definition bslalg_constructorproxy.h:1189
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:895
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:974
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, BSLS_COMPILERFEATURES_FORWARD_REF(ARG10) a10, BSLS_COMPILERFEATURES_FORWARD_REF(ARG11) a11, BSLS_COMPILERFEATURES_FORWARD_REF(ARG12) a12, BSLS_COMPILERFEATURES_FORWARD_REF(ARG13) a13, BSLS_COMPILERFEATURES_FORWARD_REF(ARG14) a14, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:1151
ConstructorProxy_AllocatorType< OBJECT_TYPE >::type allocator_type
Definition bslalg_constructorproxy.h:407
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:836
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:853
OBJECT_TYPE & object() BSLS_KEYWORD_NOEXCEPT
Return a reference to the modifiable object held by this proxy.
Definition bslalg_constructorproxy.h:1197
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, BSLS_COMPILERFEATURES_FORWARD_REF(ARG10) a10, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:1005
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:807
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, BSLS_COMPILERFEATURES_FORWARD_REF(ARG10) a10, BSLS_COMPILERFEATURES_FORWARD_REF(ARG11) a11, BSLS_COMPILERFEATURES_FORWARD_REF(ARG12) a12, BSLS_COMPILERFEATURES_FORWARD_REF(ARG13) a13, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:1111
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:821
ConstructorProxy(const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:787
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:873
ConstructorProxy(ARG01 &a01, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:795
OBJECT_TYPE ValueType
Definition bslalg_constructorproxy.h:400
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:919
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, BSLS_COMPILERFEATURES_FORWARD_REF(ARG10) a10, BSLS_COMPILERFEATURES_FORWARD_REF(ARG11) a11, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:1038
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, BSLS_COMPILERFEATURES_FORWARD_REF(ARG09) a09, BSLS_COMPILERFEATURES_FORWARD_REF(ARG10) a10, BSLS_COMPILERFEATURES_FORWARD_REF(ARG11) a11, BSLS_COMPILERFEATURES_FORWARD_REF(ARG12) a12, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:1073
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, BSLS_COMPILERFEATURES_FORWARD_REF(ARG03) a03, BSLS_COMPILERFEATURES_FORWARD_REF(ARG04) a04, BSLS_COMPILERFEATURES_FORWARD_REF(ARG05) a05, BSLS_COMPILERFEATURES_FORWARD_REF(ARG06) a06, BSLS_COMPILERFEATURES_FORWARD_REF(ARG07) a07, BSLS_COMPILERFEATURES_FORWARD_REF(ARG08) a08, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:945
Definition bslmf_movableref.h:752
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:651
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
Definition bdlat_valuetypefunctions.h:939
Definition bdlc_flathashmap.h:2218
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
bsl::allocator type
Definition bslalg_constructorproxy.h:684
bsl::allocator ArgType
Definition bslalg_constructorproxy.h:685
bsl::allocator ArgType
Definition bslalg_constructorproxy.h:695
bsl::allocator type
Definition bslalg_constructorproxy.h:694
Definition bslalg_constructorproxy.h:671
ConstructorProxy_PolymorphicAllocator ArgType
Definition bslalg_constructorproxy.h:675
bsl::polymorphic_allocator type
Definition bslalg_constructorproxy.h:674
Definition bslalg_constructorproxy.h:330
static TYPE & unproxy(TYPE &obj)
Definition bslalg_constructorproxy.h:706
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1244
Definition bslma_isstdallocator.h:202
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisemoveable.h:718
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1039
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335
TYPE & object()
Definition bsls_objectbuffer.h:352