2 //===--------------------------- sstream ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_SSTREAM
12 #define _LIBCPP_SSTREAM
17 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
19 : public basic_streambuf<charT, traits>
22 typedef charT char_type;
23 typedef traits traits_type;
24 typedef typename traits_type::int_type int_type;
25 typedef typename traits_type::pos_type pos_type;
26 typedef typename traits_type::off_type off_type;
27 typedef Allocator allocator_type;
29 // 27.8.1.1 Constructors:
30 explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
31 explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
32 ios_base::openmode which = ios_base::in | ios_base::out);
33 basic_stringbuf(basic_stringbuf&& rhs);
35 // 27.8.1.2 Assign and swap:
36 basic_stringbuf& operator=(basic_stringbuf&& rhs);
37 void swap(basic_stringbuf& rhs);
39 // 27.8.1.3 Get and set:
40 basic_string<char_type, traits_type, allocator_type> str() const;
41 void str(const basic_string<char_type, traits_type, allocator_type>& s);
44 // 27.8.1.4 Overridden virtual functions:
45 virtual int_type underflow();
46 virtual int_type pbackfail(int_type c = traits_type::eof());
47 virtual int_type overflow (int_type c = traits_type::eof());
48 virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
49 virtual pos_type seekoff(off_type off, ios_base::seekdir way,
50 ios_base::openmode which = ios_base::in | ios_base::out);
51 virtual pos_type seekpos(pos_type sp,
52 ios_base::openmode which = ios_base::in | ios_base::out);
55 template <class charT, class traits, class Allocator>
56 void swap(basic_stringbuf<charT, traits, Allocator>& x,
57 basic_stringbuf<charT, traits, Allocator>& y);
59 typedef basic_stringbuf<char> stringbuf;
60 typedef basic_stringbuf<wchar_t> wstringbuf;
62 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
63 class basic_istringstream
64 : public basic_istream<charT, traits>
67 typedef charT char_type;
68 typedef traits traits_type;
69 typedef typename traits_type::int_type int_type;
70 typedef typename traits_type::pos_type pos_type;
71 typedef typename traits_type::off_type off_type;
72 typedef Allocator allocator_type;
74 // 27.8.2.1 Constructors:
75 explicit basic_istringstream(ios_base::openmode which = ios_base::in);
76 explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
77 ios_base::openmode which = ios_base::in);
78 basic_istringstream(basic_istringstream&& rhs);
80 // 27.8.2.2 Assign and swap:
81 basic_istringstream& operator=(basic_istringstream&& rhs);
82 void swap(basic_istringstream& rhs);
85 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
86 basic_string<char_type, traits_type, allocator_type> str() const;
87 void str(const basic_string<char_type, traits_type, allocator_type>& s);
90 template <class charT, class traits, class Allocator>
91 void swap(basic_istringstream<charT, traits, Allocator>& x,
92 basic_istringstream<charT, traits, Allocator>& y);
94 typedef basic_istringstream<char> istringstream;
95 typedef basic_istringstream<wchar_t> wistringstream;
97 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
98 class basic_ostringstream
99 : public basic_ostream<charT, traits>
103 typedef charT char_type;
104 typedef traits traits_type;
105 typedef typename traits_type::int_type int_type;
106 typedef typename traits_type::pos_type pos_type;
107 typedef typename traits_type::off_type off_type;
108 typedef Allocator allocator_type;
110 // 27.8.3.1 Constructors/destructor:
111 explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
112 explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
113 ios_base::openmode which = ios_base::out);
114 basic_ostringstream(basic_ostringstream&& rhs);
116 // 27.8.3.2 Assign/swap:
117 basic_ostringstream& operator=(basic_ostringstream&& rhs);
118 void swap(basic_ostringstream& rhs);
121 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
122 basic_string<char_type, traits_type, allocator_type> str() const;
123 void str(const basic_string<char_type, traits_type, allocator_type>& s);
126 template <class charT, class traits, class Allocator>
127 void swap(basic_ostringstream<charT, traits, Allocator>& x,
128 basic_ostringstream<charT, traits, Allocator>& y);
130 typedef basic_ostringstream<char> ostringstream;
131 typedef basic_ostringstream<wchar_t> wostringstream;
133 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
134 class basic_stringstream
135 : public basic_iostream<charT, traits>
139 typedef charT char_type;
140 typedef traits traits_type;
141 typedef typename traits_type::int_type int_type;
142 typedef typename traits_type::pos_type pos_type;
143 typedef typename traits_type::off_type off_type;
144 typedef Allocator allocator_type;
146 // constructors/destructor
147 explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
148 explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
149 ios_base::openmode which = ios_base::out|ios_base::in);
150 basic_stringstream(basic_stringstream&& rhs);
152 // 27.8.5.1 Assign/swap:
153 basic_stringstream& operator=(basic_stringstream&& rhs);
154 void swap(basic_stringstream& rhs);
157 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
158 basic_string<char_type, traits_type, allocator_type> str() const;
159 void str(const basic_string<char_type, traits_type, allocator_type>& str);
162 template <class charT, class traits, class Allocator>
163 void swap(basic_stringstream<charT, traits, Allocator>& x,
164 basic_stringstream<charT, traits, Allocator>& y);
166 typedef basic_stringstream<char> stringstream;
167 typedef basic_stringstream<wchar_t> wstringstream;
178 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
179 #pragma GCC system_header
183 #include <__undef_macros>
186 _LIBCPP_BEGIN_NAMESPACE_STD
190 template <class _CharT, class _Traits, class _Allocator>
191 class _LIBCPP_TEMPLATE_VIS basic_stringbuf
192 : public basic_streambuf<_CharT, _Traits>
195 typedef _CharT char_type;
196 typedef _Traits traits_type;
197 typedef typename traits_type::int_type int_type;
198 typedef typename traits_type::pos_type pos_type;
199 typedef typename traits_type::off_type off_type;
200 typedef _Allocator allocator_type;
202 typedef basic_string<char_type, traits_type, allocator_type> string_type;
207 mutable char_type* __hm_;
208 ios_base::openmode __mode_;
211 // 27.8.1.1 Constructors:
212 inline _LIBCPP_INLINE_VISIBILITY
213 explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
214 inline _LIBCPP_INLINE_VISIBILITY
215 explicit basic_stringbuf(const string_type& __s,
216 ios_base::openmode __wch = ios_base::in | ios_base::out);
217 #ifndef _LIBCPP_CXX03_LANG
218 basic_stringbuf(basic_stringbuf&& __rhs);
220 // 27.8.1.2 Assign and swap:
221 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
223 void swap(basic_stringbuf& __rhs);
225 // 27.8.1.3 Get and set:
226 string_type str() const;
227 void str(const string_type& __s);
230 // 27.8.1.4 Overridden virtual functions:
231 virtual int_type underflow();
232 virtual int_type pbackfail(int_type __c = traits_type::eof());
233 virtual int_type overflow (int_type __c = traits_type::eof());
234 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
235 ios_base::openmode __wch = ios_base::in | ios_base::out);
236 inline _LIBCPP_INLINE_VISIBILITY
237 virtual pos_type seekpos(pos_type __sp,
238 ios_base::openmode __wch = ios_base::in | ios_base::out);
241 template <class _CharT, class _Traits, class _Allocator>
242 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
249 template <class _CharT, class _Traits, class _Allocator>
250 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
251 ios_base::openmode __wch)
252 : __str_(__s.get_allocator()),
259 #ifndef _LIBCPP_CXX03_LANG
261 template <class _CharT, class _Traits, class _Allocator>
262 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
263 : __mode_(__rhs.__mode_)
265 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
266 ptrdiff_t __binp = -1;
267 ptrdiff_t __ninp = -1;
268 ptrdiff_t __einp = -1;
269 if (__rhs.eback() != nullptr)
271 __binp = __rhs.eback() - __p;
272 __ninp = __rhs.gptr() - __p;
273 __einp = __rhs.egptr() - __p;
275 ptrdiff_t __bout = -1;
276 ptrdiff_t __nout = -1;
277 ptrdiff_t __eout = -1;
278 if (__rhs.pbase() != nullptr)
280 __bout = __rhs.pbase() - __p;
281 __nout = __rhs.pptr() - __p;
282 __eout = __rhs.epptr() - __p;
284 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
285 __str_ = _VSTD::move(__rhs.__str_);
286 __p = const_cast<char_type*>(__str_.data());
288 this->setg(__p + __binp, __p + __ninp, __p + __einp);
291 this->setp(__p + __bout, __p + __eout);
294 __hm_ = __hm == -1 ? nullptr : __p + __hm;
295 __p = const_cast<char_type*>(__rhs.__str_.data());
296 __rhs.setg(__p, __p, __p);
297 __rhs.setp(__p, __p);
299 this->pubimbue(__rhs.getloc());
302 template <class _CharT, class _Traits, class _Allocator>
303 basic_stringbuf<_CharT, _Traits, _Allocator>&
304 basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
306 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
307 ptrdiff_t __binp = -1;
308 ptrdiff_t __ninp = -1;
309 ptrdiff_t __einp = -1;
310 if (__rhs.eback() != nullptr)
312 __binp = __rhs.eback() - __p;
313 __ninp = __rhs.gptr() - __p;
314 __einp = __rhs.egptr() - __p;
316 ptrdiff_t __bout = -1;
317 ptrdiff_t __nout = -1;
318 ptrdiff_t __eout = -1;
319 if (__rhs.pbase() != nullptr)
321 __bout = __rhs.pbase() - __p;
322 __nout = __rhs.pptr() - __p;
323 __eout = __rhs.epptr() - __p;
325 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
326 __str_ = _VSTD::move(__rhs.__str_);
327 __p = const_cast<char_type*>(__str_.data());
329 this->setg(__p + __binp, __p + __ninp, __p + __einp);
331 this->setg(nullptr, nullptr, nullptr);
334 this->setp(__p + __bout, __p + __eout);
338 this->setp(nullptr, nullptr);
340 __hm_ = __hm == -1 ? nullptr : __p + __hm;
341 __mode_ = __rhs.__mode_;
342 __p = const_cast<char_type*>(__rhs.__str_.data());
343 __rhs.setg(__p, __p, __p);
344 __rhs.setp(__p, __p);
346 this->pubimbue(__rhs.getloc());
350 #endif // _LIBCPP_CXX03_LANG
352 template <class _CharT, class _Traits, class _Allocator>
354 basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
356 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
357 ptrdiff_t __rbinp = -1;
358 ptrdiff_t __rninp = -1;
359 ptrdiff_t __reinp = -1;
360 if (__rhs.eback() != nullptr)
362 __rbinp = __rhs.eback() - __p;
363 __rninp = __rhs.gptr() - __p;
364 __reinp = __rhs.egptr() - __p;
366 ptrdiff_t __rbout = -1;
367 ptrdiff_t __rnout = -1;
368 ptrdiff_t __reout = -1;
369 if (__rhs.pbase() != nullptr)
371 __rbout = __rhs.pbase() - __p;
372 __rnout = __rhs.pptr() - __p;
373 __reout = __rhs.epptr() - __p;
375 ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
376 __p = const_cast<char_type*>(__str_.data());
377 ptrdiff_t __lbinp = -1;
378 ptrdiff_t __lninp = -1;
379 ptrdiff_t __leinp = -1;
380 if (this->eback() != nullptr)
382 __lbinp = this->eback() - __p;
383 __lninp = this->gptr() - __p;
384 __leinp = this->egptr() - __p;
386 ptrdiff_t __lbout = -1;
387 ptrdiff_t __lnout = -1;
388 ptrdiff_t __leout = -1;
389 if (this->pbase() != nullptr)
391 __lbout = this->pbase() - __p;
392 __lnout = this->pptr() - __p;
393 __leout = this->epptr() - __p;
395 ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
396 _VSTD::swap(__mode_, __rhs.__mode_);
397 __str_.swap(__rhs.__str_);
398 __p = const_cast<char_type*>(__str_.data());
400 this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
402 this->setg(nullptr, nullptr, nullptr);
405 this->setp(__p + __rbout, __p + __reout);
406 this->pbump(__rnout);
409 this->setp(nullptr, nullptr);
410 __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
411 __p = const_cast<char_type*>(__rhs.__str_.data());
413 __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
415 __rhs.setg(nullptr, nullptr, nullptr);
418 __rhs.setp(__p + __lbout, __p + __leout);
419 __rhs.pbump(__lnout);
422 __rhs.setp(nullptr, nullptr);
423 __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
424 locale __tl = __rhs.getloc();
425 __rhs.pubimbue(this->getloc());
426 this->pubimbue(__tl);
429 template <class _CharT, class _Traits, class _Allocator>
430 inline _LIBCPP_INLINE_VISIBILITY
432 swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
433 basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
438 template <class _CharT, class _Traits, class _Allocator>
439 basic_string<_CharT, _Traits, _Allocator>
440 basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
442 if (__mode_ & ios_base::out)
444 if (__hm_ < this->pptr())
445 __hm_ = this->pptr();
446 return string_type(this->pbase(), __hm_, __str_.get_allocator());
448 else if (__mode_ & ios_base::in)
449 return string_type(this->eback(), this->egptr(), __str_.get_allocator());
450 return string_type(__str_.get_allocator());
453 template <class _CharT, class _Traits, class _Allocator>
455 basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
459 if (__mode_ & ios_base::in)
461 __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
462 this->setg(const_cast<char_type*>(__str_.data()),
463 const_cast<char_type*>(__str_.data()),
466 if (__mode_ & ios_base::out)
468 typename string_type::size_type __sz = __str_.size();
469 __hm_ = const_cast<char_type*>(__str_.data()) + __sz;
470 __str_.resize(__str_.capacity());
471 this->setp(const_cast<char_type*>(__str_.data()),
472 const_cast<char_type*>(__str_.data()) + __str_.size());
473 if (__mode_ & (ios_base::app | ios_base::ate))
478 template <class _CharT, class _Traits, class _Allocator>
479 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
480 basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
482 if (__hm_ < this->pptr())
483 __hm_ = this->pptr();
484 if (__mode_ & ios_base::in)
486 if (this->egptr() < __hm_)
487 this->setg(this->eback(), this->gptr(), __hm_);
488 if (this->gptr() < this->egptr())
489 return traits_type::to_int_type(*this->gptr());
491 return traits_type::eof();
494 template <class _CharT, class _Traits, class _Allocator>
495 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
496 basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
498 if (__hm_ < this->pptr())
499 __hm_ = this->pptr();
500 if (this->eback() < this->gptr())
502 if (traits_type::eq_int_type(__c, traits_type::eof()))
504 this->setg(this->eback(), this->gptr()-1, __hm_);
505 return traits_type::not_eof(__c);
507 if ((__mode_ & ios_base::out) ||
508 traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
510 this->setg(this->eback(), this->gptr()-1, __hm_);
511 *this->gptr() = traits_type::to_char_type(__c);
515 return traits_type::eof();
518 template <class _CharT, class _Traits, class _Allocator>
519 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
520 basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
522 if (!traits_type::eq_int_type(__c, traits_type::eof()))
524 ptrdiff_t __ninp = this->gptr() - this->eback();
525 if (this->pptr() == this->epptr())
527 if (!(__mode_ & ios_base::out))
528 return traits_type::eof();
529 #ifndef _LIBCPP_NO_EXCEPTIONS
532 #endif // _LIBCPP_NO_EXCEPTIONS
533 ptrdiff_t __nout = this->pptr() - this->pbase();
534 ptrdiff_t __hm = __hm_ - this->pbase();
535 __str_.push_back(char_type());
536 __str_.resize(__str_.capacity());
537 char_type* __p = const_cast<char_type*>(__str_.data());
538 this->setp(__p, __p + __str_.size());
540 __hm_ = this->pbase() + __hm;
541 #ifndef _LIBCPP_NO_EXCEPTIONS
545 return traits_type::eof();
547 #endif // _LIBCPP_NO_EXCEPTIONS
549 __hm_ = _VSTD::max(this->pptr() + 1, __hm_);
550 if (__mode_ & ios_base::in)
552 char_type* __p = const_cast<char_type*>(__str_.data());
553 this->setg(__p, __p + __ninp, __hm_);
555 return this->sputc(__c);
557 return traits_type::not_eof(__c);
560 template <class _CharT, class _Traits, class _Allocator>
561 typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
562 basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
563 ios_base::seekdir __way,
564 ios_base::openmode __wch)
566 if (__hm_ < this->pptr())
567 __hm_ = this->pptr();
568 if ((__wch & (ios_base::in | ios_base::out)) == 0)
570 if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
571 && __way == ios_base::cur)
580 if (__wch & ios_base::in)
581 __noff = this->gptr() - this->eback();
583 __noff = this->pptr() - this->pbase();
586 __noff = __hm_ - __str_.data();
592 if (__noff < 0 || __hm_ - __str_.data() < __noff)
596 if ((__wch & ios_base::in) && this->gptr() == 0)
598 if ((__wch & ios_base::out) && this->pptr() == 0)
601 if (__wch & ios_base::in)
602 this->setg(this->eback(), this->eback() + __noff, __hm_);
603 if (__wch & ios_base::out)
605 this->setp(this->pbase(), this->epptr());
608 return pos_type(__noff);
611 template <class _CharT, class _Traits, class _Allocator>
612 typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
613 basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
614 ios_base::openmode __wch)
616 return seekoff(__sp, ios_base::beg, __wch);
619 // basic_istringstream
621 template <class _CharT, class _Traits, class _Allocator>
622 class _LIBCPP_TEMPLATE_VIS basic_istringstream
623 : public basic_istream<_CharT, _Traits>
626 typedef _CharT char_type;
627 typedef _Traits traits_type;
628 typedef typename traits_type::int_type int_type;
629 typedef typename traits_type::pos_type pos_type;
630 typedef typename traits_type::off_type off_type;
631 typedef _Allocator allocator_type;
633 typedef basic_string<char_type, traits_type, allocator_type> string_type;
636 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
639 // 27.8.2.1 Constructors:
640 inline _LIBCPP_INLINE_VISIBILITY
641 explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
642 inline _LIBCPP_INLINE_VISIBILITY
643 explicit basic_istringstream(const string_type& __s,
644 ios_base::openmode __wch = ios_base::in);
645 #ifndef _LIBCPP_CXX03_LANG
646 inline _LIBCPP_INLINE_VISIBILITY
647 basic_istringstream(basic_istringstream&& __rhs);
649 // 27.8.2.2 Assign and swap:
650 basic_istringstream& operator=(basic_istringstream&& __rhs);
651 #endif // _LIBCPP_CXX03_LANG
652 inline _LIBCPP_INLINE_VISIBILITY
653 void swap(basic_istringstream& __rhs);
656 inline _LIBCPP_INLINE_VISIBILITY
657 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
658 inline _LIBCPP_INLINE_VISIBILITY
659 string_type str() const;
660 inline _LIBCPP_INLINE_VISIBILITY
661 void str(const string_type& __s);
664 template <class _CharT, class _Traits, class _Allocator>
665 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
666 : basic_istream<_CharT, _Traits>(&__sb_),
667 __sb_(__wch | ios_base::in)
671 template <class _CharT, class _Traits, class _Allocator>
672 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
673 ios_base::openmode __wch)
674 : basic_istream<_CharT, _Traits>(&__sb_),
675 __sb_(__s, __wch | ios_base::in)
679 #ifndef _LIBCPP_CXX03_LANG
681 template <class _CharT, class _Traits, class _Allocator>
682 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
683 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
684 __sb_(_VSTD::move(__rhs.__sb_))
686 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
689 template <class _CharT, class _Traits, class _Allocator>
690 basic_istringstream<_CharT, _Traits, _Allocator>&
691 basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
693 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
694 __sb_ = _VSTD::move(__rhs.__sb_);
698 #endif // _LIBCPP_CXX03_LANG
700 template <class _CharT, class _Traits, class _Allocator>
701 void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
703 basic_istream<char_type, traits_type>::swap(__rhs);
704 __sb_.swap(__rhs.__sb_);
707 template <class _CharT, class _Traits, class _Allocator>
708 inline _LIBCPP_INLINE_VISIBILITY
710 swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
711 basic_istringstream<_CharT, _Traits, _Allocator>& __y)
716 template <class _CharT, class _Traits, class _Allocator>
717 basic_stringbuf<_CharT, _Traits, _Allocator>*
718 basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
720 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
723 template <class _CharT, class _Traits, class _Allocator>
724 basic_string<_CharT, _Traits, _Allocator>
725 basic_istringstream<_CharT, _Traits, _Allocator>::str() const
730 template <class _CharT, class _Traits, class _Allocator>
731 void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
736 // basic_ostringstream
738 template <class _CharT, class _Traits, class _Allocator>
739 class _LIBCPP_TEMPLATE_VIS basic_ostringstream
740 : public basic_ostream<_CharT, _Traits>
743 typedef _CharT char_type;
744 typedef _Traits traits_type;
745 typedef typename traits_type::int_type int_type;
746 typedef typename traits_type::pos_type pos_type;
747 typedef typename traits_type::off_type off_type;
748 typedef _Allocator allocator_type;
750 typedef basic_string<char_type, traits_type, allocator_type> string_type;
753 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
756 // 27.8.2.1 Constructors:
757 inline _LIBCPP_INLINE_VISIBILITY
758 explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
759 inline _LIBCPP_INLINE_VISIBILITY
760 explicit basic_ostringstream(const string_type& __s,
761 ios_base::openmode __wch = ios_base::out);
762 #ifndef _LIBCPP_CXX03_LANG
763 inline _LIBCPP_INLINE_VISIBILITY
764 basic_ostringstream(basic_ostringstream&& __rhs);
766 // 27.8.2.2 Assign and swap:
767 basic_ostringstream& operator=(basic_ostringstream&& __rhs);
768 #endif // _LIBCPP_CXX03_LANG
769 inline _LIBCPP_INLINE_VISIBILITY
770 void swap(basic_ostringstream& __rhs);
773 inline _LIBCPP_INLINE_VISIBILITY
774 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
775 inline _LIBCPP_INLINE_VISIBILITY
776 string_type str() const;
777 inline _LIBCPP_INLINE_VISIBILITY
778 void str(const string_type& __s);
781 template <class _CharT, class _Traits, class _Allocator>
782 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
783 : basic_ostream<_CharT, _Traits>(&__sb_),
784 __sb_(__wch | ios_base::out)
788 template <class _CharT, class _Traits, class _Allocator>
789 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
790 ios_base::openmode __wch)
791 : basic_ostream<_CharT, _Traits>(&__sb_),
792 __sb_(__s, __wch | ios_base::out)
796 #ifndef _LIBCPP_CXX03_LANG
798 template <class _CharT, class _Traits, class _Allocator>
799 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
800 : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
801 __sb_(_VSTD::move(__rhs.__sb_))
803 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
806 template <class _CharT, class _Traits, class _Allocator>
807 basic_ostringstream<_CharT, _Traits, _Allocator>&
808 basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
810 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
811 __sb_ = _VSTD::move(__rhs.__sb_);
815 #endif // _LIBCPP_CXX03_LANG
817 template <class _CharT, class _Traits, class _Allocator>
819 basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
821 basic_ostream<char_type, traits_type>::swap(__rhs);
822 __sb_.swap(__rhs.__sb_);
825 template <class _CharT, class _Traits, class _Allocator>
826 inline _LIBCPP_INLINE_VISIBILITY
828 swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
829 basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
834 template <class _CharT, class _Traits, class _Allocator>
835 basic_stringbuf<_CharT, _Traits, _Allocator>*
836 basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
838 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
841 template <class _CharT, class _Traits, class _Allocator>
842 basic_string<_CharT, _Traits, _Allocator>
843 basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
848 template <class _CharT, class _Traits, class _Allocator>
850 basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
855 // basic_stringstream
857 template <class _CharT, class _Traits, class _Allocator>
858 class _LIBCPP_TEMPLATE_VIS basic_stringstream
859 : public basic_iostream<_CharT, _Traits>
862 typedef _CharT char_type;
863 typedef _Traits traits_type;
864 typedef typename traits_type::int_type int_type;
865 typedef typename traits_type::pos_type pos_type;
866 typedef typename traits_type::off_type off_type;
867 typedef _Allocator allocator_type;
869 typedef basic_string<char_type, traits_type, allocator_type> string_type;
872 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
875 // 27.8.2.1 Constructors:
876 inline _LIBCPP_INLINE_VISIBILITY
877 explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
878 inline _LIBCPP_INLINE_VISIBILITY
879 explicit basic_stringstream(const string_type& __s,
880 ios_base::openmode __wch = ios_base::in | ios_base::out);
881 #ifndef _LIBCPP_CXX03_LANG
882 inline _LIBCPP_INLINE_VISIBILITY
883 basic_stringstream(basic_stringstream&& __rhs);
885 // 27.8.2.2 Assign and swap:
886 basic_stringstream& operator=(basic_stringstream&& __rhs);
887 #endif // _LIBCPP_CXX03_LANG
888 inline _LIBCPP_INLINE_VISIBILITY
889 void swap(basic_stringstream& __rhs);
892 inline _LIBCPP_INLINE_VISIBILITY
893 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
894 inline _LIBCPP_INLINE_VISIBILITY
895 string_type str() const;
896 inline _LIBCPP_INLINE_VISIBILITY
897 void str(const string_type& __s);
900 template <class _CharT, class _Traits, class _Allocator>
901 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
902 : basic_iostream<_CharT, _Traits>(&__sb_),
907 template <class _CharT, class _Traits, class _Allocator>
908 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
909 ios_base::openmode __wch)
910 : basic_iostream<_CharT, _Traits>(&__sb_),
915 #ifndef _LIBCPP_CXX03_LANG
917 template <class _CharT, class _Traits, class _Allocator>
918 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
919 : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
920 __sb_(_VSTD::move(__rhs.__sb_))
922 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
925 template <class _CharT, class _Traits, class _Allocator>
926 basic_stringstream<_CharT, _Traits, _Allocator>&
927 basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
929 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
930 __sb_ = _VSTD::move(__rhs.__sb_);
934 #endif // _LIBCPP_CXX03_LANG
936 template <class _CharT, class _Traits, class _Allocator>
938 basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
940 basic_iostream<char_type, traits_type>::swap(__rhs);
941 __sb_.swap(__rhs.__sb_);
944 template <class _CharT, class _Traits, class _Allocator>
945 inline _LIBCPP_INLINE_VISIBILITY
947 swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
948 basic_stringstream<_CharT, _Traits, _Allocator>& __y)
953 template <class _CharT, class _Traits, class _Allocator>
954 basic_stringbuf<_CharT, _Traits, _Allocator>*
955 basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
957 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
960 template <class _CharT, class _Traits, class _Allocator>
961 basic_string<_CharT, _Traits, _Allocator>
962 basic_stringstream<_CharT, _Traits, _Allocator>::str() const
967 template <class _CharT, class _Traits, class _Allocator>
969 basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
974 _LIBCPP_END_NAMESPACE_STD
978 #endif // _LIBCPP_SSTREAM