blob: 411374207b4a2f8c211045000ed7ee6ecd0028b6 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- sstream ----------------------------------===//
3//
Howard Hinnantc566dc32010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00005//
Howard Hinnantee11c312010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc51e1022010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_SSTREAM
12#define _LIBCPP_SSTREAM
13
14/*
15 sstream synopsis
16
17template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
18class basic_stringbuf
19 : public basic_streambuf<charT, traits>
20{
21public:
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;
28
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);
34
35 // 27.8.1.2 Assign and swap:
36 basic_stringbuf& operator=(basic_stringbuf&& rhs);
37 void swap(basic_stringbuf& rhs);
38
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);
42
43protected:
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);
53};
54
55template <class charT, class traits, class Allocator>
56 void swap(basic_stringbuf<charT, traits, Allocator>& x,
57 basic_stringbuf<charT, traits, Allocator>& y);
58
59typedef basic_stringbuf<char> stringbuf;
60typedef basic_stringbuf<wchar_t> wstringbuf;
61
62template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
63class basic_istringstream
64 : public basic_istream<charT, traits>
65{
66public:
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;
73
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);
79
80 // 27.8.2.2 Assign and swap:
81 basic_istringstream& operator=(basic_istringstream&& rhs);
82 void swap(basic_istringstream& rhs);
83
84 // 27.8.2.3 Members:
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);
88};
89
90template <class charT, class traits, class Allocator>
91 void swap(basic_istringstream<charT, traits, Allocator>& x,
92 basic_istringstream<charT, traits, Allocator>& y);
93
94typedef basic_istringstream<char> istringstream;
95typedef basic_istringstream<wchar_t> wistringstream;
96
97template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
98class basic_ostringstream
99 : public basic_ostream<charT, traits>
100{
101public:
102 // types:
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;
109
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);
115
116 // 27.8.3.2 Assign/swap:
117 basic_ostringstream& operator=(basic_ostringstream&& rhs);
118 void swap(basic_ostringstream& rhs);
119
120 // 27.8.3.3 Members:
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);
124};
125
126template <class charT, class traits, class Allocator>
127 void swap(basic_ostringstream<charT, traits, Allocator>& x,
128 basic_ostringstream<charT, traits, Allocator>& y);
129
130typedef basic_ostringstream<char> ostringstream;
131typedef basic_ostringstream<wchar_t> wostringstream;
132
133template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
134class basic_stringstream
135 : public basic_iostream<charT, traits>
136{
137public:
138 // types:
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;
145
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);
151
152 // 27.8.5.1 Assign/swap:
153 basic_stringstream& operator=(basic_stringstream&& rhs);
154 void swap(basic_stringstream& rhs);
155
156 // Members:
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);
160};
161
162template <class charT, class traits, class Allocator>
163 void swap(basic_stringstream<charT, traits, Allocator>& x,
164 basic_stringstream<charT, traits, Allocator>& y);
165
166typedef basic_stringstream<char> stringstream;
167typedef basic_stringstream<wchar_t> wstringstream;
168
169} // std
170
171*/
172
173#include <__config>
174#include <ostream>
175#include <istream>
176#include <string>
177
Howard Hinnantc5a5fbd2011-11-29 16:45:27 +0000178#include <__undef_min_max>
179
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000180#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000181#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000182#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000183
184_LIBCPP_BEGIN_NAMESPACE_STD
185
186// basic_stringbuf
187
188template <class _CharT, class _Traits, class _Allocator>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000189class _LIBCPP_TEMPLATE_VIS basic_stringbuf
Howard Hinnantc51e1022010-05-11 19:42:16 +0000190 : public basic_streambuf<_CharT, _Traits>
191{
192public:
193 typedef _CharT char_type;
194 typedef _Traits traits_type;
195 typedef typename traits_type::int_type int_type;
196 typedef typename traits_type::pos_type pos_type;
197 typedef typename traits_type::off_type off_type;
198 typedef _Allocator allocator_type;
199
200 typedef basic_string<char_type, traits_type, allocator_type> string_type;
201
202private:
203
204 string_type __str_;
205 mutable char_type* __hm_;
206 ios_base::openmode __mode_;
207
208public:
209 // 27.8.1.1 Constructors:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000210 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000211 explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000212 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000213 explicit basic_stringbuf(const string_type& __s,
214 ios_base::openmode __wch = ios_base::in | ios_base::out);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000215#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000216 basic_stringbuf(basic_stringbuf&& __rhs);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000217
218 // 27.8.1.2 Assign and swap:
Howard Hinnantc51e1022010-05-11 19:42:16 +0000219 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
220#endif
221 void swap(basic_stringbuf& __rhs);
222
223 // 27.8.1.3 Get and set:
224 string_type str() const;
225 void str(const string_type& __s);
226
227protected:
228 // 27.8.1.4 Overridden virtual functions:
229 virtual int_type underflow();
230 virtual int_type pbackfail(int_type __c = traits_type::eof());
231 virtual int_type overflow (int_type __c = traits_type::eof());
232 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
233 ios_base::openmode __wch = ios_base::in | ios_base::out);
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000234 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000235 virtual pos_type seekpos(pos_type __sp,
236 ios_base::openmode __wch = ios_base::in | ios_base::out);
237};
238
239template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000240basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
241 : __hm_(0),
242 __mode_(__wch)
243{
244 str(string_type());
245}
246
247template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000248basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
249 ios_base::openmode __wch)
250 : __hm_(0),
251 __mode_(__wch)
252{
253 str(__s);
254}
255
Eric Fiselier78ccf772017-04-18 23:38:41 +0000256#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000257
258template <class _CharT, class _Traits, class _Allocator>
259basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
260 : __mode_(__rhs.__mode_)
261{
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000262 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
263 ptrdiff_t __binp = -1;
264 ptrdiff_t __ninp = -1;
265 ptrdiff_t __einp = -1;
266 if (__rhs.eback() != nullptr)
267 {
268 __binp = __rhs.eback() - __p;
269 __ninp = __rhs.gptr() - __p;
270 __einp = __rhs.egptr() - __p;
271 }
272 ptrdiff_t __bout = -1;
273 ptrdiff_t __nout = -1;
274 ptrdiff_t __eout = -1;
275 if (__rhs.pbase() != nullptr)
276 {
277 __bout = __rhs.pbase() - __p;
278 __nout = __rhs.pptr() - __p;
279 __eout = __rhs.epptr() - __p;
280 }
281 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000282 __str_ = _VSTD::move(__rhs.__str_);
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000283 __p = const_cast<char_type*>(__str_.data());
284 if (__binp != -1)
285 this->setg(__p + __binp, __p + __ninp, __p + __einp);
286 if (__bout != -1)
287 {
288 this->setp(__p + __bout, __p + __eout);
289 this->pbump(__nout);
290 }
291 __hm_ = __hm == -1 ? nullptr : __p + __hm;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000292 __p = const_cast<char_type*>(__rhs.__str_.data());
293 __rhs.setg(__p, __p, __p);
294 __rhs.setp(__p, __p);
295 __rhs.__hm_ = __p;
296 this->pubimbue(__rhs.getloc());
297}
298
299template <class _CharT, class _Traits, class _Allocator>
300basic_stringbuf<_CharT, _Traits, _Allocator>&
301basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
302{
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000303 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
304 ptrdiff_t __binp = -1;
305 ptrdiff_t __ninp = -1;
306 ptrdiff_t __einp = -1;
307 if (__rhs.eback() != nullptr)
308 {
309 __binp = __rhs.eback() - __p;
310 __ninp = __rhs.gptr() - __p;
311 __einp = __rhs.egptr() - __p;
312 }
313 ptrdiff_t __bout = -1;
314 ptrdiff_t __nout = -1;
315 ptrdiff_t __eout = -1;
316 if (__rhs.pbase() != nullptr)
317 {
318 __bout = __rhs.pbase() - __p;
319 __nout = __rhs.pptr() - __p;
320 __eout = __rhs.epptr() - __p;
321 }
322 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000323 __str_ = _VSTD::move(__rhs.__str_);
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000324 __p = const_cast<char_type*>(__str_.data());
325 if (__binp != -1)
326 this->setg(__p + __binp, __p + __ninp, __p + __einp);
Marshall Clow45e157b2014-09-16 18:57:52 +0000327 else
328 this->setg(nullptr, nullptr, nullptr);
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000329 if (__bout != -1)
330 {
331 this->setp(__p + __bout, __p + __eout);
332 this->pbump(__nout);
333 }
Marshall Clow45e157b2014-09-16 18:57:52 +0000334 else
335 this->setp(nullptr, nullptr);
336
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000337 __hm_ = __hm == -1 ? nullptr : __p + __hm;
338 __mode_ = __rhs.__mode_;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000339 __p = const_cast<char_type*>(__rhs.__str_.data());
340 __rhs.setg(__p, __p, __p);
341 __rhs.setp(__p, __p);
342 __rhs.__hm_ = __p;
343 this->pubimbue(__rhs.getloc());
344 return *this;
345}
346
Eric Fiselier78ccf772017-04-18 23:38:41 +0000347#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000348
349template <class _CharT, class _Traits, class _Allocator>
350void
351basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
352{
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000353 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
354 ptrdiff_t __rbinp = -1;
355 ptrdiff_t __rninp = -1;
356 ptrdiff_t __reinp = -1;
357 if (__rhs.eback() != nullptr)
358 {
359 __rbinp = __rhs.eback() - __p;
360 __rninp = __rhs.gptr() - __p;
361 __reinp = __rhs.egptr() - __p;
362 }
363 ptrdiff_t __rbout = -1;
364 ptrdiff_t __rnout = -1;
365 ptrdiff_t __reout = -1;
366 if (__rhs.pbase() != nullptr)
367 {
368 __rbout = __rhs.pbase() - __p;
369 __rnout = __rhs.pptr() - __p;
370 __reout = __rhs.epptr() - __p;
371 }
372 ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
373 __p = const_cast<char_type*>(__str_.data());
374 ptrdiff_t __lbinp = -1;
375 ptrdiff_t __lninp = -1;
376 ptrdiff_t __leinp = -1;
377 if (this->eback() != nullptr)
378 {
379 __lbinp = this->eback() - __p;
380 __lninp = this->gptr() - __p;
381 __leinp = this->egptr() - __p;
382 }
383 ptrdiff_t __lbout = -1;
384 ptrdiff_t __lnout = -1;
385 ptrdiff_t __leout = -1;
386 if (this->pbase() != nullptr)
387 {
388 __lbout = this->pbase() - __p;
389 __lnout = this->pptr() - __p;
390 __leout = this->epptr() - __p;
391 }
392 ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000393 _VSTD::swap(__mode_, __rhs.__mode_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000394 __str_.swap(__rhs.__str_);
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000395 __p = const_cast<char_type*>(__str_.data());
396 if (__rbinp != -1)
397 this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
398 else
399 this->setg(nullptr, nullptr, nullptr);
400 if (__rbout != -1)
401 {
402 this->setp(__p + __rbout, __p + __reout);
403 this->pbump(__rnout);
404 }
405 else
406 this->setp(nullptr, nullptr);
407 __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000408 __p = const_cast<char_type*>(__rhs.__str_.data());
Howard Hinnantd6d6e102013-04-03 20:21:29 +0000409 if (__lbinp != -1)
410 __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
411 else
412 __rhs.setg(nullptr, nullptr, nullptr);
413 if (__lbout != -1)
414 {
415 __rhs.setp(__p + __lbout, __p + __leout);
416 __rhs.pbump(__lnout);
417 }
418 else
419 __rhs.setp(nullptr, nullptr);
420 __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000421 locale __tl = __rhs.getloc();
422 __rhs.pubimbue(this->getloc());
423 this->pubimbue(__tl);
424}
425
426template <class _CharT, class _Traits, class _Allocator>
Evgeniy Stepanovb9254262016-01-08 19:21:02 +0000427inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000428void
429swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
430 basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
431{
432 __x.swap(__y);
433}
434
435template <class _CharT, class _Traits, class _Allocator>
436basic_string<_CharT, _Traits, _Allocator>
437basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
438{
439 if (__mode_ & ios_base::out)
440 {
441 if (__hm_ < this->pptr())
442 __hm_ = this->pptr();
443 return string_type(this->pbase(), __hm_, __str_.get_allocator());
444 }
445 else if (__mode_ & ios_base::in)
446 return string_type(this->eback(), this->egptr(), __str_.get_allocator());
447 return string_type(__str_.get_allocator());
448}
449
450template <class _CharT, class _Traits, class _Allocator>
451void
452basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
453{
454 __str_ = __s;
455 __hm_ = 0;
456 if (__mode_ & ios_base::in)
457 {
458 __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
459 this->setg(const_cast<char_type*>(__str_.data()),
460 const_cast<char_type*>(__str_.data()),
461 __hm_);
462 }
463 if (__mode_ & ios_base::out)
464 {
465 typename string_type::size_type __sz = __str_.size();
466 __hm_ = const_cast<char_type*>(__str_.data()) + __sz;
467 __str_.resize(__str_.capacity());
468 this->setp(const_cast<char_type*>(__str_.data()),
469 const_cast<char_type*>(__str_.data()) + __str_.size());
470 if (__mode_ & (ios_base::app | ios_base::ate))
471 this->pbump(__sz);
472 }
473}
474
475template <class _CharT, class _Traits, class _Allocator>
476typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
477basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
478{
479 if (__hm_ < this->pptr())
480 __hm_ = this->pptr();
481 if (__mode_ & ios_base::in)
482 {
483 if (this->egptr() < __hm_)
484 this->setg(this->eback(), this->gptr(), __hm_);
485 if (this->gptr() < this->egptr())
486 return traits_type::to_int_type(*this->gptr());
487 }
488 return traits_type::eof();
489}
490
491template <class _CharT, class _Traits, class _Allocator>
492typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
493basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
494{
495 if (__hm_ < this->pptr())
496 __hm_ = this->pptr();
497 if (this->eback() < this->gptr())
498 {
499 if (traits_type::eq_int_type(__c, traits_type::eof()))
500 {
501 this->setg(this->eback(), this->gptr()-1, __hm_);
502 return traits_type::not_eof(__c);
503 }
504 if ((__mode_ & ios_base::out) ||
505 traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
506 {
507 this->setg(this->eback(), this->gptr()-1, __hm_);
508 *this->gptr() = traits_type::to_char_type(__c);
509 return __c;
510 }
511 }
512 return traits_type::eof();
513}
514
515template <class _CharT, class _Traits, class _Allocator>
516typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
517basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
518{
519 if (!traits_type::eq_int_type(__c, traits_type::eof()))
520 {
521 ptrdiff_t __ninp = this->gptr() - this->eback();
522 if (this->pptr() == this->epptr())
523 {
524 if (!(__mode_ & ios_base::out))
525 return traits_type::eof();
526#ifndef _LIBCPP_NO_EXCEPTIONS
527 try
528 {
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000529#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000530 ptrdiff_t __nout = this->pptr() - this->pbase();
531 ptrdiff_t __hm = __hm_ - this->pbase();
532 __str_.push_back(char_type());
533 __str_.resize(__str_.capacity());
534 char_type* __p = const_cast<char_type*>(__str_.data());
535 this->setp(__p, __p + __str_.size());
536 this->pbump(__nout);
537 __hm_ = this->pbase() + __hm;
538#ifndef _LIBCPP_NO_EXCEPTIONS
539 }
540 catch (...)
541 {
542 return traits_type::eof();
543 }
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000544#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000545 }
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000546 __hm_ = _VSTD::max(this->pptr() + 1, __hm_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000547 if (__mode_ & ios_base::in)
548 {
549 char_type* __p = const_cast<char_type*>(__str_.data());
550 this->setg(__p, __p + __ninp, __hm_);
551 }
552 return this->sputc(__c);
553 }
554 return traits_type::not_eof(__c);
555}
556
557template <class _CharT, class _Traits, class _Allocator>
558typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
559basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
560 ios_base::seekdir __way,
561 ios_base::openmode __wch)
562{
563 if (__hm_ < this->pptr())
564 __hm_ = this->pptr();
565 if ((__wch & (ios_base::in | ios_base::out)) == 0)
566 return pos_type(-1);
567 if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
568 && __way == ios_base::cur)
569 return pos_type(-1);
570 off_type __noff;
571 switch (__way)
572 {
573 case ios_base::beg:
574 __noff = 0;
575 break;
576 case ios_base::cur:
577 if (__wch & ios_base::in)
578 __noff = this->gptr() - this->eback();
579 else
580 __noff = this->pptr() - this->pbase();
581 break;
582 case ios_base::end:
583 __noff = __hm_ - __str_.data();
584 break;
585 default:
586 return pos_type(-1);
587 }
588 __noff += __off;
589 if (__noff < 0 || __hm_ - __str_.data() < __noff)
590 return pos_type(-1);
591 if (__noff != 0)
592 {
593 if ((__wch & ios_base::in) && this->gptr() == 0)
594 return pos_type(-1);
595 if ((__wch & ios_base::out) && this->pptr() == 0)
596 return pos_type(-1);
597 }
598 if (__wch & ios_base::in)
599 this->setg(this->eback(), this->eback() + __noff, __hm_);
600 if (__wch & ios_base::out)
601 {
602 this->setp(this->pbase(), this->epptr());
603 this->pbump(__noff);
604 }
605 return pos_type(__noff);
606}
607
608template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000609typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
610basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
611 ios_base::openmode __wch)
612{
613 return seekoff(__sp, ios_base::beg, __wch);
614}
615
616// basic_istringstream
617
618template <class _CharT, class _Traits, class _Allocator>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000619class _LIBCPP_TEMPLATE_VIS basic_istringstream
Howard Hinnantc51e1022010-05-11 19:42:16 +0000620 : public basic_istream<_CharT, _Traits>
621{
622public:
623 typedef _CharT char_type;
624 typedef _Traits traits_type;
625 typedef typename traits_type::int_type int_type;
626 typedef typename traits_type::pos_type pos_type;
627 typedef typename traits_type::off_type off_type;
628 typedef _Allocator allocator_type;
629
630 typedef basic_string<char_type, traits_type, allocator_type> string_type;
631
632private:
633 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
634
635public:
636 // 27.8.2.1 Constructors:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000637 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000638 explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000639 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000640 explicit basic_istringstream(const string_type& __s,
641 ios_base::openmode __wch = ios_base::in);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000642#ifndef _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000643 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000644 basic_istringstream(basic_istringstream&& __rhs);
645
646 // 27.8.2.2 Assign and swap:
647 basic_istringstream& operator=(basic_istringstream&& __rhs);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000648#endif // _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000649 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000650 void swap(basic_istringstream& __rhs);
651
652 // 27.8.2.3 Members:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000653 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000654 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000655 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000656 string_type str() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000657 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000658 void str(const string_type& __s);
659};
660
661template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000662basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
663 : basic_istream<_CharT, _Traits>(&__sb_),
664 __sb_(__wch | ios_base::in)
665{
666}
667
668template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000669basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
670 ios_base::openmode __wch)
671 : basic_istream<_CharT, _Traits>(&__sb_),
672 __sb_(__s, __wch | ios_base::in)
673{
674}
675
Eric Fiselier78ccf772017-04-18 23:38:41 +0000676#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000677
678template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000679basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000680 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
681 __sb_(_VSTD::move(__rhs.__sb_))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000682{
683 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
684}
685
686template <class _CharT, class _Traits, class _Allocator>
687basic_istringstream<_CharT, _Traits, _Allocator>&
688basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
689{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000690 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
691 __sb_ = _VSTD::move(__rhs.__sb_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000692 return *this;
693}
694
Eric Fiselier78ccf772017-04-18 23:38:41 +0000695#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000696
697template <class _CharT, class _Traits, class _Allocator>
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000698void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000699{
700 basic_istream<char_type, traits_type>::swap(__rhs);
701 __sb_.swap(__rhs.__sb_);
702}
703
704template <class _CharT, class _Traits, class _Allocator>
Evgeniy Stepanovb9254262016-01-08 19:21:02 +0000705inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000706void
707swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
708 basic_istringstream<_CharT, _Traits, _Allocator>& __y)
709{
710 __x.swap(__y);
711}
712
713template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000714basic_stringbuf<_CharT, _Traits, _Allocator>*
715basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
716{
717 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
718}
719
720template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000721basic_string<_CharT, _Traits, _Allocator>
722basic_istringstream<_CharT, _Traits, _Allocator>::str() const
723{
724 return __sb_.str();
725}
726
727template <class _CharT, class _Traits, class _Allocator>
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000728void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000729{
730 __sb_.str(__s);
731}
732
733// basic_ostringstream
734
735template <class _CharT, class _Traits, class _Allocator>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000736class _LIBCPP_TEMPLATE_VIS basic_ostringstream
Howard Hinnantc51e1022010-05-11 19:42:16 +0000737 : public basic_ostream<_CharT, _Traits>
738{
739public:
740 typedef _CharT char_type;
741 typedef _Traits traits_type;
742 typedef typename traits_type::int_type int_type;
743 typedef typename traits_type::pos_type pos_type;
744 typedef typename traits_type::off_type off_type;
745 typedef _Allocator allocator_type;
746
747 typedef basic_string<char_type, traits_type, allocator_type> string_type;
748
749private:
750 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
751
752public:
753 // 27.8.2.1 Constructors:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000754 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000755 explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000756 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000757 explicit basic_ostringstream(const string_type& __s,
758 ios_base::openmode __wch = ios_base::out);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000759#ifndef _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000760 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000761 basic_ostringstream(basic_ostringstream&& __rhs);
762
763 // 27.8.2.2 Assign and swap:
764 basic_ostringstream& operator=(basic_ostringstream&& __rhs);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000765#endif // _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000766 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000767 void swap(basic_ostringstream& __rhs);
768
769 // 27.8.2.3 Members:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000770 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000771 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000772 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000773 string_type str() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000774 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000775 void str(const string_type& __s);
776};
777
778template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000779basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
780 : basic_ostream<_CharT, _Traits>(&__sb_),
781 __sb_(__wch | ios_base::out)
782{
783}
784
785template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000786basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
787 ios_base::openmode __wch)
788 : basic_ostream<_CharT, _Traits>(&__sb_),
789 __sb_(__s, __wch | ios_base::out)
790{
791}
792
Eric Fiselier78ccf772017-04-18 23:38:41 +0000793#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000794
795template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000796basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000797 : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
798 __sb_(_VSTD::move(__rhs.__sb_))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000799{
800 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
801}
802
803template <class _CharT, class _Traits, class _Allocator>
804basic_ostringstream<_CharT, _Traits, _Allocator>&
805basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
806{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000807 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
808 __sb_ = _VSTD::move(__rhs.__sb_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000809 return *this;
810}
811
Eric Fiselier78ccf772017-04-18 23:38:41 +0000812#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000813
814template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000815void
816basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
817{
818 basic_ostream<char_type, traits_type>::swap(__rhs);
819 __sb_.swap(__rhs.__sb_);
820}
821
822template <class _CharT, class _Traits, class _Allocator>
Evgeniy Stepanovb9254262016-01-08 19:21:02 +0000823inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000824void
825swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
826 basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
827{
828 __x.swap(__y);
829}
830
831template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000832basic_stringbuf<_CharT, _Traits, _Allocator>*
833basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
834{
835 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
836}
837
838template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000839basic_string<_CharT, _Traits, _Allocator>
840basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
841{
842 return __sb_.str();
843}
844
845template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000846void
847basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
848{
849 __sb_.str(__s);
850}
851
852// basic_stringstream
853
854template <class _CharT, class _Traits, class _Allocator>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000855class _LIBCPP_TEMPLATE_VIS basic_stringstream
Howard Hinnantc51e1022010-05-11 19:42:16 +0000856 : public basic_iostream<_CharT, _Traits>
857{
858public:
859 typedef _CharT char_type;
860 typedef _Traits traits_type;
861 typedef typename traits_type::int_type int_type;
862 typedef typename traits_type::pos_type pos_type;
863 typedef typename traits_type::off_type off_type;
864 typedef _Allocator allocator_type;
865
866 typedef basic_string<char_type, traits_type, allocator_type> string_type;
867
868private:
869 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
870
871public:
872 // 27.8.2.1 Constructors:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000873 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000874 explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000875 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000876 explicit basic_stringstream(const string_type& __s,
877 ios_base::openmode __wch = ios_base::in | ios_base::out);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000878#ifndef _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000879 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000880 basic_stringstream(basic_stringstream&& __rhs);
881
882 // 27.8.2.2 Assign and swap:
883 basic_stringstream& operator=(basic_stringstream&& __rhs);
Eric Fiselier78ccf772017-04-18 23:38:41 +0000884#endif // _LIBCPP_CXX03_LANG
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000885 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000886 void swap(basic_stringstream& __rhs);
887
888 // 27.8.2.3 Members:
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000889 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000890 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000891 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000892 string_type str() const;
Eric Fiselier7fdc71a2016-09-16 02:09:26 +0000893 inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000894 void str(const string_type& __s);
895};
896
897template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000898basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
899 : basic_iostream<_CharT, _Traits>(&__sb_),
900 __sb_(__wch)
901{
902}
903
904template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000905basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
906 ios_base::openmode __wch)
907 : basic_iostream<_CharT, _Traits>(&__sb_),
908 __sb_(__s, __wch)
909{
910}
911
Eric Fiselier78ccf772017-04-18 23:38:41 +0000912#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000913
914template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000915basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000916 : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
917 __sb_(_VSTD::move(__rhs.__sb_))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000918{
919 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
920}
921
922template <class _CharT, class _Traits, class _Allocator>
923basic_stringstream<_CharT, _Traits, _Allocator>&
924basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
925{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000926 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
927 __sb_ = _VSTD::move(__rhs.__sb_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000928 return *this;
929}
930
Eric Fiselier78ccf772017-04-18 23:38:41 +0000931#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000932
933template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000934void
935basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
936{
937 basic_iostream<char_type, traits_type>::swap(__rhs);
938 __sb_.swap(__rhs.__sb_);
939}
940
941template <class _CharT, class _Traits, class _Allocator>
Evgeniy Stepanovb9254262016-01-08 19:21:02 +0000942inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000943void
944swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
945 basic_stringstream<_CharT, _Traits, _Allocator>& __y)
946{
947 __x.swap(__y);
948}
949
950template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000951basic_stringbuf<_CharT, _Traits, _Allocator>*
952basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
953{
954 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
955}
956
957template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000958basic_string<_CharT, _Traits, _Allocator>
959basic_stringstream<_CharT, _Traits, _Allocator>::str() const
960{
961 return __sb_.str();
962}
963
964template <class _CharT, class _Traits, class _Allocator>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000965void
966basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
967{
968 __sb_.str(__s);
969}
970
971_LIBCPP_END_NAMESPACE_STD
972
973#endif // _LIBCPP_SSTREAM