BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlb_nullableallocatedvalue_cpp03.h
Go to the documentation of this file.
1/// @file bdlb_nullableallocatedvalue_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlb_nullableallocatedvalue_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BDLB_NULLABLEALLOCATEDVALUE_CPP03
12#define INCLUDED_BDLB_NULLABLEALLOCATEDVALUE_CPP03
13
14/// @defgroup bdlb_nullableallocatedvalue_cpp03 bdlb_nullableallocatedvalue_cpp03
15/// @brief Provide C++03 implementation for bdlb_nullableallocatedvalue.h
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlb
19/// @{
20/// @addtogroup bdlb_nullableallocatedvalue_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlb_nullableallocatedvalue_cpp03-purpose"> Purpose</a>
25/// * <a href="#bdlb_nullableallocatedvalue_cpp03-classes"> Classes </a>
26/// * <a href="#bdlb_nullableallocatedvalue_cpp03-description"> Description </a>
27///
28/// # Purpose {#bdlb_nullableallocatedvalue_cpp03-purpose}
29/// Provide C++03 implementation for bdlb_nullableallocatedvalue.h
30///
31/// # Classes {#bdlb_nullableallocatedvalue_cpp03-classes}
32/// See bdlb_nullableallocatedvalue.h for list of classes
33///
34/// @see bdlb_nullableallocatedvalue
35///
36/// # Description {#bdlb_nullableallocatedvalue_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 Wed Oct 29 16:14:12 2025
48/// Command line: sim_cpp11_features.pl bdlb_nullableallocatedvalue.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bdl
54 * @{
55 */
56/** @addtogroup bdlb
57 * @{
58 */
59/** @addtogroup bdlb_nullableallocatedvalue_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BDLB_NULLABLEALLOCATEDVALUE_H
64
65
66namespace bdlb {
67
68 // ==================================
69 // class NullableAllocatedValue<TYPE>
70 // ==================================
71
72/// This template class extends the set of values of its value-semantic
73/// `TYPE` parameter to include the notion of a "null" value. If `TYPE` is
74/// fully value-semantic, then the augmented type
75/// `NullableAllocatedValue<TYPE>` will be as well. In addition to
76/// supporting all homogeneous value-semantic operations, conversions
77/// between comparable underlying value types is also supported. Two
78/// nullable objects with different underlying types compare equal if their
79/// underlying types are comparable and either (1) both objects are null or
80/// (2) the non-null values compare equal. Attempts to copy construct, copy
81/// assign, or compare incompatible values types will fail to compile. The
82/// `NullableAllocatedValue` template can be instantiated on an incomplete
83/// type, but it cannot be instantiated on a type that overloads
84/// `operator&`.
85///
86/// See @ref bdlb_nullableallocatedvalue_cpp03
87template <class TYPE>
88class NullableAllocatedValue {
89
90 enum { k_HAS_VALUE = 0 };
91 // flag for checking if the value is present
92
93 // DATA
94 NullableAllocatedValue_PointerBitsPair<bslma::Allocator, 1> d_allocator;
95 union {
96 TYPE *d_pointer_p;
97 char d_buffer[sizeof(TYPE *)];
98 } d_storage;
99
100 // PRIVATE TYPES
101# ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
102 // UNSPECIFIED BOOL
103
104 /// This type is needed only in C++03 mode, where `explicit` conversion
105 /// operators are not supported. A `NullableAllocatedValue` is implicitly
106 /// converted to `UnspecifiedBool` when used in `if` statements, but is not
107 /// implicitly convertible to `bool`.
108 typedef BloombergLP::bsls::UnspecifiedBool<NullableAllocatedValue>
109 UnspecifiedBoolUtil;
110 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
111# endif
112
113 // PRIVATE CLASS METHODS
114
115 /// Returns `true` if an object of the template parameter `TYPE` can be
116 /// stored locally, instead of being allocated on the heap.
117 static bool isLocal() BSLS_KEYWORD_NOEXCEPT;
118
119 // PRIVATE ACCESSORS
120
121 /// return a pointer to the held value. If the value does not exist and
122 /// the storage is local, then return a pointer to storage suitable for
123 /// constructing the held value. If the value does not exist and the
124 /// storage is not local, return NULL.
125 TYPE *getAddress();
126 const TYPE *getAddress() const;
127
128 // PRIVATE MANIPULATORS
129
130 /// Clear the flag in the `d_allocator` field that indicates that this
131 /// object does not hold a value.
132 void clearHasValueFlag() BSLS_KEYWORD_NOEXCEPT;
133
134 /// Set the flag in the `d_allocator` field that indicates that this
135 /// object holds a value.
136 void setHasValueFlag() BSLS_KEYWORD_NOEXCEPT;
137
138 /// Set the value of the pointer to the held value to the specified `newPtr`.
139 ///
140 /// \pre The behavior is undefined if the storage is local.
141 void setRemoteAddress(TYPE *newPtr);
142
143 /// Efficiently exchange the value of this object with the value of the
144 /// specified `other` object. At least one of `this` or `other` is not
145 /// empty, and the values are stored locally. This method provides the
146 /// no-throw exception-safety guarantee.
147 ///
148 /// \pre The behavior is undefined unless this object was created with the same allocator as `other`.
149 void swapLocal(NullableAllocatedValue& other);
150
151 /// Efficiently exchange the value of this object with the value of the
152 /// specified `other` object. At least one of `this` or `other` is not
153 /// empty, and the values are stored remotely. This method provides the
154 /// no-throw exception-safety guarantee.
155 ///
156 /// \pre The behavior is undefined unless this object was created with the same allocator as `other`.
157 void swapRemote(NullableAllocatedValue& other);
158
159
160 public:
161 // TYPES
162
163 /// `ValueType` is an alias for the underlying `TYPE` upon which this
164 /// template class is instantiated, and represents the type of the
165 /// managed object.
166 typedef TYPE ValueType;
167
168 // TRAITS
170 bslma::UsesBslmaAllocator);
172 bslmf::IsBitwiseMoveable);
174 bdlb::HasPrintMethod);
175
176 // CREATORS
177
178 /// Create a nullable object having the null value. Use the currently
179 /// installed default allocator to supply memory.
181
182 /// Create a nullable object that has the null value and that uses the
183 /// mechanism of the specified `allocator` to supply memory.
184 explicit NullableAllocatedValue(const bsl::allocator<char>& allocator);
185
186 /// Create a nullable object having the null value. Use the currently
187 /// installed default allocator to supply memory.
188 NullableAllocatedValue(const bsl::nullopt_t&); // IMPLICIT
189
190 /// Create a nullable object that has the null value and that uses the
191 /// mechanism of the specified `allocator` to supply memory.
192 NullableAllocatedValue(const bsl::nullopt_t&,
193 const bsl::allocator<char>& allocator);
194
195 /// Create a nullable object having the value of the specified
196 /// `original` object. Use the currently installed default allocator
197 /// to supply memory.
199
200 /// Create a nullable object having the value of the specified
201 /// `original` object and that uses the mechanism of the specified
202 /// `allocator` to supply memory.
204 const bsl::allocator<char>& allocator);
205
206 /// Create a nullable object having the specified `value`. Use the
207 /// currently installed default allocator to supply memory.
208 NullableAllocatedValue(const TYPE& value); // IMPLICIT
209
210 /// Create a nullable object having the specified `value` and that uses
211 /// the mechanism of specified `allocator` to supply memory.
212 NullableAllocatedValue(const TYPE& value,
213 const bsl::allocator<char>& allocator);
214
215 /// Destroy this object.
217
218 // MANIPULATORS
219
220 /// Assign to this object the value of the specified `rhs`, and return a
221 /// reference providing modifiable access to this object.
222 NullableAllocatedValue<TYPE>& operator=(const NullableAllocatedValue& rhs);
223
224 /// Reset this object to the default constructed state (i.e., to have
225 /// the null value).
226 NullableAllocatedValue<TYPE>& operator=(const bsl::nullopt_t&);
227
228 /// Assign to this object the value of the specified `rhs`, and return a
229 /// reference providing modifiable access to the underlying `TYPE`
230 /// object.
231 NullableAllocatedValue<TYPE>& operator=(const TYPE& rhs);
232
233 /// Return a pointer providing modifiable access to the underlying `TYPE` object.
234 ///
235 /// \pre The behavior is undefined if the object has no
236 /// value.
237 TYPE *operator->();
238
239 /// Return a reference providing modifiable access to the underlying `TYPE` object.
240 ///
241 /// \pre The behavior is undefined if the object has no
242 /// value.
243 TYPE& operator*();
244
245#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
246// {{{ BEGIN GENERATED CODE
247// Command line: sim_cpp11_features.pl bdlb_nullableallocatedvalue.h
248#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
249#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT 10
250#endif
251#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A
252#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
253#endif
254#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 0
255 TYPE& emplace();
256#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 0
257
258#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 1
259 template <class ARGS_01>
261#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 1
262
263#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 2
264 template <class ARGS_01,
265 class ARGS_02>
268#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 2
269
270#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 3
271 template <class ARGS_01,
272 class ARGS_02,
273 class ARGS_03>
277#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 3
278
279#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 4
280 template <class ARGS_01,
281 class ARGS_02,
282 class ARGS_03,
283 class ARGS_04>
288#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 4
289
290#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 5
291 template <class ARGS_01,
292 class ARGS_02,
293 class ARGS_03,
294 class ARGS_04,
295 class ARGS_05>
301#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 5
302
303#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 6
304 template <class ARGS_01,
305 class ARGS_02,
306 class ARGS_03,
307 class ARGS_04,
308 class ARGS_05,
309 class ARGS_06>
316#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 6
317
318#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 7
319 template <class ARGS_01,
320 class ARGS_02,
321 class ARGS_03,
322 class ARGS_04,
323 class ARGS_05,
324 class ARGS_06,
325 class ARGS_07>
333#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 7
334
335#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 8
336 template <class ARGS_01,
337 class ARGS_02,
338 class ARGS_03,
339 class ARGS_04,
340 class ARGS_05,
341 class ARGS_06,
342 class ARGS_07,
343 class ARGS_08>
352#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 8
353
354#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 9
355 template <class ARGS_01,
356 class ARGS_02,
357 class ARGS_03,
358 class ARGS_04,
359 class ARGS_05,
360 class ARGS_06,
361 class ARGS_07,
362 class ARGS_08,
363 class ARGS_09>
373#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 9
374
375#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 10
376 template <class ARGS_01,
377 class ARGS_02,
378 class ARGS_03,
379 class ARGS_04,
380 class ARGS_05,
381 class ARGS_06,
382 class ARGS_07,
383 class ARGS_08,
384 class ARGS_09,
385 class ARGS_10>
396#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 10
397
398
399# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
400#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 0
401 template <class INIT_LIST_TYPE>
402 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il);
403#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 0
404
405#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 1
406 template <class INIT_LIST_TYPE, class ARGS_01>
407 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
409#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 1
410
411#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 2
412 template <class INIT_LIST_TYPE, class ARGS_01,
413 class ARGS_02>
414 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
417#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 2
418
419#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 3
420 template <class INIT_LIST_TYPE, class ARGS_01,
421 class ARGS_02,
422 class ARGS_03>
423 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
427#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 3
428
429#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 4
430 template <class INIT_LIST_TYPE, class ARGS_01,
431 class ARGS_02,
432 class ARGS_03,
433 class ARGS_04>
434 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
439#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 4
440
441#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 5
442 template <class INIT_LIST_TYPE, class ARGS_01,
443 class ARGS_02,
444 class ARGS_03,
445 class ARGS_04,
446 class ARGS_05>
447 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
453#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 5
454
455#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 6
456 template <class INIT_LIST_TYPE, class ARGS_01,
457 class ARGS_02,
458 class ARGS_03,
459 class ARGS_04,
460 class ARGS_05,
461 class ARGS_06>
462 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
469#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 6
470
471#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 7
472 template <class INIT_LIST_TYPE, class ARGS_01,
473 class ARGS_02,
474 class ARGS_03,
475 class ARGS_04,
476 class ARGS_05,
477 class ARGS_06,
478 class ARGS_07>
479 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
487#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 7
488
489#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 8
490 template <class INIT_LIST_TYPE, class ARGS_01,
491 class ARGS_02,
492 class ARGS_03,
493 class ARGS_04,
494 class ARGS_05,
495 class ARGS_06,
496 class ARGS_07,
497 class ARGS_08>
498 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
507#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 8
508
509#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 9
510 template <class INIT_LIST_TYPE, class ARGS_01,
511 class ARGS_02,
512 class ARGS_03,
513 class ARGS_04,
514 class ARGS_05,
515 class ARGS_06,
516 class ARGS_07,
517 class ARGS_08,
518 class ARGS_09>
519 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
529#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 9
530
531#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 10
532 template <class INIT_LIST_TYPE, class ARGS_01,
533 class ARGS_02,
534 class ARGS_03,
535 class ARGS_04,
536 class ARGS_05,
537 class ARGS_06,
538 class ARGS_07,
539 class ARGS_08,
540 class ARGS_09,
541 class ARGS_10>
542 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
553#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_A >= 10
554
555
556# endif
557#else
558// The generated code below is a workaround for the absence of perfect
559// forwarding in some compilers.
560 template <class... ARGS>
562
563# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
564 template <class INIT_LIST_TYPE, class... ARGS>
565 TYPE& emplace(std::initializer_list<INIT_LIST_TYPE> il,
567
568# endif
569// }}} END GENERATED CODE
570#endif
571
572 /// Assign to this object the value read from the specified input
573 /// `stream` using the specified `version` format, and return a
574 /// reference to `stream`. If `stream` is initially invalid, this
575 /// operation has no effect. If `version` is not supported, this object
576 /// is unaltered and `stream` is invalidated, but otherwise unmodified.
577 /// If `version` is supported but `stream` becomes invalid during this
578 /// operation, this object has an undefined, but valid, state.
579 ///
580 /// \note Note that no version is read from `stream`. See the `bslx` package-level
581 /// documentation for more information on BDEX streaming of
582 /// value-semantic types and containers.
583 template <class STREAM>
584 STREAM& bdexStreamIn(STREAM& stream, int version);
585
586 /// Assign to this object the specified `val`, and return a reference
587 /// providing modifiable access to the underlying `TYPE` object.
588 TYPE& makeValue(const TYPE& val);
589
590 /// Assign to this object the default value for `TYPE`, and return a
591 /// reference providing modifiable access to the underlying `TYPE`
592 /// object.
593 TYPE& makeValue();
594
595 /// Reset this object to the default constructed state (i.e., to have
596 /// the null value).
597 void reset();
598
599 /// Efficiently exchange the value of this object with the value of the
600 /// specified `other` object. This method provides the no-throw exception-safety guarantee.
601 ///
602 /// \pre The behavior is undefined unless this
603 /// object was created with the same allocator as `other`.
604 void swap(NullableAllocatedValue& other);
605
606 /// Return a reference providing modifiable access to the underlying `TYPE` object.
607 ///
608 /// \pre The behavior is undefined unless this object is
609 /// non-null.
610 TYPE& value();
611
612 // ACCESSORS
613
614 /// Write the value of this object, using the specified `version`
615 /// format, to the specified output `stream`, and return a reference to
616 /// `stream`. If `stream` is initially invalid, this operation has no
617 /// effect. If `version` is not supported, `stream` is invalidated, but otherwise unmodified.
618 ///
619 /// \note Note that `version` is not written to
620 /// `stream`. See the `bslx` package-level documentation for more
621 /// information on BDEX streaming of value-semantic types and
622 /// containers.
623 template <class STREAM>
624 STREAM& bdexStreamOut(STREAM& stream, int version) const;
625
626 /// Return a `bsl::allocator` constructed from the `bslma::Allocator` used by this object to supply memory.
627 ///
628 /// \note Note that if no allocator was
629 /// supplied at construction the default allocator in effect at
630 /// construction is used.
632
633 /// Return `true` if this object contains a value, and `false`
634 /// otherwise.
635 bool has_value() const BSLS_KEYWORD_NOEXCEPT;
636
637 /// Return `false` if this object contains a value, and `true` otherwise.
638 ///
639 /// \note Note that this is the opposite of @ref has_value .
640 bool isNull() const BSLS_KEYWORD_NOEXCEPT;
641
642 /// Return the maximum valid BDEX format version, as indicated by the
643 /// specified `versionSelector`, to be passed to the `bdexStreamOut` method.
644 ///
645 /// \note Note that it is highly recommended that `versionSelector`
646 /// be formatted as "YYYYMMDD", a date representation. Also note that
647 /// `versionSelector` should be a *compile*-time-chosen value that
648 /// selects a format version supported by both externalizer and
649 /// unexternalizer. See the `bslx` package-level documentation for more
650 /// information on BDEX streaming of value-semantic types and
651 /// containers.
652 int maxSupportedBdexVersion(int versionSelector) const;
653
654#ifndef BDE_OMIT_INTERNAL_DEPRECATED
655 /// Return the most current BDEX streaming version number supported by
656 /// this class. (See the package-group-level documentation for more
657 /// information on BDEX streaming of container types.)
658 int maxSupportedBdexVersion() const;
659#endif // BDE_OMIT_INTERNAL_DEPRECATED
660
661 /// Return the value of the underlying object of a (template parameter)
662 /// `TYPE` if this object is non-null, and the specified @ref default_value otherwise.
663 ///
664 /// \note Note that this method returns *by* *value*, so may be
665 /// inefficient in some contexts.
666 template <class ANY_TYPE>
667 TYPE value_or(const ANY_TYPE& default_value) const;
668
669 /// Return a pointer providing non-modifiable access to the underlying `TYPE` object.
670 ///
671 /// \pre The behavior is undefined if the object has no
672 /// value.
673 const TYPE *operator->() const;
674
675 /// Return a reference providing non-modifiable access to the underlying `TYPE` object.
676 ///
677 /// \pre The behavior is undefined if the object has no
678 /// value.
679 const TYPE& operator*() const;
680
681
682# ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
683 /// Return `true` if this object is contains a value, and `true`
684 /// otherwise.
685 BSLS_KEYWORD_EXPLICIT operator bool() const BSLS_KEYWORD_NOEXCEPT;
686# else // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
687 /// Simulation of explicit conversion to bool. Inlined to work around xlC
688 /// bug when out-of-line.
689 operator UnspecifiedBool() const BSLS_NOTHROW_SPEC
690 {
691 return UnspecifiedBoolUtil::makeValue(has_value());
692 }
693# endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT else
694
695 // Aspects
696
697 /// Return the allocator used by this object to supply memory.
699
700 /// Format this object to the specified output `stream` at the (absolute
701 /// value of) the optionally specified indentation `level` and return a
702 /// reference to `stream`. If `level` is specified, optionally specify
703 /// `spacesPerLevel`, the number of spaces per indentation level for
704 /// this and all of its nested objects. If `level` is negative,
705 /// suppress indentation of the first line. If `spacesPerLevel` is
706 /// negative, format the entire output on one line, suppressing all but
707 /// the initial indentation (as governed by `level`). If `stream` is
708 /// not valid on entry, this operation has no effect.
709 bsl::ostream& print(bsl::ostream& stream,
710 int level = 0,
711 int spacesPerLevel = 4) const;
712
713 /// Return a reference providing non-modifiable access to the underlying `TYPE` object.
714 ///
715 /// \pre The behavior is undefined unless this object is
716 /// non-null.
717 const TYPE& value() const;
718
719 // DEPRECATED FUNCTIONS
720 // provided for compatibility with NullableValue
721
722 /// Return an address providing non-modifiable access to the underlying
723 /// object of a (template parameter) `TYPE` if this object is non-null,
724 /// and the specified `address` otherwise.
725 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::addressOr",
726 "Use 'has_value() ? &value() : address' instead")
727 const TYPE *addressOr(const TYPE *address) const;
728
729#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
730// {{{ BEGIN GENERATED CODE
731// Command line: sim_cpp11_features.pl bdlb_nullableallocatedvalue.h
732#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
733#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT 10
734#endif
735#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B
736#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
737#endif
738
739#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 0
740 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
741 "Use 'emplace' instead")
742 TYPE& makeValueInplace();
743#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 0
744
745#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 1
746 template <class ARGS_01>
747 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
748 "Use 'emplace' instead")
749 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
750#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 1
751
752#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 2
753 template <class ARGS_01,
754 class ARGS_02>
755 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
756 "Use 'emplace' instead")
757 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
758 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
759#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 2
760
761#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 3
762 template <class ARGS_01,
763 class ARGS_02,
764 class ARGS_03>
765 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
766 "Use 'emplace' instead")
767 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
768 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
769 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
770#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 3
771
772#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 4
773 template <class ARGS_01,
774 class ARGS_02,
775 class ARGS_03,
776 class ARGS_04>
777 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
778 "Use 'emplace' instead")
779 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
780 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
781 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
782 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
783#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 4
784
785#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 5
786 template <class ARGS_01,
787 class ARGS_02,
788 class ARGS_03,
789 class ARGS_04,
790 class ARGS_05>
791 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
792 "Use 'emplace' instead")
793 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
794 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
795 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
796 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
797 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
798#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 5
799
800#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 6
801 template <class ARGS_01,
802 class ARGS_02,
803 class ARGS_03,
804 class ARGS_04,
805 class ARGS_05,
806 class ARGS_06>
807 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
808 "Use 'emplace' instead")
809 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
810 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
811 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
812 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
813 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
814 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
815#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 6
816
817#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 7
818 template <class ARGS_01,
819 class ARGS_02,
820 class ARGS_03,
821 class ARGS_04,
822 class ARGS_05,
823 class ARGS_06,
824 class ARGS_07>
825 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
826 "Use 'emplace' instead")
827 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
828 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
829 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
830 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
831 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
832 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
833 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
834#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 7
835
836#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 8
837 template <class ARGS_01,
838 class ARGS_02,
839 class ARGS_03,
840 class ARGS_04,
841 class ARGS_05,
842 class ARGS_06,
843 class ARGS_07,
844 class ARGS_08>
845 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
846 "Use 'emplace' instead")
847 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
848 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
849 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
850 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
851 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
852 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
853 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
854 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
855#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 8
856
857#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 9
858 template <class ARGS_01,
859 class ARGS_02,
860 class ARGS_03,
861 class ARGS_04,
862 class ARGS_05,
863 class ARGS_06,
864 class ARGS_07,
865 class ARGS_08,
866 class ARGS_09>
867 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
868 "Use 'emplace' instead")
869 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
870 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
871 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
872 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
873 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
874 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
875 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
876 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
877 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
878#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 9
879
880#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 10
881 template <class ARGS_01,
882 class ARGS_02,
883 class ARGS_03,
884 class ARGS_04,
885 class ARGS_05,
886 class ARGS_06,
887 class ARGS_07,
888 class ARGS_08,
889 class ARGS_09,
890 class ARGS_10>
891 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
892 "Use 'emplace' instead")
893 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
894 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
895 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
896 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
897 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
898 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
899 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
900 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
901 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
902 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
903#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_B >= 10
904
905#else
906// The generated code below is a workaround for the absence of perfect
907// forwarding in some compilers.
908
909 template <class... ARGS>
910 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::makeValueInplace",
911 "Use 'emplace' instead")
912 TYPE& makeValueInplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
913// }}} END GENERATED CODE
914#endif
915
916 /// Return the value of the underlying object of a (template parameter)
917 /// `TYPE` if this object is non-null, and the specified `otherValue` otherwise.
918 ///
919 /// \note Note that this method returns *by* *value*, so may be
920 /// inefficient in some contexts.
921 BSLS_DEPRECATE_FEATURE("bdl", "NullableAllocatedValue::valueOr",
922 "Use 'value_or' instead")
923 TYPE valueOr(const TYPE& otherValue) const;
924
925 /// Return an address providing non-modifiable access to the underlying
926 /// object of a (template parameter) `TYPE` if this object is non-null,
927 /// and 0 otherwise.
929 "Use 'has_value() ? &value() : NULL' instead")
930 const TYPE *valueOrNull() const;
931
932};
933
934// FREE OPERATORS
935
936/// Return `true` if the specified `lhs` and `rhs` nullable objects have the
937/// same value, and `false` otherwise. Two nullable objects have the same
938/// value if both are null, or if both are non-null and the values of their underlying objects compare equal.
939///
940/// \note Note that this function will fail to
941/// compile if `LHS_TYPE` and `RHS_TYPE` are not compatible.
942template <class LHS_TYPE, class RHS_TYPE>
943bool operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
944 const NullableAllocatedValue<RHS_TYPE>& rhs);
945
946/// Return `true` if the specified `lhs` and `rhs` objects have the same
947/// value, and `false` otherwise. A nullable object and a value of some
948/// type have the same value if the nullable object is non-null and its underlying value compares equal to the other value.
949///
950/// \note Note that this
951/// function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not
952/// compatible.
953template <class LHS_TYPE, class RHS_TYPE>
954bool operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
955 const RHS_TYPE& rhs);
956template <class LHS_TYPE, class RHS_TYPE>
957bool operator==(const LHS_TYPE& lhs,
958 const NullableAllocatedValue<RHS_TYPE>& rhs);
959
960/// Return `true` if the specified `lhs` and `rhs` nullable objects do not
961/// have the same value, and `false` otherwise. Two nullable objects do not
962/// have the same value if one is null and the other is non-null, or if both
963/// are non-null and the values of their underlying objects do not compare equal.
964///
965/// \note Note that this function will fail to compile if `LHS_TYPE` and
966/// `RHS_TYPE` are not compatible.
967template <class LHS_TYPE, class RHS_TYPE>
968bool operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
969 const NullableAllocatedValue<RHS_TYPE>& rhs);
970
971/// Return `true` if the specified `lhs` and `rhs` objects do not have the
972/// same value, and `false` otherwise. A nullable object and a value of
973/// some type do not have the same value if either the nullable object is
974/// null, or its underlying value does not compare equal to the other value.
975///
976/// \note Note that this function will fail to compile if `LHS_TYPE` and
977/// `RHS_TYPE` are not compatible.
978template <class LHS_TYPE, class RHS_TYPE>
979bool operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
980 const RHS_TYPE& rhs);
981template <class LHS_TYPE, class RHS_TYPE>
982bool operator!=(const LHS_TYPE& lhs,
983 const NullableAllocatedValue<RHS_TYPE>& rhs);
984
985/// Return `true` if the specified `lhs` nullable object is ordered before
986/// the specified `rhs` nullable object, and `false` otherwise. `lhs` is
987/// ordered before `rhs` if `lhs` is null and `rhs` is non-null or if both
988/// are non-null and `lhs.value()` is ordered before `rhs.value()`.
989///
990/// \note Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are
991/// not compatible.
992template <class LHS_TYPE, class RHS_TYPE>
993bool operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
994 const NullableAllocatedValue<RHS_TYPE>& rhs);
995
996/// Return `true` if the specified `lhs` nullable object is ordered before
997/// the specified `rhs`, and `false` otherwise. `lhs` is ordered before
998/// `rhs` if `lhs` is null or `lhs.value()` is ordered before `rhs`.
999template <class LHS_TYPE, class RHS_TYPE>
1000bool operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
1001 const RHS_TYPE& rhs);
1002
1003/// Return `true` if the specified `lhs` is ordered before the specified
1004/// `rhs` nullable object, and `false` otherwise. `lhs` is ordered before
1005/// `rhs` if `rhs` is not null and `lhs` is ordered before `rhs.value()`.
1006template <class LHS_TYPE, class RHS_TYPE>
1007bool operator<(const LHS_TYPE& lhs,
1008 const NullableAllocatedValue<RHS_TYPE>& rhs);
1009
1010
1011/// Return `true` if the specified `lhs` nullable object is ordered before
1012/// the specified `rhs` nullable object or `lhs` and `rhs` have the same
1013/// value, and `false` otherwise. (See `operator<` and `operator==`.)
1014///
1015/// \note Note that this operator returns `!(rhs < lhs)` when both operands are of
1016/// `NullableValue` type. Also note that this function will fail to compile
1017/// if `LHS_TYPE` and `RHS_TYPE` are not compatible.
1018template <class LHS_TYPE, class RHS_TYPE>
1019bool operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1020 const NullableAllocatedValue<RHS_TYPE>& rhs);
1021
1022/// Return `true` if the specified `lhs` nullable object is ordered before
1023/// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator<` and `operator==`.)
1024///
1025/// \note Note that this operator
1026/// returns `!(rhs < lhs)`.
1027template <class LHS_TYPE, class RHS_TYPE>
1028bool operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1029 const RHS_TYPE& rhs);
1030
1031/// Return `true` if the specified `lhs` is ordered before the specified
1032/// `rhs` nullable object or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator<` and `operator==`.)
1033///
1034/// \note Note that this
1035/// operator returns `!(rhs < lhs)`.
1036template <class LHS_TYPE, class RHS_TYPE>
1037bool operator<=(const LHS_TYPE& lhs,
1038 const NullableAllocatedValue<RHS_TYPE>& rhs);
1039
1040/// Return `true` if the specified `lhs` nullable object is ordered after
1041/// the specified `rhs` nullable object, and `false` otherwise. `lhs` is
1042/// ordered after `rhs` if `lhs` is non-null and `rhs` is null or if both
1043/// are non-null and `lhs.value()` is ordered after `rhs.value()`.
1044///
1045/// \note Note that this operator returns `rhs < lhs` when both operands are of
1046/// `NullableValue` type. Also note that this function will fail to compile
1047/// if `LHS_TYPE` and `RHS_TYPE` are not compatible.
1048template <class LHS_TYPE, class RHS_TYPE>
1049bool operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
1050 const NullableAllocatedValue<RHS_TYPE>& rhs);
1051
1052/// Return `true` if the specified `lhs` nullable object is ordered after
1053/// the specified `rhs`, and `false` otherwise. `lhs` is ordered after
1054/// `rhs` if `lhs` is not null and `lhs.value()` is ordered after `rhs`.
1055///
1056/// \note Note that this operator returns `rhs < lhs`.
1057template <class LHS_TYPE, class RHS_TYPE>
1058bool operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
1059 const RHS_TYPE& rhs);
1060
1061/// Return `true` if the specified `lhs` is ordered after the specified
1062/// `rhs` nullable object, and `false` otherwise. `lhs` is ordered after
1063/// `rhs` if `rhs` is null or `lhs` is ordered after `rhs.value()`.
1064///
1065/// \note Note that this operator returns `rhs < lhs`.
1066template <class LHS_TYPE, class RHS_TYPE>
1067bool operator>(const LHS_TYPE& lhs,
1068 const NullableAllocatedValue<RHS_TYPE>& rhs);
1069
1070/// Return `true` if the specified `lhs` nullable object is ordered after
1071/// the specified `rhs` nullable object or `lhs` and `rhs` have the same
1072/// value, and `false` otherwise. (See `operator>` and `operator==`.)
1073///
1074/// \note Note that this operator returns `!(lhs < rhs)` when both operands are of
1075/// `NullableValue` type. Also note that this function will fail to compile
1076/// if `LHS_TYPE` and `RHS_TYPE` are not compatible.
1077template <class LHS_TYPE, class RHS_TYPE>
1078bool operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1079 const NullableAllocatedValue<RHS_TYPE>& rhs);
1080
1081/// Return `true` if the specified `lhs` nullable object is ordered after
1082/// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator>` and `operator==`.)
1083///
1084/// \note Note that this operator
1085/// returns `!(lhs < rhs)`.
1086template <class LHS_TYPE, class RHS_TYPE>
1087bool operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1088 const RHS_TYPE& rhs);
1089
1090/// Return `true` if the specified `lhs` is ordered after the specified
1091/// `rhs` nullable object or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator>` and `operator==`.)
1092///
1093/// \note Note that this
1094/// operator returns `!(lhs < rhs)`.
1095template <class LHS_TYPE, class RHS_TYPE>
1096bool operator>=(const LHS_TYPE& lhs,
1097 const NullableAllocatedValue<RHS_TYPE>& rhs);
1098
1099/// Write the value of the specified `object` to the specified output
1100/// `stream` in a single-line format, and return a reference to `stream`.
1101/// If `stream` is not valid on entry, this operation has no effect.
1102///
1103/// \note Note that this human-readable format is not fully specified, can change
1104/// without notice, and is logically equivalent to:
1105/// @code
1106/// print(stream, 0, -1);
1107/// @endcode
1108template <class TYPE>
1109bsl::ostream& operator<<(bsl::ostream& stream,
1110 const NullableAllocatedValue<TYPE>& object);
1111
1112 //================================
1113 // Comparisons with bsl::nullopt_t
1114 //================================
1115
1116/// Return `true` if the specified `lhs` is null, and `false` otherwise.
1117template <class TYPE>
1118bool operator==(const NullableAllocatedValue<TYPE>& lhs, const bsl::nullopt_t&)
1120
1121/// Return `true` if the specified `rhs` is null, and `false` otherwise.
1122template <class TYPE>
1123bool operator==(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>& rhs)
1125
1126/// Return `true` if the specified `lhs` is not null, and `false` otherwise.
1127template <class TYPE>
1128bool operator!=(const NullableAllocatedValue<TYPE>& lhs, const bsl::nullopt_t&)
1130
1131/// Return `true` if the specified `rhs` is not null, and `false`
1132/// otherwise.
1133template <class TYPE>
1134bool operator!=(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>& rhs)
1136
1137/// Return `false`.
1138/// \note Note that `bsl::nullopt` never orders after a
1139/// `NullableAllocatedValue`.
1140template <class TYPE>
1141bool operator<(const NullableAllocatedValue<TYPE>&, const bsl::nullopt_t&)
1143
1144/// Return `true` if the specified `rhs` is not null, and `false` otherwise.
1145///
1146/// \note Note that `bsl::nullopt` is ordered before any `NullableAllocatedValue`
1147/// that is not null.
1148template <class TYPE>
1149bool operator<(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>& rhs)
1151
1152/// Return `true` if the specified `lhs` is not null, and `false`
1153/// otherwise.
1154template <class TYPE>
1155bool operator>(const NullableAllocatedValue<TYPE>& lhs, const bsl::nullopt_t&)
1157
1158/// Return `false`.
1159/// \note Note that `bsl::nullopt` never orders after a
1160/// `NullableAllocatedValue`.
1161template <class TYPE>
1162bool operator>(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>&)
1164
1165/// Return `true` if the specified `lhs` is null, and `false` otherwise.
1166template <class TYPE>
1167bool operator<=(const NullableAllocatedValue<TYPE>& lhs, const bsl::nullopt_t&)
1169
1170/// Return `true`.
1171template <class TYPE>
1172bool operator<=(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>&)
1174
1175/// Return `true`.
1176template <class TYPE>
1177bool operator>=(const NullableAllocatedValue<TYPE>&, const bsl::nullopt_t&)
1179
1180/// Return `true` if the specified `rhs` is null, and `false` otherwise.
1181template <class TYPE>
1182bool operator>=(const bsl::nullopt_t&, const NullableAllocatedValue<TYPE>& rhs)
1184
1185 //===============================
1186 // Comparisons with bsl::optional
1187 //===============================
1188
1189/// If neither of the specified `lhs` and `rhs` contain a value, return
1190/// `true`. If one contains a value, and the other does not, return
1191/// `false`. Otherwise, return `lhs.value == rhs.value()`.
1192template <class LHS_TYPE, class RHS_TYPE>
1193bool operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
1194 const bsl::optional<RHS_TYPE>& rhs);
1195template <class LHS_TYPE, class RHS_TYPE>
1196bool operator==(const bsl::optional<LHS_TYPE>& lhs,
1197 const NullableAllocatedValue<RHS_TYPE>& rhs);
1198
1199/// If neither of the specified `lhs` and `rhs` contain a value, return
1200/// `false`. If one contains a value, and the other does not, return
1201/// `true`. Otherwise, return `lhs.value != rhs.value()`.
1202template <class LHS_TYPE, class RHS_TYPE>
1203bool operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1204 const bsl::optional<RHS_TYPE>& rhs);
1205template <class LHS_TYPE, class RHS_TYPE>
1206bool operator!=(const bsl::optional<LHS_TYPE>& lhs,
1207 const NullableAllocatedValue<RHS_TYPE>& rhs);
1208
1209/// If neither of the specified `lhs` and `rhs` contain a value, return
1210/// `false`. If `lhs` contains a value, and `rhs` does not, return `false`.
1211/// If `lhs` does not contains a value, `rhs` does, return `true`.
1212/// Otherwise, return `lhs.value < rhs.value()`.
1213template <class LHS_TYPE, class RHS_TYPE>
1214bool operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
1215 const bsl::optional<RHS_TYPE>& rhs);
1216
1217/// If neither of the specified `lhs` and `rhs` contain a value, return
1218/// `false`. If `lhs` contains a value, and `rhs` does not, return `false`.
1219/// If `lhs` does not contains a value, `rhs` does, return `true`.
1220/// Otherwise, return `lhs.value < rhs.value()`.
1221template <class LHS_TYPE, class RHS_TYPE>
1222bool operator<(const bsl::optional<LHS_TYPE>& lhs,
1223 const NullableAllocatedValue<RHS_TYPE>& rhs);
1224
1225/// If neither of the specified `lhs` and `rhs` contain a value, return
1226/// `false`. If `lhs` contains a value, and `rhs` does not, return `true`.
1227/// If `lhs` does not contains a value, `rhs` does, return `false`.
1228/// Otherwise, return `lhs.value > rhs.value()`.
1229template <class LHS_TYPE, class RHS_TYPE>
1230bool operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
1231 const bsl::optional<RHS_TYPE>& rhs);
1232
1233/// If neither of the specified `lhs` and `rhs` contain a value, return
1234/// `false`. If `lhs` contains a value, and `rhs` does not, return `true`.
1235/// If `lhs` does not contains a value, `rhs` does, return `false`.
1236/// Otherwise, return `lhs.value > rhs.value()`.
1237template <class LHS_TYPE, class RHS_TYPE>
1238bool operator>(const bsl::optional<LHS_TYPE>& lhs,
1239 const NullableAllocatedValue<RHS_TYPE>& rhs);
1240
1241/// If neither of the specified `lhs` and `rhs` contain a value, return
1242/// `true`. If `lhs` contains a value, and `rhs` does not, return `false`.
1243/// If `lhs` does not contains a value, `rhs` does, return `true`.
1244/// Otherwise, return `lhs.value <= rhs.value()`.
1245template <class LHS_TYPE, class RHS_TYPE>
1246bool operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1247 const bsl::optional<RHS_TYPE>& rhs);
1248
1249/// If neither of the specified `lhs` and `rhs` contain a value, return
1250/// `true`. If `lhs` contains a value, and `rhs` does not, return `false`.
1251/// If `lhs` does not contains a value, `rhs` does, return `true`.
1252/// Otherwise, return `lhs.value <= rhs.value()`.
1253template <class LHS_TYPE, class RHS_TYPE>
1254bool operator<=(const bsl::optional<LHS_TYPE>& lhs,
1255 const NullableAllocatedValue<RHS_TYPE>& rhs);
1256
1257/// If neither of the specified `lhs` and `rhs` contain a value, return
1258/// `true`. If `lhs` contains a value, and `rhs` does not, return `true`.
1259/// If `lhs` does not contains a value, `rhs` does, return `false`.
1260/// Otherwise, return `lhs.value >= rhs.value()`.
1261template <class LHS_TYPE, class RHS_TYPE>
1262bool operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
1263 const bsl::optional<RHS_TYPE>& rhs);
1264
1265/// If neither of the specified `lhs` and `rhs` contain a value, return
1266/// `true`. If `lhs` contains a value, and `rhs` does not, return `true`.
1267/// If `lhs` does not contains a value, `rhs` does, return `false`.
1268/// Otherwise, return `lhs.value >= rhs.value()`.
1269template <class LHS_TYPE, class RHS_TYPE>
1270bool operator>=(const bsl::optional<LHS_TYPE>& lhs,
1271 const NullableAllocatedValue<RHS_TYPE>& rhs);
1272
1273// FREE FUNCTIONS
1274
1275/// Pass the boolean value of whether the specified `input` contains a value
1276/// to the specified `hashAlg` hashing algorithm of (template parameter)
1277/// type `HASHALG`. If `input` contains a value, additionally pass that
1278/// value to `hashAlg`.
1279template <class HASHALG, class TYPE>
1280void hashAppend(HASHALG& hashAlg, const NullableAllocatedValue<TYPE>& input);
1281
1282/// Exchange the values of the specified `a` and `b` objects. This function
1283/// provides the no-throw exception-safety guarantee if the two objects were
1284/// created with the same allocator and the basic guarantee otherwise.
1285template <class TYPE>
1286void swap(NullableAllocatedValue<TYPE>& a,
1287 NullableAllocatedValue<TYPE>& b);
1288
1289// ============================================================================
1290// INLINE DEFINITIONS
1291// ============================================================================
1292
1293 // ----------------------------------
1294 // class NullableAllocatedValue<TYPE>
1295 // ----------------------------------
1296
1297// CREATORS
1298template <class TYPE>
1299inline
1301: d_allocator(bslma::Default::defaultAllocator())
1302{
1303 d_storage.d_pointer_p = 0;
1304}
1305
1306template <class TYPE>
1307inline
1308NullableAllocatedValue<TYPE>
1309::NullableAllocatedValue(const bsl::allocator<char>& allocator)
1310: d_allocator(allocator.mechanism())
1311{
1312 d_storage.d_pointer_p = 0;
1313}
1314
1315template <class TYPE>
1316inline
1317NullableAllocatedValue<TYPE>::NullableAllocatedValue(const bsl::nullopt_t&)
1318: d_allocator(bslma::Default::defaultAllocator())
1319{
1320 d_storage.d_pointer_p = 0;
1321}
1322
1323template <class TYPE>
1324inline
1325NullableAllocatedValue<TYPE>
1326::NullableAllocatedValue(const bsl::nullopt_t&,
1327 const bsl::allocator<char>& allocator)
1328: d_allocator(allocator.mechanism())
1329{
1330 d_storage.d_pointer_p = 0;
1331}
1332
1333template <class TYPE>
1334inline
1335NullableAllocatedValue<TYPE>
1336::NullableAllocatedValue(const NullableAllocatedValue<TYPE>& original)
1337: d_allocator(bslma::Default::defaultAllocator())
1338{
1339 if (original.has_value()) {
1340 makeValue(original.value());
1341 }
1342 else {
1343 d_storage.d_pointer_p = 0;
1344 }
1345}
1346
1347template <class TYPE>
1348inline
1349NullableAllocatedValue<TYPE>
1350::NullableAllocatedValue(const NullableAllocatedValue<TYPE>& original,
1351 const bsl::allocator<char>& allocator)
1352: d_allocator(allocator.mechanism())
1353{
1354 if (original.has_value()) {
1355 makeValue(original.value());
1356 }
1357 else {
1358 d_storage.d_pointer_p = 0;
1359 }
1360}
1361
1362template <class TYPE>
1363inline
1364NullableAllocatedValue<TYPE>::NullableAllocatedValue(const TYPE& value)
1365: d_allocator(bslma::Default::defaultAllocator())
1366{
1367 makeValue(value);
1368}
1369
1370template <class TYPE>
1371inline
1372NullableAllocatedValue<TYPE>::NullableAllocatedValue(
1373 const TYPE& value,
1374 const bsl::allocator<char>& allocator)
1375: d_allocator(allocator.mechanism())
1376{
1377 makeValue(value);
1378}
1379
1380template <class TYPE>
1381inline
1382NullableAllocatedValue<TYPE>::~NullableAllocatedValue()
1383{
1384 reset();
1385}
1386
1387// PRIVATE CLASS METHODS
1388template <class TYPE>
1389bool NullableAllocatedValue<TYPE>::isLocal() BSLS_KEYWORD_NOEXCEPT
1390{
1391// we can store it locally if it will fit into a pointer, and it doesn't have
1392// an exceptionally large alignment requirement.
1393 return (sizeof(TYPE) <= sizeof(TYPE *)) &&
1395 (static_cast<bsl::size_t>(bsls::AlignmentFromType<TYPE >::VALUE) <=
1396 static_cast<bsl::size_t>(bsls::AlignmentFromType<TYPE *>::VALUE));
1397}
1398
1399// MANIPULATORS
1400template <class TYPE>
1401inline
1402NullableAllocatedValue<TYPE>&
1403NullableAllocatedValue<TYPE>::operator=(
1404 const NullableAllocatedValue<TYPE>& rhs)
1405{
1406 if (rhs.has_value()) {
1407 makeValue(rhs.value());
1408 }
1409 else {
1410 reset();
1411 }
1412
1413 return *this;
1414}
1415
1416template <class TYPE>
1417inline
1418NullableAllocatedValue<TYPE>&
1419NullableAllocatedValue<TYPE>::operator=(const bsl::nullopt_t&)
1420{
1421 reset();
1422 return *this;
1423}
1424
1425template <class TYPE>
1426inline
1427NullableAllocatedValue<TYPE>&
1428NullableAllocatedValue<TYPE>::operator=(const TYPE& rhs)
1429{
1430 makeValue(rhs);
1431 return *this;
1432}
1433
1434template <class TYPE>
1435template <class STREAM>
1436STREAM& NullableAllocatedValue<TYPE>::bdexStreamIn(STREAM& stream, int version)
1437{
1439
1440 char isNullFlag = 0; // Redundant initialization to suppress -Werror.
1441
1442 stream.getInt8(isNullFlag);
1443
1444 if (stream) {
1445 if (!isNullFlag) {
1446 makeValue();
1447 bdexStreamIn(stream, value(), version);
1448 }
1449 else {
1450 reset();
1451 }
1452 }
1453
1454 return stream;
1455}
1456
1457template <class TYPE>
1458inline
1459TYPE& NullableAllocatedValue<TYPE>::makeValue(const TYPE& val)
1460{
1461 if (has_value()) {
1462 TYPE &v = value();
1463 v = val;
1464 return v; // RETURN
1465 }
1466
1467 bslma::Allocator *alloc = allocator();
1468 if (isLocal()) {
1469 bslalg::ScalarPrimitives::copyConstruct(getAddress(), val, alloc);
1470 }
1471 else {
1472 TYPE *tmpPtr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1473
1474 bslma::DeallocatorProctor<bslma::Allocator> proctor(tmpPtr, alloc);
1475 bslalg::ScalarPrimitives::copyConstruct(tmpPtr, val, alloc);
1476 proctor.release();
1477 setRemoteAddress(tmpPtr);
1478 }
1479
1480 setHasValueFlag();
1481 return value();
1482}
1483
1484template <class TYPE>
1485inline
1486TYPE& NullableAllocatedValue<TYPE>::makeValue()
1487{
1488 reset();
1489
1490 // Note that this alternative implementation, instead of 'reset()',
1491 // provides stronger exception-safety, but it breaks some client code that
1492 // uses 'NullableAllocatedValue' with a non-value-semantic 'TYPE'.
1493 //..
1494 // if (d_value_p) {
1495 // *d_value_p = TYPE(allocator());
1496 // return *d_value_p; // RETURN
1497 // }
1498 //..
1499
1500 bslma::Allocator *alloc = allocator();
1501 if (isLocal()) {
1502 bslalg::ScalarPrimitives::defaultConstruct(getAddress(), alloc);
1503 }
1504 else {
1505 TYPE *tmpPtr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1506
1507 bslma::DeallocatorProctor<bslma::Allocator> proctor(tmpPtr, alloc);
1509 proctor.release();
1510 setRemoteAddress(tmpPtr);
1511 }
1512
1513 setHasValueFlag();
1514
1515 return value();
1516}
1517
1518template <class TYPE>
1519inline
1520void NullableAllocatedValue<TYPE>::reset()
1521{
1522 if (has_value()) {
1523 TYPE *p = getAddress();
1524 BSLS_ASSERT(p);
1525 p->~TYPE();
1526 if (!isLocal()) {
1527 allocator()->deallocate(p);
1528 }
1529 clearHasValueFlag();
1530 }
1531}
1532
1533template <class TYPE>
1534void NullableAllocatedValue<TYPE>::swap(NullableAllocatedValue& other)
1535{
1536 // Member 'swap' is undefined for non-equal allocators.
1537
1538 BSLS_ASSERT(allocator() == other.allocator());
1539
1540 // Nothing to do if both objects are null.
1541 if (isNull() && other.isNull()) {
1542 return; // RETURN
1543 }
1544
1545 if (isLocal()) {
1546 swapLocal(other);
1547 }
1548 else {
1549 swapRemote(other);
1550 }
1551}
1552
1553template <class TYPE>
1554inline
1555TYPE& NullableAllocatedValue<TYPE>::value()
1556{
1557 BSLS_ASSERT(has_value());
1558 return *getAddress();
1559}
1560
1561template <class TYPE>
1562inline
1563TYPE *NullableAllocatedValue<TYPE>::operator->()
1564{
1565 BSLS_ASSERT(has_value());
1566 return getAddress();
1567}
1568
1569template <class TYPE>
1570inline
1571TYPE& NullableAllocatedValue<TYPE>::operator*()
1572{
1573 BSLS_ASSERT(has_value());
1574 return value();
1575}
1576
1577#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1578// {{{ BEGIN GENERATED CODE
1579// Command line: sim_cpp11_features.pl bdlb_nullableallocatedvalue.h
1580#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
1581#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT 10
1582#endif
1583#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C
1584#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
1585#endif
1586#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 0
1587template <class TYPE>
1588inline
1589TYPE& NullableAllocatedValue<TYPE>::emplace(
1590 )
1591{
1592 bslma::Allocator *alloc = allocator();
1593 TYPE *ptr = getAddress();
1594 if (has_value()) {
1595 BSLS_ASSERT(ptr);
1596 ptr->~TYPE();
1597 clearHasValueFlag();
1598 }
1599 else if (!isLocal()) {
1600 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1601 setRemoteAddress(ptr);
1602 }
1603
1604 if (isLocal()) {
1605 BloombergLP::bslma::ConstructionUtil::construct(
1606 ptr,
1607 alloc);
1608 }
1609 else {
1611 BloombergLP::bslma::ConstructionUtil::construct(
1612 ptr,
1613 alloc);
1614 proctor.release();
1615 }
1616 setHasValueFlag();
1617 return value();
1618}
1619#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 0
1620
1621#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 1
1622template <class TYPE>
1623template <class ARGS_01>
1624inline
1625TYPE& NullableAllocatedValue<TYPE>::emplace(
1626 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
1627{
1628 bslma::Allocator *alloc = allocator();
1629 TYPE *ptr = getAddress();
1630 if (has_value()) {
1631 BSLS_ASSERT(ptr);
1632 ptr->~TYPE();
1633 clearHasValueFlag();
1634 }
1635 else if (!isLocal()) {
1636 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1637 setRemoteAddress(ptr);
1638 }
1639
1640 if (isLocal()) {
1641 BloombergLP::bslma::ConstructionUtil::construct(
1642 ptr,
1643 alloc,
1644 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
1645 }
1646 else {
1648 BloombergLP::bslma::ConstructionUtil::construct(
1649 ptr,
1650 alloc,
1651 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
1652 proctor.release();
1653 }
1654 setHasValueFlag();
1655 return value();
1656}
1657#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 1
1658
1659#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 2
1660template <class TYPE>
1661template <class ARGS_01,
1662 class ARGS_02>
1663inline
1664TYPE& NullableAllocatedValue<TYPE>::emplace(
1665 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1666 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
1667{
1668 bslma::Allocator *alloc = allocator();
1669 TYPE *ptr = getAddress();
1670 if (has_value()) {
1671 BSLS_ASSERT(ptr);
1672 ptr->~TYPE();
1673 clearHasValueFlag();
1674 }
1675 else if (!isLocal()) {
1676 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1677 setRemoteAddress(ptr);
1678 }
1679
1680 if (isLocal()) {
1681 BloombergLP::bslma::ConstructionUtil::construct(
1682 ptr,
1683 alloc,
1684 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1685 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
1686 }
1687 else {
1689 BloombergLP::bslma::ConstructionUtil::construct(
1690 ptr,
1691 alloc,
1692 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1693 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
1694 proctor.release();
1695 }
1696 setHasValueFlag();
1697 return value();
1698}
1699#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 2
1700
1701#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 3
1702template <class TYPE>
1703template <class ARGS_01,
1704 class ARGS_02,
1705 class ARGS_03>
1706inline
1707TYPE& NullableAllocatedValue<TYPE>::emplace(
1708 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1709 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1710 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
1711{
1712 bslma::Allocator *alloc = allocator();
1713 TYPE *ptr = getAddress();
1714 if (has_value()) {
1715 BSLS_ASSERT(ptr);
1716 ptr->~TYPE();
1717 clearHasValueFlag();
1718 }
1719 else if (!isLocal()) {
1720 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1721 setRemoteAddress(ptr);
1722 }
1723
1724 if (isLocal()) {
1725 BloombergLP::bslma::ConstructionUtil::construct(
1726 ptr,
1727 alloc,
1728 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1729 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1730 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
1731 }
1732 else {
1734 BloombergLP::bslma::ConstructionUtil::construct(
1735 ptr,
1736 alloc,
1737 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1738 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1739 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
1740 proctor.release();
1741 }
1742 setHasValueFlag();
1743 return value();
1744}
1745#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 3
1746
1747#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 4
1748template <class TYPE>
1749template <class ARGS_01,
1750 class ARGS_02,
1751 class ARGS_03,
1752 class ARGS_04>
1753inline
1754TYPE& NullableAllocatedValue<TYPE>::emplace(
1755 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1756 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1757 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1758 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
1759{
1760 bslma::Allocator *alloc = allocator();
1761 TYPE *ptr = getAddress();
1762 if (has_value()) {
1763 BSLS_ASSERT(ptr);
1764 ptr->~TYPE();
1765 clearHasValueFlag();
1766 }
1767 else if (!isLocal()) {
1768 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1769 setRemoteAddress(ptr);
1770 }
1771
1772 if (isLocal()) {
1773 BloombergLP::bslma::ConstructionUtil::construct(
1774 ptr,
1775 alloc,
1776 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1777 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1778 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1779 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
1780 }
1781 else {
1783 BloombergLP::bslma::ConstructionUtil::construct(
1784 ptr,
1785 alloc,
1786 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1787 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1788 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1789 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
1790 proctor.release();
1791 }
1792 setHasValueFlag();
1793 return value();
1794}
1795#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 4
1796
1797#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 5
1798template <class TYPE>
1799template <class ARGS_01,
1800 class ARGS_02,
1801 class ARGS_03,
1802 class ARGS_04,
1803 class ARGS_05>
1804inline
1805TYPE& NullableAllocatedValue<TYPE>::emplace(
1806 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1807 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1808 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1809 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1810 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
1811{
1812 bslma::Allocator *alloc = allocator();
1813 TYPE *ptr = getAddress();
1814 if (has_value()) {
1815 BSLS_ASSERT(ptr);
1816 ptr->~TYPE();
1817 clearHasValueFlag();
1818 }
1819 else if (!isLocal()) {
1820 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1821 setRemoteAddress(ptr);
1822 }
1823
1824 if (isLocal()) {
1825 BloombergLP::bslma::ConstructionUtil::construct(
1826 ptr,
1827 alloc,
1828 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1829 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1830 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1831 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1832 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
1833 }
1834 else {
1836 BloombergLP::bslma::ConstructionUtil::construct(
1837 ptr,
1838 alloc,
1839 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1840 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1841 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1842 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1843 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
1844 proctor.release();
1845 }
1846 setHasValueFlag();
1847 return value();
1848}
1849#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 5
1850
1851#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 6
1852template <class TYPE>
1853template <class ARGS_01,
1854 class ARGS_02,
1855 class ARGS_03,
1856 class ARGS_04,
1857 class ARGS_05,
1858 class ARGS_06>
1859inline
1860TYPE& NullableAllocatedValue<TYPE>::emplace(
1861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1862 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1863 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1864 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1865 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1866 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
1867{
1868 bslma::Allocator *alloc = allocator();
1869 TYPE *ptr = getAddress();
1870 if (has_value()) {
1871 BSLS_ASSERT(ptr);
1872 ptr->~TYPE();
1873 clearHasValueFlag();
1874 }
1875 else if (!isLocal()) {
1876 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1877 setRemoteAddress(ptr);
1878 }
1879
1880 if (isLocal()) {
1881 BloombergLP::bslma::ConstructionUtil::construct(
1882 ptr,
1883 alloc,
1884 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1885 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1886 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1887 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1888 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
1889 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
1890 }
1891 else {
1893 BloombergLP::bslma::ConstructionUtil::construct(
1894 ptr,
1895 alloc,
1896 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1897 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1898 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1899 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1900 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
1901 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
1902 proctor.release();
1903 }
1904 setHasValueFlag();
1905 return value();
1906}
1907#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 6
1908
1909#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 7
1910template <class TYPE>
1911template <class ARGS_01,
1912 class ARGS_02,
1913 class ARGS_03,
1914 class ARGS_04,
1915 class ARGS_05,
1916 class ARGS_06,
1917 class ARGS_07>
1918inline
1919TYPE& NullableAllocatedValue<TYPE>::emplace(
1920 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1921 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1922 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1923 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1924 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1925 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1926 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
1927{
1928 bslma::Allocator *alloc = allocator();
1929 TYPE *ptr = getAddress();
1930 if (has_value()) {
1931 BSLS_ASSERT(ptr);
1932 ptr->~TYPE();
1933 clearHasValueFlag();
1934 }
1935 else if (!isLocal()) {
1936 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
1937 setRemoteAddress(ptr);
1938 }
1939
1940 if (isLocal()) {
1941 BloombergLP::bslma::ConstructionUtil::construct(
1942 ptr,
1943 alloc,
1944 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1945 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1946 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1947 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1948 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
1949 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
1950 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
1951 }
1952 else {
1954 BloombergLP::bslma::ConstructionUtil::construct(
1955 ptr,
1956 alloc,
1957 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
1958 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
1959 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
1960 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
1961 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
1962 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
1963 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
1964 proctor.release();
1965 }
1966 setHasValueFlag();
1967 return value();
1968}
1969#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 7
1970
1971#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 8
1972template <class TYPE>
1973template <class ARGS_01,
1974 class ARGS_02,
1975 class ARGS_03,
1976 class ARGS_04,
1977 class ARGS_05,
1978 class ARGS_06,
1979 class ARGS_07,
1980 class ARGS_08>
1981inline
1982TYPE& NullableAllocatedValue<TYPE>::emplace(
1983 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1984 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1985 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1986 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1987 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1988 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1989 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1990 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
1991{
1992 bslma::Allocator *alloc = allocator();
1993 TYPE *ptr = getAddress();
1994 if (has_value()) {
1995 BSLS_ASSERT(ptr);
1996 ptr->~TYPE();
1997 clearHasValueFlag();
1998 }
1999 else if (!isLocal()) {
2000 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2001 setRemoteAddress(ptr);
2002 }
2003
2004 if (isLocal()) {
2005 BloombergLP::bslma::ConstructionUtil::construct(
2006 ptr,
2007 alloc,
2008 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2009 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2010 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2011 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2012 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2013 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2014 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2015 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
2016 }
2017 else {
2019 BloombergLP::bslma::ConstructionUtil::construct(
2020 ptr,
2021 alloc,
2022 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2023 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2024 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2025 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2026 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2027 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2028 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2029 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
2030 proctor.release();
2031 }
2032 setHasValueFlag();
2033 return value();
2034}
2035#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 8
2036
2037#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 9
2038template <class TYPE>
2039template <class ARGS_01,
2040 class ARGS_02,
2041 class ARGS_03,
2042 class ARGS_04,
2043 class ARGS_05,
2044 class ARGS_06,
2045 class ARGS_07,
2046 class ARGS_08,
2047 class ARGS_09>
2048inline
2049TYPE& NullableAllocatedValue<TYPE>::emplace(
2050 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2051 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2052 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2053 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2054 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2055 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2056 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2057 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2058 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
2059{
2060 bslma::Allocator *alloc = allocator();
2061 TYPE *ptr = getAddress();
2062 if (has_value()) {
2063 BSLS_ASSERT(ptr);
2064 ptr->~TYPE();
2065 clearHasValueFlag();
2066 }
2067 else if (!isLocal()) {
2068 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2069 setRemoteAddress(ptr);
2070 }
2071
2072 if (isLocal()) {
2073 BloombergLP::bslma::ConstructionUtil::construct(
2074 ptr,
2075 alloc,
2076 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2077 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2078 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2079 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2080 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2081 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2082 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2083 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2084 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
2085 }
2086 else {
2088 BloombergLP::bslma::ConstructionUtil::construct(
2089 ptr,
2090 alloc,
2091 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2092 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2093 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2094 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2095 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2096 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2097 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2098 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2099 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
2100 proctor.release();
2101 }
2102 setHasValueFlag();
2103 return value();
2104}
2105#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 9
2106
2107#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 10
2108template <class TYPE>
2109template <class ARGS_01,
2110 class ARGS_02,
2111 class ARGS_03,
2112 class ARGS_04,
2113 class ARGS_05,
2114 class ARGS_06,
2115 class ARGS_07,
2116 class ARGS_08,
2117 class ARGS_09,
2118 class ARGS_10>
2119inline
2120TYPE& NullableAllocatedValue<TYPE>::emplace(
2121 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2122 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2123 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2124 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2125 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2126 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2127 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2128 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2129 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2130 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
2131{
2132 bslma::Allocator *alloc = allocator();
2133 TYPE *ptr = getAddress();
2134 if (has_value()) {
2135 BSLS_ASSERT(ptr);
2136 ptr->~TYPE();
2137 clearHasValueFlag();
2138 }
2139 else if (!isLocal()) {
2140 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2141 setRemoteAddress(ptr);
2142 }
2143
2144 if (isLocal()) {
2145 BloombergLP::bslma::ConstructionUtil::construct(
2146 ptr,
2147 alloc,
2148 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2149 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2150 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2151 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2152 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2153 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2154 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2155 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2156 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
2157 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
2158 }
2159 else {
2161 BloombergLP::bslma::ConstructionUtil::construct(
2162 ptr,
2163 alloc,
2164 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2165 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2166 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2167 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2168 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2169 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2170 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2171 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2172 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
2173 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
2174 proctor.release();
2175 }
2176 setHasValueFlag();
2177 return value();
2178}
2179#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 10
2180
2181
2182# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2183#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 0
2184template <class TYPE>
2185template <class INIT_LIST_TYPE>
2186TYPE& NullableAllocatedValue<TYPE>::emplace(
2187 std::initializer_list<INIT_LIST_TYPE> il)
2188{
2189 bslma::Allocator *alloc = allocator();
2190 TYPE *ptr = getAddress();
2191 if (has_value()) {
2192 BSLS_ASSERT(ptr);
2193 ptr->~TYPE();
2194 clearHasValueFlag();
2195 }
2196 else if (!isLocal()) {
2197 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2198 setRemoteAddress(ptr);
2199 }
2200
2201 if (isLocal()) {
2202 BloombergLP::bslma::ConstructionUtil::construct(
2203 ptr,
2204 alloc,
2205 il);
2206 }
2207 else {
2209 BloombergLP::bslma::ConstructionUtil::construct(
2210 ptr,
2211 alloc,
2212 il);
2213 proctor.release();
2214 }
2215 setHasValueFlag();
2216 return value();
2217}
2218#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 0
2219
2220#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 1
2221template <class TYPE>
2222template <class INIT_LIST_TYPE, class ARGS_01>
2223TYPE& NullableAllocatedValue<TYPE>::emplace(
2224 std::initializer_list<INIT_LIST_TYPE> il,
2225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
2226{
2227 bslma::Allocator *alloc = allocator();
2228 TYPE *ptr = getAddress();
2229 if (has_value()) {
2230 BSLS_ASSERT(ptr);
2231 ptr->~TYPE();
2232 clearHasValueFlag();
2233 }
2234 else if (!isLocal()) {
2235 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2236 setRemoteAddress(ptr);
2237 }
2238
2239 if (isLocal()) {
2240 BloombergLP::bslma::ConstructionUtil::construct(
2241 ptr,
2242 alloc,
2243 il,
2244 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
2245 }
2246 else {
2248 BloombergLP::bslma::ConstructionUtil::construct(
2249 ptr,
2250 alloc,
2251 il,
2252 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
2253 proctor.release();
2254 }
2255 setHasValueFlag();
2256 return value();
2257}
2258#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 1
2259
2260#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 2
2261template <class TYPE>
2262template <class INIT_LIST_TYPE, class ARGS_01,
2263 class ARGS_02>
2264TYPE& NullableAllocatedValue<TYPE>::emplace(
2265 std::initializer_list<INIT_LIST_TYPE> il,
2266 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2267 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
2268{
2269 bslma::Allocator *alloc = allocator();
2270 TYPE *ptr = getAddress();
2271 if (has_value()) {
2272 BSLS_ASSERT(ptr);
2273 ptr->~TYPE();
2274 clearHasValueFlag();
2275 }
2276 else if (!isLocal()) {
2277 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2278 setRemoteAddress(ptr);
2279 }
2280
2281 if (isLocal()) {
2282 BloombergLP::bslma::ConstructionUtil::construct(
2283 ptr,
2284 alloc,
2285 il,
2286 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2287 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
2288 }
2289 else {
2291 BloombergLP::bslma::ConstructionUtil::construct(
2292 ptr,
2293 alloc,
2294 il,
2295 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2296 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
2297 proctor.release();
2298 }
2299 setHasValueFlag();
2300 return value();
2301}
2302#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 2
2303
2304#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 3
2305template <class TYPE>
2306template <class INIT_LIST_TYPE, class ARGS_01,
2307 class ARGS_02,
2308 class ARGS_03>
2309TYPE& NullableAllocatedValue<TYPE>::emplace(
2310 std::initializer_list<INIT_LIST_TYPE> il,
2311 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2312 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2313 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
2314{
2315 bslma::Allocator *alloc = allocator();
2316 TYPE *ptr = getAddress();
2317 if (has_value()) {
2318 BSLS_ASSERT(ptr);
2319 ptr->~TYPE();
2320 clearHasValueFlag();
2321 }
2322 else if (!isLocal()) {
2323 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2324 setRemoteAddress(ptr);
2325 }
2326
2327 if (isLocal()) {
2328 BloombergLP::bslma::ConstructionUtil::construct(
2329 ptr,
2330 alloc,
2331 il,
2332 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2333 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2334 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
2335 }
2336 else {
2338 BloombergLP::bslma::ConstructionUtil::construct(
2339 ptr,
2340 alloc,
2341 il,
2342 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2343 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2344 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
2345 proctor.release();
2346 }
2347 setHasValueFlag();
2348 return value();
2349}
2350#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 3
2351
2352#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 4
2353template <class TYPE>
2354template <class INIT_LIST_TYPE, class ARGS_01,
2355 class ARGS_02,
2356 class ARGS_03,
2357 class ARGS_04>
2358TYPE& NullableAllocatedValue<TYPE>::emplace(
2359 std::initializer_list<INIT_LIST_TYPE> il,
2360 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2361 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2362 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2363 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
2364{
2365 bslma::Allocator *alloc = allocator();
2366 TYPE *ptr = getAddress();
2367 if (has_value()) {
2368 BSLS_ASSERT(ptr);
2369 ptr->~TYPE();
2370 clearHasValueFlag();
2371 }
2372 else if (!isLocal()) {
2373 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2374 setRemoteAddress(ptr);
2375 }
2376
2377 if (isLocal()) {
2378 BloombergLP::bslma::ConstructionUtil::construct(
2379 ptr,
2380 alloc,
2381 il,
2382 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2383 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2384 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2385 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
2386 }
2387 else {
2389 BloombergLP::bslma::ConstructionUtil::construct(
2390 ptr,
2391 alloc,
2392 il,
2393 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2394 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2395 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2396 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
2397 proctor.release();
2398 }
2399 setHasValueFlag();
2400 return value();
2401}
2402#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 4
2403
2404#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 5
2405template <class TYPE>
2406template <class INIT_LIST_TYPE, class ARGS_01,
2407 class ARGS_02,
2408 class ARGS_03,
2409 class ARGS_04,
2410 class ARGS_05>
2411TYPE& NullableAllocatedValue<TYPE>::emplace(
2412 std::initializer_list<INIT_LIST_TYPE> il,
2413 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2414 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2415 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2416 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2417 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
2418{
2419 bslma::Allocator *alloc = allocator();
2420 TYPE *ptr = getAddress();
2421 if (has_value()) {
2422 BSLS_ASSERT(ptr);
2423 ptr->~TYPE();
2424 clearHasValueFlag();
2425 }
2426 else if (!isLocal()) {
2427 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2428 setRemoteAddress(ptr);
2429 }
2430
2431 if (isLocal()) {
2432 BloombergLP::bslma::ConstructionUtil::construct(
2433 ptr,
2434 alloc,
2435 il,
2436 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2437 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2438 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2439 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2440 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
2441 }
2442 else {
2444 BloombergLP::bslma::ConstructionUtil::construct(
2445 ptr,
2446 alloc,
2447 il,
2448 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2449 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2450 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2451 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2452 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
2453 proctor.release();
2454 }
2455 setHasValueFlag();
2456 return value();
2457}
2458#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 5
2459
2460#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 6
2461template <class TYPE>
2462template <class INIT_LIST_TYPE, class ARGS_01,
2463 class ARGS_02,
2464 class ARGS_03,
2465 class ARGS_04,
2466 class ARGS_05,
2467 class ARGS_06>
2468TYPE& NullableAllocatedValue<TYPE>::emplace(
2469 std::initializer_list<INIT_LIST_TYPE> il,
2470 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2471 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2472 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2474 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2475 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
2476{
2477 bslma::Allocator *alloc = allocator();
2478 TYPE *ptr = getAddress();
2479 if (has_value()) {
2480 BSLS_ASSERT(ptr);
2481 ptr->~TYPE();
2482 clearHasValueFlag();
2483 }
2484 else if (!isLocal()) {
2485 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2486 setRemoteAddress(ptr);
2487 }
2488
2489 if (isLocal()) {
2490 BloombergLP::bslma::ConstructionUtil::construct(
2491 ptr,
2492 alloc,
2493 il,
2494 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2495 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2496 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2497 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2498 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2499 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
2500 }
2501 else {
2503 BloombergLP::bslma::ConstructionUtil::construct(
2504 ptr,
2505 alloc,
2506 il,
2507 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2508 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2509 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2510 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2511 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2512 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
2513 proctor.release();
2514 }
2515 setHasValueFlag();
2516 return value();
2517}
2518#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 6
2519
2520#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 7
2521template <class TYPE>
2522template <class INIT_LIST_TYPE, class ARGS_01,
2523 class ARGS_02,
2524 class ARGS_03,
2525 class ARGS_04,
2526 class ARGS_05,
2527 class ARGS_06,
2528 class ARGS_07>
2529TYPE& NullableAllocatedValue<TYPE>::emplace(
2530 std::initializer_list<INIT_LIST_TYPE> il,
2531 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2532 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2533 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2534 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2535 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2536 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2537 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
2538{
2539 bslma::Allocator *alloc = allocator();
2540 TYPE *ptr = getAddress();
2541 if (has_value()) {
2542 BSLS_ASSERT(ptr);
2543 ptr->~TYPE();
2544 clearHasValueFlag();
2545 }
2546 else if (!isLocal()) {
2547 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2548 setRemoteAddress(ptr);
2549 }
2550
2551 if (isLocal()) {
2552 BloombergLP::bslma::ConstructionUtil::construct(
2553 ptr,
2554 alloc,
2555 il,
2556 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2557 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2558 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2559 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2560 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2561 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2562 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
2563 }
2564 else {
2566 BloombergLP::bslma::ConstructionUtil::construct(
2567 ptr,
2568 alloc,
2569 il,
2570 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2571 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2572 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2573 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2574 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2575 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2576 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
2577 proctor.release();
2578 }
2579 setHasValueFlag();
2580 return value();
2581}
2582#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 7
2583
2584#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 8
2585template <class TYPE>
2586template <class INIT_LIST_TYPE, class ARGS_01,
2587 class ARGS_02,
2588 class ARGS_03,
2589 class ARGS_04,
2590 class ARGS_05,
2591 class ARGS_06,
2592 class ARGS_07,
2593 class ARGS_08>
2594TYPE& NullableAllocatedValue<TYPE>::emplace(
2595 std::initializer_list<INIT_LIST_TYPE> il,
2596 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2597 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2598 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2599 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2600 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2601 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2602 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2603 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
2604{
2605 bslma::Allocator *alloc = allocator();
2606 TYPE *ptr = getAddress();
2607 if (has_value()) {
2608 BSLS_ASSERT(ptr);
2609 ptr->~TYPE();
2610 clearHasValueFlag();
2611 }
2612 else if (!isLocal()) {
2613 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2614 setRemoteAddress(ptr);
2615 }
2616
2617 if (isLocal()) {
2618 BloombergLP::bslma::ConstructionUtil::construct(
2619 ptr,
2620 alloc,
2621 il,
2622 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2623 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2624 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2625 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2626 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2627 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2628 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2629 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
2630 }
2631 else {
2633 BloombergLP::bslma::ConstructionUtil::construct(
2634 ptr,
2635 alloc,
2636 il,
2637 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2638 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2639 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2640 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2641 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2642 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2643 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2644 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
2645 proctor.release();
2646 }
2647 setHasValueFlag();
2648 return value();
2649}
2650#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 8
2651
2652#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 9
2653template <class TYPE>
2654template <class INIT_LIST_TYPE, class ARGS_01,
2655 class ARGS_02,
2656 class ARGS_03,
2657 class ARGS_04,
2658 class ARGS_05,
2659 class ARGS_06,
2660 class ARGS_07,
2661 class ARGS_08,
2662 class ARGS_09>
2663TYPE& NullableAllocatedValue<TYPE>::emplace(
2664 std::initializer_list<INIT_LIST_TYPE> il,
2665 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2666 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2667 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2668 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2669 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2670 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2671 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2672 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2673 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
2674{
2675 bslma::Allocator *alloc = allocator();
2676 TYPE *ptr = getAddress();
2677 if (has_value()) {
2678 BSLS_ASSERT(ptr);
2679 ptr->~TYPE();
2680 clearHasValueFlag();
2681 }
2682 else if (!isLocal()) {
2683 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2684 setRemoteAddress(ptr);
2685 }
2686
2687 if (isLocal()) {
2688 BloombergLP::bslma::ConstructionUtil::construct(
2689 ptr,
2690 alloc,
2691 il,
2692 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2693 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2694 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2695 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2696 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2697 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2698 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2699 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2700 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
2701 }
2702 else {
2704 BloombergLP::bslma::ConstructionUtil::construct(
2705 ptr,
2706 alloc,
2707 il,
2708 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2709 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2710 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2711 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2712 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2713 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2714 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2715 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2716 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
2717 proctor.release();
2718 }
2719 setHasValueFlag();
2720 return value();
2721}
2722#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 9
2723
2724#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 10
2725template <class TYPE>
2726template <class INIT_LIST_TYPE, class ARGS_01,
2727 class ARGS_02,
2728 class ARGS_03,
2729 class ARGS_04,
2730 class ARGS_05,
2731 class ARGS_06,
2732 class ARGS_07,
2733 class ARGS_08,
2734 class ARGS_09,
2735 class ARGS_10>
2736TYPE& NullableAllocatedValue<TYPE>::emplace(
2737 std::initializer_list<INIT_LIST_TYPE> il,
2738 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2739 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2740 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2741 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2742 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2743 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2744 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2745 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2746 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2747 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
2748{
2749 bslma::Allocator *alloc = allocator();
2750 TYPE *ptr = getAddress();
2751 if (has_value()) {
2752 BSLS_ASSERT(ptr);
2753 ptr->~TYPE();
2754 clearHasValueFlag();
2755 }
2756 else if (!isLocal()) {
2757 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2758 setRemoteAddress(ptr);
2759 }
2760
2761 if (isLocal()) {
2762 BloombergLP::bslma::ConstructionUtil::construct(
2763 ptr,
2764 alloc,
2765 il,
2766 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2767 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2768 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2769 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2770 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2771 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2772 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2773 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2774 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
2775 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
2776 }
2777 else {
2779 BloombergLP::bslma::ConstructionUtil::construct(
2780 ptr,
2781 alloc,
2782 il,
2783 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
2784 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
2785 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
2786 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
2787 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
2788 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
2789 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
2790 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
2791 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
2792 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
2793 proctor.release();
2794 }
2795 setHasValueFlag();
2796 return value();
2797}
2798#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_C >= 10
2799
2800# endif
2801#else
2802// The generated code below is a workaround for the absence of perfect
2803// forwarding in some compilers.
2804template <class TYPE>
2805template <class... ARGS>
2806inline
2807TYPE& NullableAllocatedValue<TYPE>::emplace(
2809{
2810 bslma::Allocator *alloc = allocator();
2811 TYPE *ptr = getAddress();
2812 if (has_value()) {
2813 BSLS_ASSERT(ptr);
2814 ptr->~TYPE();
2815 clearHasValueFlag();
2816 }
2817 else if (!isLocal()) {
2818 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2819 setRemoteAddress(ptr);
2820 }
2821
2822 if (isLocal()) {
2823 BloombergLP::bslma::ConstructionUtil::construct(
2824 ptr,
2825 alloc,
2826 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
2827 }
2828 else {
2830 BloombergLP::bslma::ConstructionUtil::construct(
2831 ptr,
2832 alloc,
2833 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
2834 proctor.release();
2835 }
2836 setHasValueFlag();
2837 return value();
2838}
2839
2840# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2841template <class TYPE>
2842template <class INIT_LIST_TYPE, class... ARGS>
2843TYPE& NullableAllocatedValue<TYPE>::emplace(
2844 std::initializer_list<INIT_LIST_TYPE> il,
2846{
2847 bslma::Allocator *alloc = allocator();
2848 TYPE *ptr = getAddress();
2849 if (has_value()) {
2850 BSLS_ASSERT(ptr);
2851 ptr->~TYPE();
2852 clearHasValueFlag();
2853 }
2854 else if (!isLocal()) {
2855 ptr = reinterpret_cast<TYPE *>(alloc->allocate(sizeof(TYPE)));
2856 setRemoteAddress(ptr);
2857 }
2858
2859 if (isLocal()) {
2860 BloombergLP::bslma::ConstructionUtil::construct(
2861 ptr,
2862 alloc,
2863 il,
2864 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
2865 }
2866 else {
2868 BloombergLP::bslma::ConstructionUtil::construct(
2869 ptr,
2870 alloc,
2871 il,
2872 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
2873 proctor.release();
2874 }
2875 setHasValueFlag();
2876 return value();
2877}
2878# endif
2879// }}} END GENERATED CODE
2880#endif
2881
2882// PRIVATE ACCESSORS
2883template <class TYPE>
2884inline
2885TYPE *NullableAllocatedValue<TYPE>::getAddress() {
2886 if (isLocal()) {
2887 return reinterpret_cast<TYPE *>(
2888 static_cast<void *>(d_storage.d_buffer)); // RETURN
2889 }
2890 else {
2891 return d_storage.d_pointer_p; // RETURN
2892 }
2893}
2894
2895template <class TYPE>
2896inline
2897const TYPE *NullableAllocatedValue<TYPE>::getAddress() const {
2898 if (isLocal()) {
2899 return reinterpret_cast<const TYPE *>(
2900 static_cast<const void *>(d_storage.d_buffer)); // RETURN
2901 }
2902 else {
2903 return d_storage.d_pointer_p; // RETURN
2904 }
2905}
2906
2907// PRIVATE MANIPULATORS
2908template <class TYPE>
2909inline
2910void NullableAllocatedValue<TYPE>::clearHasValueFlag() BSLS_KEYWORD_NOEXCEPT
2911{
2912 d_allocator.clearFlag(k_HAS_VALUE);
2913}
2914
2915template <class TYPE>
2916inline
2917void NullableAllocatedValue<TYPE>::setHasValueFlag() BSLS_KEYWORD_NOEXCEPT
2918{
2919 d_allocator.setFlag(k_HAS_VALUE);
2920}
2921
2922template <class TYPE>
2923inline
2924void NullableAllocatedValue<TYPE>::setRemoteAddress(TYPE *newPtr) {
2925 BSLS_ASSERT(!isLocal());
2926 d_storage.d_pointer_p = newPtr;
2927}
2928
2929template <class TYPE>
2930inline
2931void NullableAllocatedValue<TYPE>::swapLocal(NullableAllocatedValue& other)
2932{
2933// At most one of 'isNull()' and 'other.isNull()' is true
2934// Swapping the 'd_allocator's would be wrong here.
2935 if (isNull()) {
2936 makeValue(other.value());
2937 other.reset();
2938 }
2939 else if (other.isNull()) {
2940 other.makeValue(value());
2941 reset();
2942 }
2943 else {
2944 bslalg::SwapUtil::swap(getAddress(), other.getAddress());
2945 }
2946}
2947
2948template <class TYPE>
2949inline
2950void NullableAllocatedValue<TYPE>::swapRemote(NullableAllocatedValue& other)
2951{
2952 bslalg::SwapUtil::swap(&d_allocator, &other.d_allocator);
2953 bslalg::SwapUtil::swap(& d_storage.d_pointer_p,
2954 &other.d_storage.d_pointer_p);
2955}
2956
2957// ACCESSORS
2958template <class TYPE>
2959template <class STREAM>
2960STREAM& NullableAllocatedValue<TYPE>::bdexStreamOut(STREAM& stream,
2961 int version) const
2962{
2964
2965 stream.putInt8(has_value() ? 0 : 1);
2966
2967 if (has_value()) {
2968 bdexStreamOut(stream, value(), version);
2969 }
2970
2971 return stream;
2972}
2973
2974template <class TYPE>
2975inline
2976bsl::allocator<char> NullableAllocatedValue<TYPE>::get_allocator() const
2977{
2978 return allocator();
2979}
2980
2981
2982template <class TYPE>
2983inline
2984bool NullableAllocatedValue<TYPE>::has_value() const BSLS_KEYWORD_NOEXCEPT
2985{
2986 return d_allocator.readFlag(k_HAS_VALUE);
2987}
2988
2989template <class TYPE>
2990inline
2991bool NullableAllocatedValue<TYPE>::isNull() const BSLS_KEYWORD_NOEXCEPT
2992{
2993 return !has_value();
2994}
2995
2996# ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
2997template <class TYPE>
2998NullableAllocatedValue<TYPE>::operator bool() const BSLS_KEYWORD_NOEXCEPT
2999{
3000 return has_value();
3001}
3002# endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
3003
3004template <class TYPE>
3005inline
3006int NullableAllocatedValue<TYPE>::maxSupportedBdexVersion(
3007 int versionSelector) const
3008{
3010
3011 // We need to call the 'bslx::VersionFunctions' helper function, because we
3012 // cannot guarantee that 'TYPE' implements 'maxSupportedBdexVersion' as a
3013 // class method.
3014
3015 return maxSupportedBdexVersion(reinterpret_cast<TYPE *>(0),
3016 versionSelector);
3017}
3018
3019#ifndef BDE_OMIT_INTERNAL_DEPRECATED
3020template <class TYPE>
3021inline
3022int NullableAllocatedValue<TYPE>::maxSupportedBdexVersion() const
3023{
3024 return maxSupportedBdexVersion(0);
3025}
3026#endif // BDE_OMIT_INTERNAL_DEPRECATED
3027
3028template <class TYPE>
3029template <class ANY_TYPE>
3030inline TYPE
3031NullableAllocatedValue<TYPE>::value_or(const ANY_TYPE& default_value) const
3032{
3033 return has_value() ? value() : static_cast<TYPE>(default_value);
3034}
3035
3036template <class TYPE>
3037inline
3038const TYPE *NullableAllocatedValue<TYPE>::operator->() const
3039{
3040 BSLS_ASSERT(has_value());
3041 return &value();
3042}
3043
3044template <class TYPE>
3045inline
3046const TYPE& NullableAllocatedValue<TYPE>::operator*() const
3047{
3048 BSLS_ASSERT(has_value());
3049 return value();
3050}
3051
3052 // Aspects
3053
3054template <class TYPE>
3055inline
3056bslma::Allocator *NullableAllocatedValue<TYPE>::allocator() const
3057{
3058 return d_allocator.getPointer();
3059}
3060
3061template <class TYPE>
3062inline
3063bsl::ostream& NullableAllocatedValue<TYPE>::print(
3064 bsl::ostream& stream,
3065 int level,
3066 int spacesPerLevel) const
3067{
3068 if (!has_value()) {
3069 return bdlb::PrintMethods::print(stream,
3070 "NULL",
3071 level,
3072 spacesPerLevel); // RETURN
3073 }
3074
3075 return bdlb::PrintMethods::print(stream, value(), level, spacesPerLevel);
3076}
3077
3078template <class TYPE>
3079inline
3080const TYPE& NullableAllocatedValue<TYPE>::value() const
3081{
3082#ifndef BDE_OMIT_INTERNAL_DEPRECATED
3083 // TBD: The assert below was commented out because a call to this function
3084 // is sometimes used as an argument to a template function that only looks
3085 // at the value type (and does not access the value).
3086
3087 // BSLS_REVIEW(has_value());
3088#else
3089 BSLS_ASSERT(has_value());
3090#endif
3091
3092 return *getAddress();
3093}
3094
3095// DEPRECATED FUNCTIONS
3096
3097template <class TYPE>
3098inline
3099const TYPE *NullableAllocatedValue<TYPE>::addressOr(const TYPE *address) const
3100{
3101 return has_value() ? &value() : address;
3102}
3103
3104#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3105// {{{ BEGIN GENERATED CODE
3106// Command line: sim_cpp11_features.pl bdlb_nullableallocatedvalue.h
3107#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
3108#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT 10
3109#endif
3110#ifndef BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D
3111#define BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT
3112#endif
3113#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 0
3114template <class TYPE>
3115inline
3116TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3117 )
3118{
3119 return emplace();
3120}
3121#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 0
3122
3123#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 1
3124template <class TYPE>
3125template <class ARGS_01>
3126inline
3127TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3128 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
3129{
3130 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
3131}
3132#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 1
3133
3134#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 2
3135template <class TYPE>
3136template <class ARGS_01,
3137 class ARGS_02>
3138inline
3139TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3140 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3141 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
3142{
3143 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3144 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
3145}
3146#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 2
3147
3148#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 3
3149template <class TYPE>
3150template <class ARGS_01,
3151 class ARGS_02,
3152 class ARGS_03>
3153inline
3154TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3156 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3157 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
3158{
3159 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3160 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3161 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
3162}
3163#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 3
3164
3165#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 4
3166template <class TYPE>
3167template <class ARGS_01,
3168 class ARGS_02,
3169 class ARGS_03,
3170 class ARGS_04>
3171inline
3172TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3173 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3174 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3175 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3176 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
3177{
3178 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3179 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3180 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3181 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
3182}
3183#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 4
3184
3185#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 5
3186template <class TYPE>
3187template <class ARGS_01,
3188 class ARGS_02,
3189 class ARGS_03,
3190 class ARGS_04,
3191 class ARGS_05>
3192inline
3193TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3194 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3195 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3196 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3197 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3198 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
3199{
3200 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3201 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3202 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3203 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3204 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
3205}
3206#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 5
3207
3208#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 6
3209template <class TYPE>
3210template <class ARGS_01,
3211 class ARGS_02,
3212 class ARGS_03,
3213 class ARGS_04,
3214 class ARGS_05,
3215 class ARGS_06>
3216inline
3217TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3218 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3219 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
3224{
3225 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3226 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3227 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3228 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3229 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
3230 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
3231}
3232#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 6
3233
3234#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 7
3235template <class TYPE>
3236template <class ARGS_01,
3237 class ARGS_02,
3238 class ARGS_03,
3239 class ARGS_04,
3240 class ARGS_05,
3241 class ARGS_06,
3242 class ARGS_07>
3243inline
3244TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3245 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3246 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3247 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3248 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3249 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3250 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3251 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
3252{
3253 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3254 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3255 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3256 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3257 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
3258 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
3259 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
3260}
3261#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 7
3262
3263#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 8
3264template <class TYPE>
3265template <class ARGS_01,
3266 class ARGS_02,
3267 class ARGS_03,
3268 class ARGS_04,
3269 class ARGS_05,
3270 class ARGS_06,
3271 class ARGS_07,
3272 class ARGS_08>
3273inline
3274TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3275 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3280 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3281 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3282 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
3283{
3284 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3285 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3286 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3287 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3288 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
3289 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
3290 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
3291 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
3292}
3293#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 8
3294
3295#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 9
3296template <class TYPE>
3297template <class ARGS_01,
3298 class ARGS_02,
3299 class ARGS_03,
3300 class ARGS_04,
3301 class ARGS_05,
3302 class ARGS_06,
3303 class ARGS_07,
3304 class ARGS_08,
3305 class ARGS_09>
3306inline
3307TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3309 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3310 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3311 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3312 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3313 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3314 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3315 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3316 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
3317{
3318 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3319 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3320 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3321 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3322 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
3323 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
3324 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
3325 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
3326 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
3327}
3328#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 9
3329
3330#if BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 10
3331template <class TYPE>
3332template <class ARGS_01,
3333 class ARGS_02,
3334 class ARGS_03,
3335 class ARGS_04,
3336 class ARGS_05,
3337 class ARGS_06,
3338 class ARGS_07,
3339 class ARGS_08,
3340 class ARGS_09,
3341 class ARGS_10>
3342inline
3343TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
3345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
3346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
3347 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
3348 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
3349 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
3350 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
3351 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
3352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
3353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
3354{
3355 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
3356 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
3357 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
3358 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
3359 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
3360 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
3361 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
3362 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
3363 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
3364 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
3365}
3366#endif // BDLB_NULLABLEALLOCATEDVALUE_VARIADIC_LIMIT_D >= 10
3367
3368#else
3369// The generated code below is a workaround for the absence of perfect
3370// forwarding in some compilers.
3371template <class TYPE>
3372template <class... ARGS>
3373inline
3374TYPE& NullableAllocatedValue<TYPE>::makeValueInplace(
3376{
3377 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
3378}
3379// }}} END GENERATED CODE
3380#endif
3381
3382template <class TYPE>
3383inline
3384TYPE NullableAllocatedValue<TYPE>::valueOr(const TYPE& otherValue) const
3385{
3386 return has_value() ? value() : otherValue;
3387}
3388
3389template <class TYPE>
3390inline
3391const TYPE *NullableAllocatedValue<TYPE>::valueOrNull() const {
3392 return has_value() ? &value() : NULL;
3393}
3394
3395} // close package namespace
3396
3397// FREE OPERATORS
3398template <class LHS_TYPE, class RHS_TYPE>
3399inline
3400bool bdlb::operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
3401 const NullableAllocatedValue<RHS_TYPE>& rhs)
3402{
3403 if (lhs.isNull()) {
3404 return rhs.isNull(); // RETURN
3405 }
3406
3407 return rhs.isNull() ? false : lhs.value() == rhs.value();
3408}
3409
3410template <class LHS_TYPE, class RHS_TYPE>
3411inline
3412bool bdlb::operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
3413 const RHS_TYPE& rhs)
3414{
3415 return lhs.isNull() ? false : lhs.value() == rhs;
3416}
3417
3418template <class LHS_TYPE, class RHS_TYPE>
3419inline
3420bool bdlb::operator==(const LHS_TYPE& lhs,
3421 const NullableAllocatedValue<RHS_TYPE>& rhs)
3422{
3423 return rhs.isNull() ? false : lhs == rhs.value();
3424}
3425
3426template <class LHS_TYPE, class RHS_TYPE>
3427inline
3428bool bdlb::operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3429 const NullableAllocatedValue<RHS_TYPE>& rhs)
3430{
3431 if (lhs.isNull()) {
3432 return !rhs.isNull(); // RETURN
3433 }
3434
3435 return rhs.isNull() ? true : lhs.value() != rhs.value();
3436}
3437
3438template <class LHS_TYPE, class RHS_TYPE>
3439inline
3440bool bdlb::operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3441 const RHS_TYPE& rhs)
3442{
3443 return lhs.isNull() ? true : lhs.value() != rhs;
3444}
3445
3446template <class LHS_TYPE, class RHS_TYPE>
3447inline
3448bool bdlb::operator!=(const LHS_TYPE& lhs,
3449 const NullableAllocatedValue<RHS_TYPE>& rhs)
3450{
3451 return rhs.isNull() ? true : lhs != rhs.value();
3452}
3453
3454template <class LHS_TYPE, class RHS_TYPE>
3455inline
3456bool bdlb::operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
3457 const NullableAllocatedValue<RHS_TYPE>& rhs)
3458{
3459 if (rhs.isNull()) {
3460 return false; // RETURN
3461 }
3462
3463 return lhs.isNull() ? true : lhs.value() < rhs.value();
3464}
3465
3466template <class LHS_TYPE, class RHS_TYPE>
3467inline
3468bool bdlb::operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
3469 const RHS_TYPE& rhs)
3470{
3471 return lhs.isNull() ? true : lhs.value() < rhs;
3472}
3473
3474template <class LHS_TYPE, class RHS_TYPE>
3475inline
3476bool bdlb::operator<(const LHS_TYPE& lhs,
3477 const NullableAllocatedValue<RHS_TYPE>& rhs)
3478{
3479 return rhs.isNull() ? false : lhs < rhs.value();
3480}
3481
3482template <class LHS_TYPE, class RHS_TYPE>
3483inline
3484bool bdlb::operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3485 const NullableAllocatedValue<RHS_TYPE>& rhs)
3486{
3487 if (lhs.isNull()) {
3488 return true; // RETURN
3489 }
3490
3491 return rhs.isNull() ? false : lhs.value() <= rhs.value();
3492}
3493
3494template <class LHS_TYPE, class RHS_TYPE>
3495inline
3496bool bdlb::operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3497 const RHS_TYPE& rhs)
3498{
3499 return lhs.isNull() ? true : lhs.value() <= rhs;
3500}
3501
3502template <class LHS_TYPE, class RHS_TYPE>
3503inline
3504bool bdlb::operator<=(const LHS_TYPE& lhs,
3505 const NullableAllocatedValue<RHS_TYPE>& rhs)
3506{
3507 return rhs.isNull() ? false : lhs <= rhs.value();
3508}
3509
3510template <class LHS_TYPE, class RHS_TYPE>
3511inline
3512bool bdlb::operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
3513 const NullableAllocatedValue<RHS_TYPE>& rhs)
3514{
3515 if (lhs.isNull()) {
3516 return false; // RETURN
3517 }
3518
3519 return rhs.isNull() ? true : lhs.value() > rhs.value();
3520}
3521
3522template <class LHS_TYPE, class RHS_TYPE>
3523inline
3524bool bdlb::operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
3525 const RHS_TYPE& rhs)
3526{
3527 return lhs.isNull() ? false : lhs.value() > rhs;
3528}
3529
3530template <class LHS_TYPE, class RHS_TYPE>
3531inline
3532bool bdlb::operator>(const LHS_TYPE& lhs,
3533 const NullableAllocatedValue<RHS_TYPE>& rhs)
3534{
3535 return rhs.isNull() ? true : lhs > rhs.value();
3536}
3537
3538template <class LHS_TYPE, class RHS_TYPE>
3539inline
3540bool bdlb::operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3541 const NullableAllocatedValue<RHS_TYPE>& rhs)
3542{
3543 if (rhs.isNull()) {
3544 return true; // RETURN
3545 }
3546
3547 return lhs.isNull() ? false : lhs.value() >= rhs.value();
3548}
3549
3550template <class LHS_TYPE, class RHS_TYPE>
3551inline
3552bool bdlb::operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3553 const RHS_TYPE& rhs)
3554{
3555 return lhs.isNull() ? false : lhs.value() >= rhs;
3556}
3557
3558template <class LHS_TYPE, class RHS_TYPE>
3559inline
3560bool bdlb::operator>=(const LHS_TYPE& lhs,
3561 const NullableAllocatedValue<RHS_TYPE>& rhs)
3562{
3563 return rhs.isNull() ? true : lhs >= rhs.value();
3564}
3565
3566template <class TYPE>
3567inline
3568bsl::ostream& bdlb::operator<<(bsl::ostream& stream,
3569 const NullableAllocatedValue<TYPE>& object)
3570{
3571 return object.print(stream, 0, -1);
3572}
3573
3574 //--------------------------------
3575 // Comparisons with bsl::nullopt_t
3576 //--------------------------------
3577
3578template <class TYPE>
3579inline
3580bool bdlb::operator==(const NullableAllocatedValue<TYPE>& lhs,
3582{
3583 return !lhs.has_value();
3584}
3585
3586template <class TYPE>
3587inline
3588bool bdlb::operator==(
3589 const bsl::nullopt_t&,
3590 const NullableAllocatedValue<TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
3591{
3592 return !rhs.has_value();
3593}
3594
3595template <class TYPE>
3596inline bool bdlb::operator!=(const NullableAllocatedValue<TYPE>& lhs,
3598{
3599 return lhs.has_value();
3600}
3601
3602template <class TYPE>
3603inline
3604bool bdlb::operator!=(
3605 const bsl::nullopt_t&,
3606 const NullableAllocatedValue<TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
3607{
3608 return rhs.has_value();
3609}
3610
3611template <class TYPE>
3612inline
3613bool bdlb::operator<(const NullableAllocatedValue<TYPE>&,
3615{
3616 return false;
3617}
3618
3619template <class TYPE>
3620inline
3621bool bdlb::operator<(
3622 const bsl::nullopt_t&,
3623 const NullableAllocatedValue<TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
3624{
3625 return rhs.has_value();
3626}
3627
3628template <class TYPE>
3629inline
3630bool bdlb::operator>(const NullableAllocatedValue<TYPE>& lhs,
3632{
3633 return lhs.has_value();
3634}
3635
3636template <class TYPE>
3637inline
3639 const NullableAllocatedValue<TYPE>&) BSLS_KEYWORD_NOEXCEPT
3640{
3641 return false;
3642}
3643
3644template <class TYPE>
3645inline
3646bool bdlb::operator<=(const NullableAllocatedValue<TYPE>& lhs,
3648{
3649 return !lhs.has_value();
3650}
3651
3652template <class TYPE>
3653inline
3654bool bdlb::operator<=(
3655 const bsl::nullopt_t&,
3656 const NullableAllocatedValue<TYPE>&) BSLS_KEYWORD_NOEXCEPT
3657{
3658 return true;
3659}
3660
3661template <class TYPE>
3662inline
3663bool bdlb::operator>=(const NullableAllocatedValue<TYPE>&,
3665{
3666 return true;
3667}
3668
3669template <class TYPE>
3670inline
3671bool bdlb::operator>=(
3672 const bsl::nullopt_t&,
3673 const NullableAllocatedValue<TYPE>& rhs) BSLS_KEYWORD_NOEXCEPT
3674{
3675 return !rhs.has_value();
3676}
3677
3678 //-------------------------------
3679 // Comparisons with bsl::optional
3680 //-------------------------------
3681
3682template <class LHS_TYPE, class RHS_TYPE>
3683inline
3684bool bdlb::operator==(const NullableAllocatedValue<LHS_TYPE>& lhs,
3685 const bsl::optional<RHS_TYPE>& rhs)
3686{
3687 if (lhs.has_value() != rhs.has_value())
3688 return false; // RETURN
3689 return lhs.has_value () ? lhs.value() == rhs.value () : true;
3690}
3691
3692template <class LHS_TYPE, class RHS_TYPE>
3693inline
3695 const NullableAllocatedValue<RHS_TYPE>& rhs)
3696{
3697 if (lhs.has_value() != rhs.has_value())
3698 return false; // RETURN
3699 return lhs.has_value () ? lhs.value() == rhs.value () : true;
3700}
3701
3702template <class LHS_TYPE, class RHS_TYPE>
3703inline
3704bool bdlb::operator!=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3705 const bsl::optional<RHS_TYPE>& rhs)
3706{
3707 if (lhs.has_value() != rhs.has_value())
3708 return true; // RETURN
3709 return lhs.has_value () ? lhs.value() != rhs.value () : false;
3710}
3711
3712template <class LHS_TYPE, class RHS_TYPE>
3713inline
3715 const NullableAllocatedValue<RHS_TYPE>& rhs)
3716{
3717 if (lhs.has_value() != rhs.has_value())
3718 return true; // RETURN
3719 return lhs.has_value () ? lhs.value() != rhs.value () : false;
3720}
3721
3722template <class LHS_TYPE, class RHS_TYPE>
3723inline
3724bool bdlb::operator<(const NullableAllocatedValue<LHS_TYPE>& lhs,
3725 const bsl::optional<RHS_TYPE>& rhs)
3726{
3727 if (lhs.has_value() != rhs.has_value())
3728 return rhs.has_value(); // RETURN
3729 return lhs.has_value () ? lhs.value() < rhs.value () : false;
3730}
3731
3732template <class LHS_TYPE, class RHS_TYPE>
3733inline
3735 const NullableAllocatedValue<RHS_TYPE>& rhs)
3736{
3737 if (lhs.has_value() != rhs.has_value())
3738 return rhs.has_value(); // RETURN
3739 return lhs.has_value () ? lhs.value() < rhs.value () : false;
3740}
3741
3742
3743template <class LHS_TYPE, class RHS_TYPE>
3744inline
3745bool bdlb::operator>(const NullableAllocatedValue<LHS_TYPE>& lhs,
3746 const bsl::optional<RHS_TYPE>& rhs)
3747{
3748 if (lhs.has_value() != rhs.has_value())
3749 return lhs.has_value(); // RETURN
3750 return lhs.has_value () ? lhs.value() > rhs.value () : false;
3751}
3752
3753template <class LHS_TYPE, class RHS_TYPE>
3754inline
3756 const NullableAllocatedValue<RHS_TYPE>& rhs)
3757{
3758 if (lhs.has_value() != rhs.has_value())
3759 return lhs.has_value(); // RETURN
3760 return lhs.has_value () ? lhs.value() > rhs.value () : false;
3761}
3762
3763template <class LHS_TYPE, class RHS_TYPE>
3764inline
3765bool bdlb::operator<=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3766 const bsl::optional<RHS_TYPE>& rhs)
3767{
3768 if (lhs.has_value() != rhs.has_value())
3769 return rhs.has_value(); // RETURN
3770 return lhs.has_value () ? lhs.value() <= rhs.value () : true;
3771}
3772
3773template <class LHS_TYPE, class RHS_TYPE>
3774inline
3776 const NullableAllocatedValue<RHS_TYPE>& rhs)
3777{
3778 if (lhs.has_value() != rhs.has_value())
3779 return rhs.has_value(); // RETURN
3780 return lhs.has_value () ? lhs.value() <= rhs.value () : true;
3781}
3782
3783template <class LHS_TYPE, class RHS_TYPE>
3784inline
3785bool bdlb::operator>=(const NullableAllocatedValue<LHS_TYPE>& lhs,
3786 const bsl::optional<RHS_TYPE>& rhs)
3787{
3788 if (lhs.has_value() != rhs.has_value())
3789 return lhs.has_value(); // RETURN
3790 return lhs.has_value () ? lhs.value() >= rhs.value () : true;
3791}
3792
3793template <class LHS_TYPE, class RHS_TYPE>
3794inline
3796 const NullableAllocatedValue<RHS_TYPE>& rhs)
3797{
3798 if (lhs.has_value() != rhs.has_value())
3799 return lhs.has_value(); // RETURN
3800 return lhs.has_value () ? lhs.value() >= rhs.value () : true;
3801}
3802
3803
3804// FREE FUNCTIONS
3805template <class HASHALG, class TYPE>
3806void bdlb::hashAppend(HASHALG& hashAlg,
3807 const NullableAllocatedValue<TYPE>& input)
3808{
3809 using ::BloombergLP::bslh::hashAppend;
3810
3811 if (!input.isNull()) {
3812 hashAppend(hashAlg, true);
3813 hashAppend(hashAlg, input.value());
3814 }
3815 else {
3816 hashAppend(hashAlg, false);
3817 }
3818}
3819
3820template <class TYPE>
3821void bdlb::swap(NullableAllocatedValue<TYPE>& a,
3822 NullableAllocatedValue<TYPE>& b)
3823{
3824 if (a.allocator() == b.allocator()) {
3825 a.swap(b);
3826
3827 return; // RETURN
3828 }
3829
3830 NullableAllocatedValue<TYPE> futureA(b, a.allocator());
3831 NullableAllocatedValue<TYPE> futureB(a, b.allocator());
3832
3833 futureA.swap(a);
3834 futureB.swap(b);
3835}
3836
3837
3838
3839#else // if ! defined(DEFINED_BDLB_NULLABLEALLOCATEDVALUE_H)
3840# error Not valid except when included from bdlb_nullableallocatedvalue.h
3841#endif // ! defined(COMPILING_BDLB_NULLABLEALLOCATEDVALUE_H)
3842
3843#endif // ! defined(INCLUDED_BDLB_NULLABLEALLOCATEDVALUE_CPP03)
3844
3845// ----------------------------------------------------------------------------
3846// Copyright 2015 Bloomberg Finance L.P.
3847//
3848// Licensed under the Apache License, Version 2.0 (the "License");
3849// you may not use this file except in compliance with the License.
3850// You may obtain a copy of the License at
3851//
3852// http://www.apache.org/licenses/LICENSE-2.0
3853//
3854// Unless required by applicable law or agreed to in writing, software
3855// distributed under the License is distributed on an "AS IS" BASIS,
3856// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3857// See the License for the specific language governing permissions and
3858// limitations under the License.
3859// ----------------------------- END-OF-FILE ----------------------------------
3860
3861/** @} */
3862/** @} */
3863/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
char d_buffer[sizeof(TYPE *)]
Definition bdlb_nullableallocatedvalue.h:189
TYPE * d_pointer_p
Definition bdlb_nullableallocatedvalue.h:188
void reset()
Definition bdlb_nullableallocatedvalue.h:1148
TYPE ValueType
Definition bdlb_nullableallocatedvalue.h:258
TYPE value_or(const ANY_TYPE &default_value) const
Definition bdlb_nullableallocatedvalue.h:1440
bool has_value() const BSLS_KEYWORD_NOEXCEPT
Definition bdlb_nullableallocatedvalue.h:1393
TYPE & emplace(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...)
NullableAllocatedValue()
Definition bdlb_nullableallocatedvalue.h:928
bsl::allocator< char > get_allocator() const
Definition bdlb_nullableallocatedvalue.h:1385
TYPE & makeValue()
Definition bdlb_nullableallocatedvalue.h:1114
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlb_nullableallocatedvalue.h:1064
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlb_nullableallocatedvalue.h:1472
TYPE * operator->()
Definition bdlb_nullableallocatedvalue.h:1191
bool isNull() const BSLS_KEYWORD_NOEXCEPT
Definition bdlb_nullableallocatedvalue.h:1400
void swap(NullableAllocatedValue &other)
Definition bdlb_nullableallocatedvalue.h:1162
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlb_nullableallocatedvalue.h:1369
TYPE & value()
Definition bdlb_nullableallocatedvalue.h:1183
int maxSupportedBdexVersion() const
Definition bdlb_nullableallocatedvalue.h:1431
TYPE & operator*()
Definition bdlb_nullableallocatedvalue.h:1199
bslma::Allocator * allocator() const
Return the allocator used by this object to supply memory.
Definition bdlb_nullableallocatedvalue.h:1465
Definition bslma_bslallocator.h:588
void deallocate(TYPE *p, std::size_t n=1)
Definition bslma_bslallocator.h:1062
Definition bslstl_optional.h:2043
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:182
Definition bslma_allocator.h:545
virtual void * allocate(size_type size)=0
Definition bslma_deallocatorproctor.h:312
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_DEPRECATE_FEATURE(UOR, FEATURE, MESSAGE)
Definition bsls_deprecatefeature.h:387
#define BSLS_KEYWORD_EXPLICIT
Definition bsls_keyword.h:683
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
STREAM & bdexStreamOut(STREAM &stream, const DayCountConvention::Enum &value, int version)
int maxSupportedBdexVersion(const DayCountConvention::Enum *, int versionSelector)
STREAM & bdexStreamIn(STREAM &stream, DayCountConvention::Enum &variable, int version)
bool isNull(const TYPE &object)
void makeValue(TYPE *object)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
bsl::ostream & print(bsl::ostream &stream, const TYPE &object, int level=0, int spacesPerLevel=4)
Definition bdlb_printmethods.h:725
Definition bdlb_algorithmworkaroundutil.h:74
bool operator!=(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const BigEndianInt16 &integer)
bool operator>=(const Guid &lhs, const Guid &rhs)
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const BigEndianInt16 &object)
void swap(NullableAllocatedValue< TYPE > &a, NullableAllocatedValue< TYPE > &b)
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
bool operator<(const Guid &lhs, const Guid &rhs)
bool operator==(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
Definition bdlat_valuetypefunctions.h:939
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
STREAM & bdexStreamIn(STREAM &stream, VALUE_TYPE &variable)
Definition bslx_instreamfunctions.h:1263
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:1004
int maxSupportedBdexVersion(const TYPE *, int versionSelector)
Definition bslx_versionfunctions.h:531
Definition bslstl_optional.h:522
static void defaultConstruct(TARGET_TYPE *address, bslma::Allocator *allocator)
Definition bslalg_scalarprimitives.h:1577
static void copyConstruct(TARGET_TYPE *address, const TARGET_TYPE &original, bslma::Allocator *allocator)
Definition bslalg_scalarprimitives.h:1617
Definition bslmf_isbitwisemoveable.h:718
Definition bsls_alignmentfromtype.h:378