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)
248 template <class _CharT, class _Traits, class _Allocator>
249 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
250 ios_base::openmode __wch)
251 : __str_(__s.get_allocator()),
258 #ifndef _LIBCPP_CXX03_LANG
260 template <class _CharT, class _Traits, class _Allocator>
261 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
262 : __mode_(__rhs.__mode_)
264 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
265 ptrdiff_t __binp = -1;
266 ptrdiff_t __ninp = -1;
267 ptrdiff_t __einp = -1;
268 if (__rhs.eback() != nullptr)
270 __binp = __rhs.eback() - __p;
271 __ninp = __rhs.gptr() - __p;
272 __einp = __rhs.egptr() - __p;
274 ptrdiff_t __bout = -1;
275 ptrdiff_t __nout = -1;
276 ptrdiff_t __eout = -1;
277 if (__rhs.pbase() != nullptr)
279 __bout = __rhs.pbase() - __p;
280 __nout = __rhs.pptr() - __p;
281 __eout = __rhs.epptr() - __p;
283 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
284 __str_ = _VSTD::move(__rhs.__str_);
285 __p = const_cast<char_type*>(__str_.data());
287 this->setg(__p + __binp, __p + __ninp, __p + __einp);
290 this->setp(__p + __bout, __p + __eout);
291 this->__pbump(__nout);
293 __hm_ = __hm == -1 ? nullptr : __p + __hm;
294 __p = const_cast<char_type*>(__rhs.__str_.data());
295 __rhs.setg(__p, __p, __p);
296 __rhs.setp(__p, __p);
298 this->pubimbue(__rhs.getloc());
301 template <class _CharT, class _Traits, class _Allocator>
302 basic_stringbuf<_CharT, _Traits, _Allocator>&
303 basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
305 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
306 ptrdiff_t __binp = -1;
307 ptrdiff_t __ninp = -1;
308 ptrdiff_t __einp = -1;
309 if (__rhs.eback() != nullptr)
311 __binp = __rhs.eback() - __p;
312 __ninp = __rhs.gptr() - __p;
313 __einp = __rhs.egptr() - __p;
315 ptrdiff_t __bout = -1;
316 ptrdiff_t __nout = -1;
317 ptrdiff_t __eout = -1;
318 if (__rhs.pbase() != nullptr)
320 __bout = __rhs.pbase() - __p;
321 __nout = __rhs.pptr() - __p;
322 __eout = __rhs.epptr() - __p;
324 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
325 __str_ = _VSTD::move(__rhs.__str_);
326 __p = const_cast<char_type*>(__str_.data());
328 this->setg(__p + __binp, __p + __ninp, __p + __einp);
330 this->setg(nullptr, nullptr, nullptr);
333 this->setp(__p + __bout, __p + __eout);
334 this->__pbump(__nout);
337 this->setp(nullptr, nullptr);
339 __hm_ = __hm == -1 ? nullptr : __p + __hm;
340 __mode_ = __rhs.__mode_;
341 __p = const_cast<char_type*>(__rhs.__str_.data());
342 __rhs.setg(__p, __p, __p);
343 __rhs.setp(__p, __p);
345 this->pubimbue(__rhs.getloc());
349 #endif // _LIBCPP_CXX03_LANG
351 template <class _CharT, class _Traits, class _Allocator>
353 basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
355 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
356 ptrdiff_t __rbinp = -1;
357 ptrdiff_t __rninp = -1;
358 ptrdiff_t __reinp = -1;
359 if (__rhs.eback() != nullptr)
361 __rbinp = __rhs.eback() - __p;
362 __rninp = __rhs.gptr() - __p;
363 __reinp = __rhs.egptr() - __p;
365 ptrdiff_t __rbout = -1;
366 ptrdiff_t __rnout = -1;
367 ptrdiff_t __reout = -1;
368 if (__rhs.pbase() != nullptr)
370 __rbout = __rhs.pbase() - __p;
371 __rnout = __rhs.pptr() - __p;
372 __reout = __rhs.epptr() - __p;
374 ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
375 __p = const_cast<char_type*>(__str_.data());
376 ptrdiff_t __lbinp = -1;
377 ptrdiff_t __lninp = -1;
378 ptrdiff_t __leinp = -1;
379 if (this->eback() != nullptr)
381 __lbinp = this->eback() - __p;
382 __lninp = this->gptr() - __p;
383 __leinp = this->egptr() - __p;
385 ptrdiff_t __lbout = -1;
386 ptrdiff_t __lnout = -1;
387 ptrdiff_t __leout = -1;
388 if (this->pbase() != nullptr)
390 __lbout = this->pbase() - __p;
391 __lnout = this->pptr() - __p;
392 __leout = this->epptr() - __p;
394 ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
395 _VSTD::swap(__mode_, __rhs.__mode_);
396 __str_.swap(__rhs.__str_);
397 __p = const_cast<char_type*>(__str_.data());
399 this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
401 this->setg(nullptr, nullptr, nullptr);
404 this->setp(__p + __rbout, __p + __reout);
405 this->__pbump(__rnout);
408 this->setp(nullptr, nullptr);
409 __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
410 __p = const_cast<char_type*>(__rhs.__str_.data());
412 __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
414 __rhs.setg(nullptr, nullptr, nullptr);
417 __rhs.setp(__p + __lbout, __p + __leout);
418 __rhs.__pbump(__lnout);
421 __rhs.setp(nullptr, nullptr);
422 __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
423 locale __tl = __rhs.getloc();
424 __rhs.pubimbue(this->getloc());
425 this->pubimbue(__tl);
428 template <class _CharT, class _Traits, class _Allocator>
429 inline _LIBCPP_INLINE_VISIBILITY
431 swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
432 basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
437 template <class _CharT, class _Traits, class _Allocator>
438 basic_string<_CharT, _Traits, _Allocator>
439 basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
441 if (__mode_ & ios_base::out)
443 if (__hm_ < this->pptr())
444 __hm_ = this->pptr();
445 return string_type(this->pbase(), __hm_, __str_.get_allocator());
447 else if (__mode_ & ios_base::in)
448 return string_type(this->eback(), this->egptr(), __str_.get_allocator());
449 return string_type(__str_.get_allocator());
452 template <class _CharT, class _Traits, class _Allocator>
454 basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
458 if (__mode_ & ios_base::in)
460 __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
461 this->setg(const_cast<char_type*>(__str_.data()),
462 const_cast<char_type*>(__str_.data()),
465 if (__mode_ & ios_base::out)
467 typename string_type::size_type __sz = __str_.size();
468 __hm_ = const_cast<char_type*>(__str_.data()) + __sz;
469 __str_.resize(__str_.capacity());
470 this->setp(const_cast<char_type*>(__str_.data()),
471 const_cast<char_type*>(__str_.data()) + __str_.size());
472 if (__mode_ & (ios_base::app | ios_base::ate))
474 while (__sz > INT_MAX)
476 this->pbump(INT_MAX);
485 template <class _CharT, class _Traits, class _Allocator>
486 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
487 basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
489 if (__hm_ < this->pptr())
490 __hm_ = this->pptr();
491 if (__mode_ & ios_base::in)
493 if (this->egptr() < __hm_)
494 this->setg(this->eback(), this->gptr(), __hm_);
495 if (this->gptr() < this->egptr())
496 return traits_type::to_int_type(*this->gptr());
498 return traits_type::eof();
501 template <class _CharT, class _Traits, class _Allocator>
502 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
503 basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
505 if (__hm_ < this->pptr())
506 __hm_ = this->pptr();
507 if (this->eback() < this->gptr())
509 if (traits_type::eq_int_type(__c, traits_type::eof()))
511 this->setg(this->eback(), this->gptr()-1, __hm_);
512 return traits_type::not_eof(__c);
514 if ((__mode_ & ios_base::out) ||
515 traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
517 this->setg(this->eback(), this->gptr()-1, __hm_);
518 *this->gptr() = traits_type::to_char_type(__c);
522 return traits_type::eof();
525 template <class _CharT, class _Traits, class _Allocator>
526 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
527 basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
529 if (!traits_type::eq_int_type(__c, traits_type::eof()))
531 ptrdiff_t __ninp = this->gptr() - this->eback();
532 if (this->pptr() == this->epptr())
534 if (!(__mode_ & ios_base::out))
535 return traits_type::eof();
536 #ifndef _LIBCPP_NO_EXCEPTIONS
539 #endif // _LIBCPP_NO_EXCEPTIONS
540 ptrdiff_t __nout = this->pptr() - this->pbase();
541 ptrdiff_t __hm = __hm_ - this->pbase();
542 __str_.push_back(char_type());
543 __str_.resize(__str_.capacity());
544 char_type* __p = const_cast<char_type*>(__str_.data());
545 this->setp(__p, __p + __str_.size());
546 this->__pbump(__nout);
547 __hm_ = this->pbase() + __hm;
548 #ifndef _LIBCPP_NO_EXCEPTIONS
552 return traits_type::eof();
554 #endif // _LIBCPP_NO_EXCEPTIONS
556 __hm_ = _VSTD::max(this->pptr() + 1, __hm_);
557 if (__mode_ & ios_base::in)
559 char_type* __p = const_cast<char_type*>(__str_.data());
560 this->setg(__p, __p + __ninp, __hm_);
562 return this->sputc(__c);
564 return traits_type::not_eof(__c);
567 template <class _CharT, class _Traits, class _Allocator>
568 typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
569 basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
570 ios_base::seekdir __way,
571 ios_base::openmode __wch)
573 if (__hm_ < this->pptr())
574 __hm_ = this->pptr();
575 if ((__wch & (ios_base::in | ios_base::out)) == 0)
577 if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
578 && __way == ios_base::cur)
587 if (__wch & ios_base::in)
588 __noff = this->gptr() - this->eback();
590 __noff = this->pptr() - this->pbase();
593 __noff = __hm_ - __str_.data();
599 if (__noff < 0 || __hm_ - __str_.data() < __noff)
603 if ((__wch & ios_base::in) && this->gptr() == 0)
605 if ((__wch & ios_base::out) && this->pptr() == 0)
608 if (__wch & ios_base::in)
609 this->setg(this->eback(), this->eback() + __noff, __hm_);
610 if (__wch & ios_base::out)
612 this->setp(this->pbase(), this->epptr());
615 return pos_type(__noff);
618 template <class _CharT, class _Traits, class _Allocator>
619 typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
620 basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
621 ios_base::openmode __wch)
623 return seekoff(__sp, ios_base::beg, __wch);
626 // basic_istringstream
628 template <class _CharT, class _Traits, class _Allocator>
629 class _LIBCPP_TEMPLATE_VIS basic_istringstream
630 : public basic_istream<_CharT, _Traits>
633 typedef _CharT char_type;
634 typedef _Traits traits_type;
635 typedef typename traits_type::int_type int_type;
636 typedef typename traits_type::pos_type pos_type;
637 typedef typename traits_type::off_type off_type;
638 typedef _Allocator allocator_type;
640 typedef basic_string<char_type, traits_type, allocator_type> string_type;
643 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
646 // 27.8.2.1 Constructors:
647 inline _LIBCPP_INLINE_VISIBILITY
648 explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
649 inline _LIBCPP_INLINE_VISIBILITY
650 explicit basic_istringstream(const string_type& __s,
651 ios_base::openmode __wch = ios_base::in);
652 #ifndef _LIBCPP_CXX03_LANG
653 inline _LIBCPP_INLINE_VISIBILITY
654 basic_istringstream(basic_istringstream&& __rhs);
656 // 27.8.2.2 Assign and swap:
657 basic_istringstream& operator=(basic_istringstream&& __rhs);
658 #endif // _LIBCPP_CXX03_LANG
659 inline _LIBCPP_INLINE_VISIBILITY
660 void swap(basic_istringstream& __rhs);
663 inline _LIBCPP_INLINE_VISIBILITY
664 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
665 inline _LIBCPP_INLINE_VISIBILITY
666 string_type str() const;
667 inline _LIBCPP_INLINE_VISIBILITY
668 void str(const string_type& __s);
671 template <class _CharT, class _Traits, class _Allocator>
672 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
673 : basic_istream<_CharT, _Traits>(&__sb_),
674 __sb_(__wch | ios_base::in)
678 template <class _CharT, class _Traits, class _Allocator>
679 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
680 ios_base::openmode __wch)
681 : basic_istream<_CharT, _Traits>(&__sb_),
682 __sb_(__s, __wch | ios_base::in)
686 #ifndef _LIBCPP_CXX03_LANG
688 template <class _CharT, class _Traits, class _Allocator>
689 basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
690 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
691 __sb_(_VSTD::move(__rhs.__sb_))
693 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
696 template <class _CharT, class _Traits, class _Allocator>
697 basic_istringstream<_CharT, _Traits, _Allocator>&
698 basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
700 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
701 __sb_ = _VSTD::move(__rhs.__sb_);
705 #endif // _LIBCPP_CXX03_LANG
707 template <class _CharT, class _Traits, class _Allocator>
708 void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
710 basic_istream<char_type, traits_type>::swap(__rhs);
711 __sb_.swap(__rhs.__sb_);
714 template <class _CharT, class _Traits, class _Allocator>
715 inline _LIBCPP_INLINE_VISIBILITY
717 swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
718 basic_istringstream<_CharT, _Traits, _Allocator>& __y)
723 template <class _CharT, class _Traits, class _Allocator>
724 basic_stringbuf<_CharT, _Traits, _Allocator>*
725 basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
727 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
730 template <class _CharT, class _Traits, class _Allocator>
731 basic_string<_CharT, _Traits, _Allocator>
732 basic_istringstream<_CharT, _Traits, _Allocator>::str() const
737 template <class _CharT, class _Traits, class _Allocator>
738 void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
743 // basic_ostringstream
745 template <class _CharT, class _Traits, class _Allocator>
746 class _LIBCPP_TEMPLATE_VIS basic_ostringstream
747 : public basic_ostream<_CharT, _Traits>
750 typedef _CharT char_type;
751 typedef _Traits traits_type;
752 typedef typename traits_type::int_type int_type;
753 typedef typename traits_type::pos_type pos_type;
754 typedef typename traits_type::off_type off_type;
755 typedef _Allocator allocator_type;
757 typedef basic_string<char_type, traits_type, allocator_type> string_type;
760 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
763 // 27.8.2.1 Constructors:
764 inline _LIBCPP_INLINE_VISIBILITY
765 explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
766 inline _LIBCPP_INLINE_VISIBILITY
767 explicit basic_ostringstream(const string_type& __s,
768 ios_base::openmode __wch = ios_base::out);
769 #ifndef _LIBCPP_CXX03_LANG
770 inline _LIBCPP_INLINE_VISIBILITY
771 basic_ostringstream(basic_ostringstream&& __rhs);
773 // 27.8.2.2 Assign and swap:
774 basic_ostringstream& operator=(basic_ostringstream&& __rhs);
775 #endif // _LIBCPP_CXX03_LANG
776 inline _LIBCPP_INLINE_VISIBILITY
777 void swap(basic_ostringstream& __rhs);
780 inline _LIBCPP_INLINE_VISIBILITY
781 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
782 inline _LIBCPP_INLINE_VISIBILITY
783 string_type str() const;
784 inline _LIBCPP_INLINE_VISIBILITY
785 void str(const string_type& __s);
788 template <class _CharT, class _Traits, class _Allocator>
789 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
790 : basic_ostream<_CharT, _Traits>(&__sb_),
791 __sb_(__wch | ios_base::out)
795 template <class _CharT, class _Traits, class _Allocator>
796 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
797 ios_base::openmode __wch)
798 : basic_ostream<_CharT, _Traits>(&__sb_),
799 __sb_(__s, __wch | ios_base::out)
803 #ifndef _LIBCPP_CXX03_LANG
805 template <class _CharT, class _Traits, class _Allocator>
806 basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
807 : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
808 __sb_(_VSTD::move(__rhs.__sb_))
810 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
813 template <class _CharT, class _Traits, class _Allocator>
814 basic_ostringstream<_CharT, _Traits, _Allocator>&
815 basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
817 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
818 __sb_ = _VSTD::move(__rhs.__sb_);
822 #endif // _LIBCPP_CXX03_LANG
824 template <class _CharT, class _Traits, class _Allocator>
826 basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
828 basic_ostream<char_type, traits_type>::swap(__rhs);
829 __sb_.swap(__rhs.__sb_);
832 template <class _CharT, class _Traits, class _Allocator>
833 inline _LIBCPP_INLINE_VISIBILITY
835 swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
836 basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
841 template <class _CharT, class _Traits, class _Allocator>
842 basic_stringbuf<_CharT, _Traits, _Allocator>*
843 basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
845 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
848 template <class _CharT, class _Traits, class _Allocator>
849 basic_string<_CharT, _Traits, _Allocator>
850 basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
855 template <class _CharT, class _Traits, class _Allocator>
857 basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
862 // basic_stringstream
864 template <class _CharT, class _Traits, class _Allocator>
865 class _LIBCPP_TEMPLATE_VIS basic_stringstream
866 : public basic_iostream<_CharT, _Traits>
869 typedef _CharT char_type;
870 typedef _Traits traits_type;
871 typedef typename traits_type::int_type int_type;
872 typedef typename traits_type::pos_type pos_type;
873 typedef typename traits_type::off_type off_type;
874 typedef _Allocator allocator_type;
876 typedef basic_string<char_type, traits_type, allocator_type> string_type;
879 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
882 // 27.8.2.1 Constructors:
883 inline _LIBCPP_INLINE_VISIBILITY
884 explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
885 inline _LIBCPP_INLINE_VISIBILITY
886 explicit basic_stringstream(const string_type& __s,
887 ios_base::openmode __wch = ios_base::in | ios_base::out);
888 #ifndef _LIBCPP_CXX03_LANG
889 inline _LIBCPP_INLINE_VISIBILITY
890 basic_stringstream(basic_stringstream&& __rhs);
892 // 27.8.2.2 Assign and swap:
893 basic_stringstream& operator=(basic_stringstream&& __rhs);
894 #endif // _LIBCPP_CXX03_LANG
895 inline _LIBCPP_INLINE_VISIBILITY
896 void swap(basic_stringstream& __rhs);
899 inline _LIBCPP_INLINE_VISIBILITY
900 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
901 inline _LIBCPP_INLINE_VISIBILITY
902 string_type str() const;
903 inline _LIBCPP_INLINE_VISIBILITY
904 void str(const string_type& __s);
907 template <class _CharT, class _Traits, class _Allocator>
908 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
909 : basic_iostream<_CharT, _Traits>(&__sb_),
914 template <class _CharT, class _Traits, class _Allocator>
915 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
916 ios_base::openmode __wch)
917 : basic_iostream<_CharT, _Traits>(&__sb_),
922 #ifndef _LIBCPP_CXX03_LANG
924 template <class _CharT, class _Traits, class _Allocator>
925 basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
926 : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
927 __sb_(_VSTD::move(__rhs.__sb_))
929 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
932 template <class _CharT, class _Traits, class _Allocator>
933 basic_stringstream<_CharT, _Traits, _Allocator>&
934 basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
936 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
937 __sb_ = _VSTD::move(__rhs.__sb_);
941 #endif // _LIBCPP_CXX03_LANG
943 template <class _CharT, class _Traits, class _Allocator>
945 basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
947 basic_iostream<char_type, traits_type>::swap(__rhs);
948 __sb_.swap(__rhs.__sb_);
951 template <class _CharT, class _Traits, class _Allocator>
952 inline _LIBCPP_INLINE_VISIBILITY
954 swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
955 basic_stringstream<_CharT, _Traits, _Allocator>& __y)
960 template <class _CharT, class _Traits, class _Allocator>
961 basic_stringbuf<_CharT, _Traits, _Allocator>*
962 basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
964 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
967 template <class _CharT, class _Traits, class _Allocator>
968 basic_string<_CharT, _Traits, _Allocator>
969 basic_stringstream<_CharT, _Traits, _Allocator>::str() const
974 template <class _CharT, class _Traits, class _Allocator>
976 basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
981 _LIBCPP_END_NAMESPACE_STD
985 #endif // _LIBCPP_SSTREAM