BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_ostringstream.h
Go to the documentation of this file.
1/// @file bslstl_ostringstream.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_ostringstream.h -*-C++-*-
8#ifndef INCLUDED_BSLSTL_OSTRINGSTREAM
9#define INCLUDED_BSLSTL_OSTRINGSTREAM
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslstl_ostringstream bslstl_ostringstream
15/// @brief Provide a C++03-compatible `ostringstream` class.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_ostringstream
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_ostringstream-purpose"> Purpose</a>
25/// * <a href="#bslstl_ostringstream-classes"> Classes </a>
26/// * <a href="#bslstl_ostringstream-description"> Description </a>
27/// * <a href="#bslstl_ostringstream-memory-allocation"> Memory Allocation </a>
28/// * <a href="#bslstl_ostringstream-bslma-style-allocators"> bslma-Style Allocators </a>
29/// * <a href="#bslstl_ostringstream-usage"> Usage </a>
30/// * <a href="#bslstl_ostringstream-example-1-basic-output-operations"> Example 1: Basic Output Operations </a>
31///
32/// # Purpose {#bslstl_ostringstream-purpose}
33/// Provide a C++03-compatible `ostringstream` class.
34///
35/// # Classes {#bslstl_ostringstream-classes}
36///
37/// - bsl::ostringstream: C++03-compatible `ostringstream` class
38///
39/// **Canonical header:** bsl_sstream.h
40///
41/// @see
42///
43/// # Description {#bslstl_ostringstream-description}
44/// This component is for internal use only. Please include
45/// `<bsl_sstream.h>` instead.
46///
47/// This component defines a class template, `bsl::basic_ostringstream`,
48/// implementing a standard output stream that provides a method for obtaining a
49/// `bsl::basic_string`, which contains the characters that have been written to
50/// the stream (see 27.8.4 [ostringstream] of the C++11 standard). This
51/// component also defines two standard aliases, `bsl::ostringstream` and
52/// `bsl::wostringstream`, that refer to specializations of the
53/// `bsl::basic_ostringstream` template for `char` and `wchar_t` types,
54/// respectively. The `bsl::basic_ostringstream` template has three parameters,
55/// `CHAR_TYPE`, `CHAR_TRAITS`, and `ALLOCATOR`. The `CHAR_TYPE` and
56/// `CHAR_TRAITS` parameters respectively define the character type for the
57/// string-stream and a type providing a set of operations the string-stream
58/// will use to manipulate characters of that type, which must meet the
59/// character traits requirements defined by the C++11 standard, 21.2
60/// [char.traits]. The `ALLOCATOR` template parameter is described in the
61/// "Memory Allocation" section below.
62///
63/// ## Memory Allocation {#bslstl_ostringstream-memory-allocation}
64///
65///
66/// The type supplied as a string-stream's `ALLOCATOR` template parameter
67/// determines how that string-stream will allocate memory. The
68/// @ref basic_ostringstream template supports allocators meeting the requirements
69/// of the C++11 standard, 17.6.3.5 [allocator.requirements]; in addition, it
70/// supports scoped-allocators derived from the `bslma::Allocator` memory
71/// allocation protocol. Clients intending to use `bslma`-style allocators
72/// should use `bsl::allocator`, which provides a C++11 standard-compatible
73/// adapter for a `bslma::Allocator` object. Note that the standard aliases
74/// `bsl::ostringstream` and `bsl::wostringstream` both use `bsl::allocator`.
75///
76/// ### bslma-Style Allocators {#bslstl_ostringstream-bslma-style-allocators}
77///
78///
79/// If the type supplied for the `ALLOCATOR` template parameter of an
80/// `ostringstream` instantiation is `bsl::allocator`, then objects of that
81/// string-stream type will conform to the standard behavior of a
82/// `bslma`-allocator-enabled type. Such a string-stream accepts an optional
83/// `bslma::Allocator` argument at construction. If the address of a
84/// `bslma::Allocator` object is explicitly supplied at construction, it will be
85/// used to supply memory for the string-stream throughout its lifetime;
86/// otherwise, the string-stream will use the default allocator installed at the
87/// time of the string-stream's construction (see @ref bslma_default ).
88///
89/// ## Usage {#bslstl_ostringstream-usage}
90///
91///
92/// This section illustrates intended use of this component.
93///
94/// ### Example 1: Basic Output Operations {#bslstl_ostringstream-example-1-basic-output-operations}
95///
96///
97/// The following example demonstrates the use of `bsl::ostringstream` to write
98/// data of various types into a `bsl::string` object.
99///
100/// Suppose we want to implement a simplified converter from a generic type,
101/// `TYPE`, to `bsl::string`. We use `bsl::ostringstream` to implement the
102/// `toString` function. We write the data into the stream with `operator<<`
103/// and then use the `str` method to retrieve the resulting string from the
104/// stream:
105/// @code
106/// template <class TYPE>
107/// bsl::string toString(const TYPE& what)
108/// {
109/// bsl::ostringstream out;
110/// out << what;
111/// return out.str();
112/// }
113/// @endcode
114/// Finally, we verify that our `toString` function works on some simple test
115/// cases:
116/// @code
117/// assert(toString(1234) == "1234");
118///
119/// assert(toString<short>(-5) == "-5");
120///
121/// assert(toString("abc") == "abc");
122/// @endcode
123/// @}
124/** @} */
125/** @} */
126
127/** @addtogroup bsl
128 * @{
129 */
130/** @addtogroup bslstl
131 * @{
132 */
133/** @addtogroup bslstl_ostringstream
134 * @{
135 */
136
137#include <bslscm_version.h>
138
139#include <bslma_isstdallocator.h>
141
142#include <bslmf_enableif.h>
143#include <bslmf_issame.h>
144#include <bslmf_movableref.h>
145
147#include <bsls_keyword.h>
148#include <bsls_libraryfeatures.h>
149#include <bsls_platform.h>
150
151#include <bslstl_string.h>
152#include <bslstl_stringview.h>
153#include <bslstl_stringbuf.h>
154
155#include <ios>
156
157#include <ostream>
158
159#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE
160# include <utility>
161#endif
162
163namespace bsl {
164
165 // =========================
166 // class basic_ostringstream
167 // =========================
168
169/// This class implements a standard output stream that provides an accessor
170/// for obtaining a `bsl::basic_string` containing the sequence of
171/// characters that have been written to the stream.
172template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
174 : private StringBufContainer<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>
175 , public std::basic_ostream<CHAR_TYPE, CHAR_TRAITS> {
176
177 private:
178 // PRIVATE TYPES
181 BaseType;
184 typedef std::basic_ostream<CHAR_TYPE, CHAR_TRAITS> BaseStream;
185 typedef std::ios_base ios_base;
186
187 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
188
189 private:
190 // NOT IMPLEMENTED
191 basic_ostringstream(const basic_ostringstream&); // = delete
192 basic_ostringstream& operator=(const basic_ostringstream&); // = delete
193
194 public:
195 // TYPES
196 typedef CHAR_TYPE char_type;
197 typedef CHAR_TRAITS traits_type;
198 typedef ALLOCATOR allocator_type;
199 typedef typename traits_type::int_type int_type;
200 typedef typename traits_type::off_type off_type;
201 typedef typename traits_type::pos_type pos_type;
202
203 // CREATORS
204
205 explicit
207 explicit
208 basic_ostringstream(ios_base::openmode modeBitMask,
210 explicit
211 basic_ostringstream(const StringType& initialString,
213 /// Create a @ref basic_ostringstream object. Optionally specify a
214 /// `modeBitMask` indicating whether the underlying stream-buffer may
215 /// also be read from (`rdbuf` is created using
216 /// `modeBitMask | ios_base::out`). If `modeBitMask` is not supplied,
217 /// `rdbuf` will be created using `ios_base::out`. Optionally specify
218 /// an `initialString` indicating the value that will be returned by a
219 /// call to `str` prior to any streaming operations performed on this
220 /// object. If `initialString` is not supplied, `str` will initially
221 /// return an empty string. Optionally specify the `allocator` used to
222 /// supply memory. If `allocator` is not supplied, a
223 /// default-constructed object of the (template parameter) `ALLOCATOR`
224 /// type is used. If the `ALLOCATOR` argument is of type
225 /// `bsl::allocator` (the default), then `allocator`, if supplied,
226 /// shall be convertible to `bslma::Allocator *`. If the `ALLOCATOR`
227 /// argument is of type `bsl::allocator` and `allocator` is not
228 /// supplied, the currently installed default allocator will be used to
229 /// supply memory.
230 basic_ostringstream(const StringType& initialString,
231 ios_base::openmode modeBitMask,
233
234 explicit
236 BloombergLP::bslmf::MovableRef<StringType> initialString);
238 BloombergLP::bslmf::MovableRef<StringType> initialString,
241 BloombergLP::bslmf::MovableRef<StringType> initialString,
242 ios_base::openmode modeBitMask);
243 /// Create a @ref basic_ostringstream object. Use the specified
244 /// `initialString` indicating the value that will be returned by a call
245 /// to `str` prior to any streaming operations performed on this object.
246 /// Optionally specify a `modeBitMask` indicating whether the underlying
247 /// stream-buffer may also be read from (`rdbuf` is created using
248 /// `modeBitMask | ios_base::out`). If `modeBitMask` is not supplied,
249 /// `rdbuf` will be created using `ios_base::out`. Optionally specify
250 /// the `allocator` used to supply memory. If `allocator` is not
251 /// supplied, the allocator in `initialString` is used. `initialString`
252 /// is left in a valid but unspecified state.
254 BloombergLP::bslmf::MovableRef<StringType> initialString,
255 ios_base::openmode modeBitMask,
257
258 /// Create a @ref basic_ostringstream object. Use the specified
259 /// `initialString` as the value that will be returned by a call to
260 /// `str` prior to any streaming operations performed on this object.
261 /// `rdbuf` is created using `ios_base::out`. Optionally specify the
262 /// `allocator` used to supply memory. If `allocator` is not supplied,
263 /// a default-constructed object of the (template parameter) `ALLOCATOR`
264 /// type is used. If the `ALLOCATOR` argument is of type
265 /// `bsl::allocator` (the default), then `allocator`, if supplied, shall
266 /// be convertible to `bslma::Allocator *`. If the `ALLOCATOR` argument
267 /// is of type `bsl::allocator` and `allocator` is not supplied, the
268 /// currently installed default allocator will be used to supply memory.
269 ///
270 /// Note: implemented inline due to Sun CC compilation error.
271 template <class SALLOC>
274 initialString,
276 typename bsl::enable_if<
277 !bsl::is_same<ALLOCATOR, SALLOC>::value, void *>::type = 0)
278 : BaseType(initialString.begin(),
279 initialString.end(),
280 ios_base::out,
281 allocator)
282 , BaseStream(BaseType::rdbuf())
283 {
284 }
285
286
287 /// Create a @ref basic_ostringstream object. Use the specified
288 /// `initialString` as the value that will be returned by a call to
289 /// `str` prior to any streaming operations performed on this object.
290 /// Use the specified `modeBitMask` to indicate whether the underlying
291 /// stream-buffer may also be read from (`rdbuf` is created using
292 /// `modeBitMask | ios_base::out`). Optionally specify the `allocator`
293 /// used to supply memory. If `allocator` is not supplied, a
294 /// default-constructed object of the (template parameter) `ALLOCATOR`
295 /// type is used. If the `ALLOCATOR` argument is of type
296 /// `bsl::allocator` (the default), then `allocator`, if supplied, shall
297 /// be convertible to `bslma::Allocator *`. If the `ALLOCATOR` argument
298 /// is of type `bsl::allocator` and `allocator` is not supplied, the
299 /// currently installed default allocator will be used to supply memory.
300 ///
301 /// Note: implemented inline due to Sun CC compilation error.
302 template <class SALLOC>
305 initialString,
306 ios_base::openmode modeBitMask,
308 typename bsl::enable_if<
309 !bsl::is_same<ALLOCATOR, SALLOC>::value, void *>::type = 0)
310 : BaseType(initialString.begin(),
311 initialString.end(),
312 modeBitMask | ios_base::out,
313 allocator)
314 , BaseStream(BaseType::rdbuf())
315 {
316 }
317
318#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE
320 /// Create a @ref basic_ostringstream object having the same value as the
321 /// specified `original` object by moving the contents of `original` to
322 /// the newly-created object. Optionally specify the `allocator` used
323 /// to supply memory. `original` is left in a valid but unspecified
324 /// state.
327#endif
328
330 // Destroy this object.
331
332 // MANIPULATORS
333#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE
334 /// Assign to this object the value of the specified `rhs`, and return a
335 /// reference providing modifiable access to this object. The contents
336 /// of `rhs` are move-assigned to this object. `rhs` is left in a valid
337 /// but unspecified state.
339#endif
340
341 /// Reset the internally buffered sequence of characters maintained by
342 /// this stream object to the specified `value`. If `value` is passed
343 /// by `MovableRef`, it is left in a valid but unspecified state.
344 ///
345 void str(const StringType& value);
346 /// Note: implemented inline due to Sun CC compilation error.
347 void str(BloombergLP::bslmf::MovableRef<StringType> value);
348 template <class SALLOC>
349 typename
352 {
353 return this->rdbuf()->str(value);
354 }
355
356#ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
357 /// Return the internally buffered sequence of characters maintained by
358 /// this stream, leaving the stream empty.
359 StringType str() &&;
360#endif
361
362#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
363 /// Efficiently exchange the value of this object with the value of the
364 /// specified `other` object. This method provides the no-throw
365 /// exception-safety guarantee if `*this` and `other` allocators compare
366 /// equal. The behavior is undefined unless either `*this` and `other`
367 /// allocators compare equal or `propagate_on_container_swap` is `true`.
368 /// Note that this function is only available for C++11 (and later)
369 /// language standards because it requires that `swap` be provided on
370 /// the (platform supplied) base class for this type.
371 void swap(basic_ostringstream& other);
372#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
373
374 // ACCESSORS
375
376 /// Return the allocator used by the underlying buffer to supply memory.
378
379 /// Return an address providing modifiable access to the
380 /// @ref basic_stringbuf object that is internally used by this string
381 /// stream to buffer unformatted characters.
382 StreamBufType *rdbuf() const;
383
384#ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
385 StringType str() const &;
386#else
387 StringType str() const;
388#endif
389 // Return the internally buffered sequence of characters maintained by
390 // this stream object.
391
392#ifndef BSLS_PLATFORM_CMP_SUN
393 // To be enabled once DRQS 168075157 is resolved
394
395 /// Return a copy of the internally buffered sequence of characters
396 /// maintained by this stream object in a @ref basic_string that uses the
397 /// specified `allocator`.
398 ///
399 /// Note: implemented inline due to Sun CC compilation error.
400 template <class SALLOC>
401 typename bsl::enable_if<
402 bsl::IsStdAllocator<SALLOC>::value,
404 str(const SALLOC& allocator) const
405 {
406 return this->rdbuf()->str(allocator);
407 }
408#endif
409
410 /// Return a view of the internally buffered sequence of characters
411 /// maintained by this stream object.
412 ViewType view() const BSLS_KEYWORD_NOEXCEPT;
413};
414
415// FREE FUNCTIONS
416#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY) \
417 && defined(BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE)
418/// Efficiently exchange the values of the specified `a` and `b` objects.
419/// This method provides the no-throw exception-safety guarantee if `a` and
420/// `b` allocators compare equal. Note that this function is only available
421/// for C++11 (and later) language standards.
422template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
425#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
426
427// STANDARD TYPEDEFS
432
433} // close namespace bsl
434
435// TYPE TRAITS
436
437namespace bslma {
438
439template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
441 bsl::basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> >
443{};
444
445} // close namespace bslma
446
447
448namespace bsl {
449
450// ============================================================================
451// TEMPLATE FUNCTION DEFINITIONS
452// ============================================================================
453
454 // -------------------------
455 // class basic_ostringstream
456 // -------------------------
457
458// CREATORS
459template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
460inline
467
468template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
469inline
471basic_ostringstream(ios_base::openmode modeBitMask,
473: BaseType(modeBitMask | ios_base::out, allocator)
474, BaseStream(BaseType::rdbuf())
475{
476}
477
478template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
479inline
481basic_ostringstream(const StringType& initialString,
483: BaseType(initialString, ios_base::out, allocator)
484, BaseStream(BaseType::rdbuf())
485{
486}
487
488template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
489inline
491basic_ostringstream(const StringType& initialString,
492 ios_base::openmode modeBitMask,
494: BaseType(initialString, modeBitMask | ios_base::out, allocator)
495, BaseStream(BaseType::rdbuf())
496{
497}
498
499template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
500inline
502basic_ostringstream(BloombergLP::bslmf::MovableRef<StringType> initialString)
503: BaseType(MoveUtil::move(initialString), ios_base::out)
504, BaseStream(BaseType::rdbuf())
505{
506}
507
508template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
509inline
511basic_ostringstream(BloombergLP::bslmf::MovableRef<StringType> initialString,
513: BaseType(MoveUtil::move(initialString), ios_base::out, allocator)
514, BaseStream(BaseType::rdbuf())
515{
516}
517
518template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
519inline
521basic_ostringstream(BloombergLP::bslmf::MovableRef<StringType> initialString,
522 ios_base::openmode modeBitMask)
523: BaseType(MoveUtil::move(initialString), modeBitMask | ios_base::out)
524, BaseStream(BaseType::rdbuf())
525{
526}
527
528template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
529inline
531basic_ostringstream(BloombergLP::bslmf::MovableRef<StringType> initialString,
532 ios_base::openmode modeBitMask,
534: BaseType(MoveUtil::move(initialString),
535 modeBitMask | ios_base::out,
536 allocator)
537, BaseStream(BaseType::rdbuf())
538{
539}
540
541#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE
542template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
543inline
546: BaseType(std::move(original))
547, BaseStream(std::move(original))
548{
549 BaseStream::set_rdbuf(BaseType::rdbuf());
550}
551
552template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
553inline
554basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::
555basic_ostringstream(basic_ostringstream&& original,
556 const allocator_type& allocator)
557: BaseType(std::move(original), allocator)
558, BaseStream(std::move(original))
559{
560 BaseStream::set_rdbuf(BaseType::rdbuf());
561}
562#endif
563
564// MANIPULATORS
565#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE
566template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
567inline
568basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>&
569basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::
570operator=(basic_ostringstream&& rhs)
571{
572 this->BaseType::operator=(std::move(rhs));
573 this->BaseStream::operator=(std::move(rhs));
574
575 return *this;
576}
577#endif
578
579template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
580inline
582 const StringType& value)
583{
584 this->rdbuf()->str(value);
585}
586
587template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
588inline
590 BloombergLP::bslmf::MovableRef<StringType> value)
591{
592 this->rdbuf()->str(MoveUtil::move(value));
593}
594
595#ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
596template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
597inline
600{
601 return std::move(*this->rdbuf()).str();
602}
603#endif
604
605#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
606template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
607inline
609 basic_ostringstream& other)
610{
613 || get_allocator() == other.get_allocator());
614 this->BaseType::swap(other);
615 this->BaseStream::swap(other);
616}
617#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
618
619// ACCESSORS
620template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
621inline
628
629template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
630inline
631typename
634{
635 return this->BaseType::rdbuf();
636}
637
638#ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
639template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
640inline
643{
644 return this->rdbuf()->str();
645}
646#else
647template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
648inline
649typename basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::StringType
651{
652 return this->rdbuf()->str();
653}
654#endif
655
656template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
657inline
661{
662 return this->rdbuf()->view();
663}
664
665} // close namespace bsl
666
667// FREE FUNCTIONS
668#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY) \
669 && defined(BSLS_LIBRARYFEATURES_HAS_CPP11_STREAM_MOVE)
670template <class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
671void bsl::swap(basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& a,
672 basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& b)
673{
674 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
675
676 if (a.get_allocator() == b.get_allocator()
678 a.swap(b);
679 }
680 else {
681 basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> aCopy(
682 MoveUtil::move(a),
683 b.get_allocator());
684 basic_ostringstream<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> bCopy(
685 MoveUtil::move(b),
686 a.get_allocator());
687 swap(a, bCopy);
688 swap(b, aCopy);
689 }
690}
691#endif
692
693#endif
694
695// ----------------------------------------------------------------------------
696// Copyright 2013 Bloomberg Finance L.P.
697//
698// Licensed under the Apache License, Version 2.0 (the "License");
699// you may not use this file except in compliance with the License.
700// You may obtain a copy of the License at
701//
702// http://www.apache.org/licenses/LICENSE-2.0
703//
704// Unless required by applicable law or agreed to in writing, software
705// distributed under the License is distributed on an "AS IS" BASIS,
706// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
707// See the License for the specific language governing permissions and
708// limitations under the License.
709// ----------------------------- END-OF-FILE ----------------------------------
710
711/** @} */
712/** @} */
713/** @} */
Definition bslstl_stringbuf.h:746
StreamBufType * rdbuf() const
Definition bslstl_stringbuf.h:864
Definition bslma_bslallocator.h:580
Definition bslstl_ostringstream.h:175
ALLOCATOR allocator_type
Definition bslstl_ostringstream.h:198
traits_type::pos_type pos_type
Definition bslstl_ostringstream.h:201
CHAR_TYPE char_type
Definition bslstl_ostringstream.h:196
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return the allocator used by the underlying buffer to supply memory.
Definition bslstl_ostringstream.h:623
StringType str() const
Definition bslstl_ostringstream.h:650
bsl::enable_if< bsl::IsStdAllocator< SALLOC >::value, basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > >::type str(const SALLOC &allocator) const
Definition bslstl_ostringstream.h:404
ViewType view() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_ostringstream.h:659
basic_ostringstream(const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &initialString, const allocator_type &allocator=allocator_type(), typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type=0)
Definition bslstl_ostringstream.h:272
traits_type::off_type off_type
Definition bslstl_ostringstream.h:200
void swap(basic_ostringstream &other)
Definition bslstl_ostringstream.h:608
bsl::enable_if<!bsl::is_same< ALLOCATOR, SALLOC >::value, void >::type str(const basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &value)
Definition bslstl_ostringstream.h:351
StreamBufType * rdbuf() const
Definition bslstl_ostringstream.h:633
traits_type::int_type int_type
Definition bslstl_ostringstream.h:199
basic_ostringstream(const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &initialString, ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type(), typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type=0)
Definition bslstl_ostringstream.h:303
CHAR_TRAITS traits_type
Definition bslstl_ostringstream.h:197
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
Definition bslstl_stringbuf.h:245
void str(const StringType &value)
Definition bslstl_stringbuf.h:1538
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
void swap(OptionValue &a, OptionValue &b)
Definition bdlb_printmethods.h:283
basic_ostringstream< wchar_t, char_traits< wchar_t >, allocator< wchar_t > > wostringstream
Definition bslstl_iosfwd.h:104
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
basic_ostringstream< char, char_traits< char >, allocator< char > > ostringstream
Definition bslstl_iosfwd.h:95
Definition balxml_encoderoptions.h:68
Definition bdldfp_decimal.h:5188
Definition bslma_allocatortraits.h:1061
Definition bslmf_enableif.h:525
Definition bslmf_issame.h:146
Definition bslma_usesbslmaallocator.h:343