BDE 4.14.0 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 consiting 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 omited 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 accessessors and, for convenience in this example,
181/// define them inline. Note that the `value` accessor extracts the proxied
182/// object from the `d_valueProxy` member:
183/// @code
184/// // ACCESSESSORS
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>
293
294#include <bslmf_enableif.h>
296#include <bslmf_issame.h>
297#include <bslmf_movableref.h>
298#include <bslmf_removecvref.h>
299
301#include <bsls_keyword.h>
302#include <bsls_objectbuffer.h>
303
304#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
306#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
307
308
309namespace bslalg {
310
311// FORWARD DECLARATIONS
312template <class OBJECT_TYPE> class ConstructorProxy;
313template <class TYPE = bsl::polymorphic_allocator<>::value_type>
314class ConstructorProxy_PolymorphicAllocator;
315template <class TYPE, class AAMODEL = typename bslma::AAModel<TYPE>::type >
316struct ConstructorProxy_AllocatorType;
317
318 // ===============================
319 // struct ConstructorProxy_ImpUtil
320 // ===============================
321
322/// Component-private utility class for implementation methods.
324
325 // CLASS METHODS
326
327 /// If the specified 'obj' is a specialization of 'ConstructorProxy',
328 /// return the object stored within 'obj'; otherwise return 'obj'
329 /// unchanged. Note that the value category (i.e., lvalue vs. xvalue)
330 /// of 'obj' is retained.
331 template <class TYPE>
332 static TYPE& unproxy(TYPE& obj);
333 template <class TYPE>
334 static TYPE& unproxy(ConstructorProxy<TYPE>& obj);
335 template <class TYPE>
336 static const TYPE& unproxy(const TYPE& obj);
337 template <class TYPE>
338 static const TYPE& unproxy(const ConstructorProxy<TYPE>& obj);
339
340#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
341 template <class TYPE>
342 static TYPE&& unproxy(TYPE&& obj);
343 template <class TYPE>
344 static TYPE&& unproxy(ConstructorProxy<TYPE>&& obj);
345#else
346 template <class TYPE>
348 template <class TYPE>
351#endif
352};
353
354 // ===============================
355 // class template ConstructorProxy
356 // ===============================
357
358/// This class acts as a proxy for constructing and destroying an object of
359/// parameterized `OBJECT_TYPE`, where `OBJECT_TYPE` may or may not use a
360/// `bslma` allocator for supplying memory. The constructors for this proxy
361/// class take a `bslma::Allocator *`. If `OBJECT_TYPE` has the
362/// `bslma::UsesBslmaAllocator` trait declared, then the supplied
363/// allocator will be used to construct the proxied object. Otherwise, the
364/// allocator is ignored.
365///
366/// See @ref bslalg_constructorproxy
367template <class OBJECT_TYPE>
369
370 // PRIVATE TYPES
371 typedef typename
373
374 // DATA
375 bsls::ObjectBuffer<OBJECT_TYPE> d_objectBuffer; // footprint of proxied
376 // object (raw buffer)
377
378 // PRIVATE CLASS METHODS
379
380 /// Unwrap the specified `alloc`, returning the underlying allocator
381 /// used to construct `OBJECT_TYPE`, if any.
383 unwrapAlloc(const CtorAllocArgT& alloc);
384
385 private:
386 // NOT IMPLEMENTED
389
390 public:
391 // TYPES
392 typedef OBJECT_TYPE ValueType;
393
394 /// Minimally picky allocator type that can be used to construct a
395 /// `ConstructorProxy`. Choose `bsl::polymorphic_allocator` If
396 /// `OBJECT_TYPE` is not AA, `bsl::allocator<char>` if `OBJECT_TYPE` is
397 /// *legacy-AA*, and `OBJECT_TYPE::allocator_type` otherwise.
398 typedef typename
400
401 // CREATORS
402
403 /// Construct a proxy, passing no arguments except possibly a specified
404 /// `allocator` to the constructor of the proxied object. If
405 /// `OBJECT_TYPE` is allocator aware and `allocator_type` is a
406 /// compatible allocator type, pass `allocator` to the proxied object
407 /// constructor; otherwise ignore `allocator`. A compilation error will
408 /// result unless `OBJECT_TYPE` has an (extended) default constructor.
409 explicit ConstructorProxy(const CtorAllocArgT& allocator);
410
411 /// Construct a proxy, passing a single argument and possibly a
412 /// specified `allocator` to the constructor of the proxied object,
413 /// where the non-allocator argument is the specified `a01` argument if
414 /// `ARG01` is not a specialization of `ConstructorProxy`, and
415 /// `a01.object()` if it is such a specialization. If `OBJECT_TYPE` is
416 /// allocator aware and `allocator_type` is a compatible allocator type,
417 /// pass `allocator` to the proxied object's constructor; otherwise
418 /// ignore `allocator`. A compilation error will result unless
419 /// `OBJECT_TYPE` has a constructor with a signature compatible with
420 /// `OBJECT_TYPE(ARG01&&)`. Note that, if `ARG01` is
421 /// `ConstructorProxy<OBJECT_TYPE>`, then these constructors take on the
422 /// rolls of the extended copy and extended move constructors.
423 template <class ARG01>
425 const CtorAllocArgT& allocator);
426 template <class ARG01>
428 const CtorAllocArgT& allocator);
429
430 /// Construct a proxy, forwarding the specified `a01` up to the
431 /// specified `a14` arguments and possibly a specified `allocator` to
432 /// the constructor of the proxied object. If `OBJECT_TYPE` is
433 /// allocator aware and `allocator_type` is a compatible allocator type,
434 /// pass `allocator` to the proxied object's constructor; otherwise
435 /// ignore `allocator`. A compilation error will result unless
436 /// `OBJECT_TYPE` has a constructor with a signature compatible with
437 /// `OBJECT_TYPE(ARG01&&, ARG2&&, ...)`. Note that, in C++03, non-const
438 /// lvalue arguments will be forwarded as `const` lvalue references.
439 template <class ARG01, class ARG02>
442 const CtorAllocArgT& allocator);
443 template <class ARG01, class ARG02, class ARG03>
447 const CtorAllocArgT& allocator);
448 template <class ARG01, class ARG02, class ARG03, class ARG04>
453 const CtorAllocArgT& allocator);
454 template <class ARG01, class ARG02, class ARG03, class ARG04,
455 class ARG05>
461 const CtorAllocArgT& allocator);
462 template <class ARG01, class ARG02, class ARG03, class ARG04,
463 class ARG05, class ARG06>
470 const CtorAllocArgT& allocator);
471 template <class ARG01, class ARG02, class ARG03, class ARG04,
472 class ARG05, class ARG06, class ARG07>
480 const CtorAllocArgT& allocator);
481 template <class ARG01, class ARG02, class ARG03, class ARG04,
482 class ARG05, class ARG06, class ARG07, class ARG08>
491 const CtorAllocArgT& allocator);
492 template <class ARG01, class ARG02, class ARG03, class ARG04,
493 class ARG05, class ARG06, class ARG07, class ARG08,
494 class ARG09>
504 const CtorAllocArgT& allocator);
505 template <class ARG01, class ARG02, class ARG03, class ARG04,
506 class ARG05, class ARG06, class ARG07, class ARG08,
507 class ARG09, class ARG10>
518 const CtorAllocArgT& allocator);
519 template <class ARG01, class ARG02, class ARG03, class ARG04,
520 class ARG05, class ARG06, class ARG07, class ARG08,
521 class ARG09, class ARG10, class ARG11>
533 const CtorAllocArgT& allocator);
534 template <class ARG01, class ARG02, class ARG03, class ARG04,
535 class ARG05, class ARG06, class ARG07, class ARG08,
536 class ARG09, class ARG10, class ARG11, class ARG12>
549 const CtorAllocArgT& allocator);
550 template <class ARG01, class ARG02, class ARG03, class ARG04,
551 class ARG05, class ARG06, class ARG07, class ARG08,
552 class ARG09, class ARG10, class ARG11, class ARG12,
553 class ARG13>
567 const CtorAllocArgT& allocator);
568 template <class ARG01, class ARG02, class ARG03, class ARG04,
569 class ARG05, class ARG06, class ARG07, class ARG08,
570 class ARG09, class ARG10, class ARG11, class ARG12,
571 class ARG13, class ARG14>
586 const CtorAllocArgT& allocator);
587
588 /// Destroy this proxy and the object held by this proxy.
590
591 // MANIPULATORS
592
593 /// Return a reference to the modifiable object held by this proxy.
595
596 // ACCESSORS
597
598 /// Return a reference to the non-modifiable object held by this proxy.
599 const OBJECT_TYPE& object() const BSLS_KEYWORD_NOEXCEPT;
600};
601
602// ============================================================================
603// INLINE FUNCTION DEFINITIONS
604// ============================================================================
605
606 // -----------------------------------------------------
607 // struct template ConstructorProxy_PolymorphicAllocator
608 // -----------------------------------------------------
609
610/// Wrapper around `bsl::polymorphic_allocator` that can tolerate being
611/// constructed with a null pointer.
612template <class TYPE>
614 : public bsl::polymorphic_allocator<TYPE> {
615
617
618 public:
619 // TRAITS
624
625 // CREATORS
626
627 /// Construct from the address of a `memory_resource` optionally
628 /// specified by `r`. If `r` is null or not specified, construct from
629 /// the default allocator.
631 // IMPLICIT
632 : Base(r ? Base(r) : Base()) { }
633
634 /// Create an allocator using the same `memory_resource` as the
635 /// specified `other` allocator.
636 template <class T2>
638 const bsl::polymorphic_allocator<T2> &other) // IMPLICIT
639 : Base(other) { }
640
644};
645
646 // ----------------------------------------------
647 // struct template ConstructorProxy_AllocatorType
648 // ----------------------------------------------
649
650/// Metafunction to determine the allocator type for a specified template
651/// parameter `TYPE` using the specified template parater `AAMODEL` for
652/// constructors. This primary template yields a nested `type` of
653/// `bsl::polymorphic_allocator`, which is the most permisive type to use as
654/// a constructor parameter, and an `ArgType` allocator constructor argument
655/// that is a wrapper around `polymorphic_allocator` that tolerates being
656/// constructed with a null pointer. However, if `AAMODEL` is `AAModelNone`
657/// or `AAModelStl`, the allocator constructor argument is ignored and not
658/// passed to the proxied object.
659template <class TYPE, class AAMODEL>
667
668/// Specialization for a bsl-AA `TYPE`.
669template <class TYPE>
670struct ConstructorProxy_AllocatorType<TYPE, bslma::AAModelBsl>
671{
672
673 // TYPES
676};
677
678/// Specialization for a legacy-AA `TYPE`. The proxy type will be bsl-AA.
679template <class TYPE>
680struct ConstructorProxy_AllocatorType<TYPE, bslma::AAModelLegacy>
681{
682
683 // TYPES
686};
687
688
689 // -------------------------------
690 // struct ConstructorProxy_ImpUtil
691 // -------------------------------
692
693// PRIVATE METHODS
694template <class TYPE>
695inline
697{
698 return obj;
699}
700
701template <class TYPE>
702inline
707
708template <class TYPE>
709inline
710const TYPE& ConstructorProxy_ImpUtil::unproxy(const TYPE& obj)
711{
712 return obj;
713}
714
715template <class TYPE>
716inline
717const TYPE&
722
723#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
724
725template <class TYPE>
726inline
727TYPE&& ConstructorProxy_ImpUtil::unproxy(TYPE&& obj)
728{
729 return bslmf::MovableRefUtil::move(obj);
730}
731
732template <class TYPE>
733inline
734TYPE&& ConstructorProxy_ImpUtil::unproxy(ConstructorProxy<TYPE>&& obj)
735{
736 return bslmf::MovableRefUtil::move(obj.object());
737}
738
739#else // if !BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
740
741template <class TYPE>
742inline
748
749template <class TYPE>
750inline
757
758#endif // !BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
759
760
761 // -------------------------------
762 // class template ConstructorProxy
763 // -------------------------------
764
765// PRIVATE CLASS METHODS
766template <class OBJECT_TYPE>
767inline
769ConstructorProxy<OBJECT_TYPE>::unwrapAlloc(const CtorAllocArgT& alloc)
770{
771 return alloc;
772}
773
774// CREATORS
775template <class OBJECT_TYPE>
776inline
781
782template <class OBJECT_TYPE>
783template <class ARG01>
784inline
786 ARG01& a01,
787 const CtorAllocArgT& allocator)
788{
790 allocator,
792}
793
794template <class OBJECT_TYPE>
795template <class ARG01>
796inline
807
808template <class OBJECT_TYPE>
809template <class ARG01, class ARG02>
810inline
822
823template <class OBJECT_TYPE>
824template <class ARG01, class ARG02, class ARG03>
825inline
839
840template <class OBJECT_TYPE>
841template <class ARG01, class ARG02, class ARG03, class ARG04>
842inline
858
859template <class OBJECT_TYPE>
860template <class ARG01, class ARG02, class ARG03, class ARG04,
861 class ARG05>
862inline
880
881template <class OBJECT_TYPE>
882template <class ARG01, class ARG02, class ARG03, class ARG04,
883 class ARG05, class ARG06>
884inline
904
905template <class OBJECT_TYPE>
906template <class ARG01, class ARG02, class ARG03, class ARG04,
907 class ARG05, class ARG06, class ARG07>
908inline
930
931template <class OBJECT_TYPE>
932template <class ARG01, class ARG02, class ARG03, class ARG04,
933 class ARG05, class ARG06, class ARG07, class ARG08>
934inline
958
959template <class OBJECT_TYPE>
960template <class ARG01, class ARG02, class ARG03, class ARG04,
961 class ARG05, class ARG06, class ARG07, class ARG08,
962 class ARG09>
963inline
989
990template <class OBJECT_TYPE>
991template <class ARG01, class ARG02, class ARG03, class ARG04,
992 class ARG05, class ARG06, class ARG07, class ARG08,
993 class ARG09, class ARG10>
994inline
1022
1023template <class OBJECT_TYPE>
1024template <class ARG01, class ARG02, class ARG03, class ARG04,
1025 class ARG05, class ARG06, class ARG07, class ARG08,
1026 class ARG09, class ARG10, class ARG11>
1027inline
1057
1058template <class OBJECT_TYPE>
1059template <class ARG01, class ARG02, class ARG03, class ARG04,
1060 class ARG05, class ARG06, class ARG07, class ARG08,
1061 class ARG09, class ARG10, class ARG11, class ARG12>
1062inline
1094
1095template <class OBJECT_TYPE>
1096template <class ARG01, class ARG02, class ARG03, class ARG04,
1097 class ARG05, class ARG06, class ARG07, class ARG08,
1098 class ARG09, class ARG10, class ARG11, class ARG12,
1099 class ARG13>
1100inline
1134
1135template <class OBJECT_TYPE>
1136template <class ARG01, class ARG02, class ARG03, class ARG04,
1137 class ARG05, class ARG06, class ARG07, class ARG08,
1138 class ARG09, class ARG10, class ARG11, class ARG12,
1139 class ARG13, class ARG14>
1140inline
1156 const CtorAllocArgT& allocator)
1157{
1159 d_objectBuffer.address(),
1160 allocator,
1174 BSLS_COMPILERFEATURES_FORWARD(ARG14, a14));
1175}
1176
1177template <class OBJECT_TYPE>
1178inline
1180{
1181 bslma::DestructionUtil::destroy(d_objectBuffer.address());
1182}
1183
1184// MANIPULATORS
1185template <class OBJECT_TYPE>
1186inline
1188{
1189 return d_objectBuffer.object();
1190}
1191
1192// ACCESSORS
1193template <class OBJECT_TYPE>
1194inline
1197{
1198 return d_objectBuffer.object();
1199}
1200
1201} // close package namespace
1202
1203// ============================================================================
1204// TYPE TRAITS
1205// ============================================================================
1206
1207namespace bslmf {
1208
1209template <class OBJECT_TYPE>
1210struct IsBitwiseMoveable<bslalg::ConstructorProxy<OBJECT_TYPE> > :
1211 IsBitwiseMoveable<OBJECT_TYPE>
1212{};
1213
1214} // close namespace bslmf
1215
1216#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
1217// ============================================================================
1218// BACKWARD COMPATIBILITY
1219// ============================================================================
1220
1221#ifdef bslalg_ConstructorProxy
1222#undef bslalg_ConstructorProxy
1223#endif
1224/// This alias is defined for backward compatibility.
1225#define bslalg_ConstructorProxy bslalg::ConstructorProxy
1226#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
1227
1228
1229
1230#endif
1231
1232// ----------------------------------------------------------------------------
1233// Copyright 2013 Bloomberg Finance L.P.
1234//
1235// Licensed under the Apache License, Version 2.0 (the "License");
1236// you may not use this file except in compliance with the License.
1237// You may obtain a copy of the License at
1238//
1239// http://www.apache.org/licenses/LICENSE-2.0
1240//
1241// Unless required by applicable law or agreed to in writing, software
1242// distributed under the License is distributed on an "AS IS" BASIS,
1243// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244// See the License for the specific language governing permissions and
1245// limitations under the License.
1246// ----------------------------- END-OF-FILE ----------------------------------
1247
1248/** @} */
1249/** @} */
1250/** @} */
Definition bslma_bslallocator.h:580
Definition bslma_memoryresource.h:441
Definition bslma_polymorphicallocator.h:452
Definition bslalg_constructorproxy.h:614
ConstructorProxy_PolymorphicAllocator(bsl::memory_resource *r=0)
Definition bslalg_constructorproxy.h:630
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:637
ConstructorProxy_PolymorphicAllocator(const ConstructorProxy_PolymorphicAllocator &)=default
Definition bslalg_constructorproxy.h:368
~ConstructorProxy()
Destroy this proxy and the object held by this proxy.
Definition bslalg_constructorproxy.h:1179
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:885
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:964
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:1141
ConstructorProxy_AllocatorType< OBJECT_TYPE >::type allocator_type
Definition bslalg_constructorproxy.h:399
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:826
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:843
OBJECT_TYPE & object() BSLS_KEYWORD_NOEXCEPT
Return a reference to the modifiable object held by this proxy.
Definition bslalg_constructorproxy.h:1187
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:995
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:797
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:1101
ConstructorProxy(BSLS_COMPILERFEATURES_FORWARD_REF(ARG01) a01, BSLS_COMPILERFEATURES_FORWARD_REF(ARG02) a02, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:811
ConstructorProxy(const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:777
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:863
ConstructorProxy(ARG01 &a01, const CtorAllocArgT &allocator)
Definition bslalg_constructorproxy.h:785
OBJECT_TYPE ValueType
Definition bslalg_constructorproxy.h:392
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:909
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:1028
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:1063
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:935
Definition bslmf_movableref.h:751
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:609
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
Definition bdlb_printmethods.h:283
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
bsl::allocator type
Definition bslalg_constructorproxy.h:674
bsl::allocator ArgType
Definition bslalg_constructorproxy.h:675
bsl::allocator ArgType
Definition bslalg_constructorproxy.h:685
bsl::allocator type
Definition bslalg_constructorproxy.h:684
Definition bslalg_constructorproxy.h:661
ConstructorProxy_PolymorphicAllocator ArgType
Definition bslalg_constructorproxy.h:665
bsl::polymorphic_allocator type
Definition bslalg_constructorproxy.h:664
Component-private utility class for implementation methods.
Definition bslalg_constructorproxy.h:323
static TYPE & unproxy(TYPE &obj)
Definition bslalg_constructorproxy.h:696
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
Definition bslma_isstdallocator.h:201
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_isbitwisemoveable.h:718
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1032
Definition bsls_objectbuffer.h:276
TYPE * address()
Definition bsls_objectbuffer.h:334
TYPE & object()
Definition bsls_objectbuffer.h:351