33#ifndef _GLIBCXX_SSTREAM
34#define _GLIBCXX_SSTREAM 1
37#pragma GCC system_header
47#define __glibcxx_want_sstream_from_string_view
50#ifdef __cpp_lib_sstream_from_string_view
54#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
55# define _GLIBCXX_LVAL_REF_QUAL &
56# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
58# define _GLIBCXX_LVAL_REF_QUAL
60# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
63namespace std _GLIBCXX_VISIBILITY(default)
65_GLIBCXX_BEGIN_NAMESPACE_VERSION
66_GLIBCXX_BEGIN_NAMESPACE_CXX11
86 template<
typename _CharT,
typename _Traits,
typename _Alloc>
89 struct __xfer_bufptrs;
91#if __cplusplus >= 201103L
100 typedef _CharT char_type;
101 typedef _Traits traits_type;
104 typedef _Alloc allocator_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;
111 typedef typename __string_type::size_type __size_type;
118 __string_type _M_string;
142 : __streambuf_type(),
_M_mode(__mode), _M_string()
156 : __streambuf_type(),
_M_mode(),
157 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
158 { _M_stringbuf_init(__mode); }
160#if __cplusplus >= 201103L
165 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
167#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
175 const allocator_type& __a)
176 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
183 : __streambuf_type(),
_M_mode(__mode), _M_string(std::
move(__s))
184 { _M_stringbuf_init(__mode); }
186 template<
typename _SAlloc>
188 const allocator_type& __a)
192 template<
typename _SAlloc>
195 const allocator_type& __a)
196 : __streambuf_type(),
_M_mode(__mode),
197 _M_string(__s.
data(), __s.
size(), __a)
198 { _M_stringbuf_init(__mode); }
200 template<
typename _SAlloc>
209#ifdef __cpp_lib_sstream_from_string_view
210 template<
typename _Tp>
214 requires (is_convertible_v<
const _Tp&,
215 basic_string_view<_CharT, _Traits>>)
219 template<
typename _Tp>
221 requires (is_convertible_v<
const _Tp&,
222 basic_string_view<_CharT, _Traits>>)
226 template<
typename _Tp>
228 const allocator_type& __a)
229 requires (is_convertible_v<
const _Tp&,
230 basic_string_view<_CharT, _Traits>>)
231 : _M_string(__t, __a)
232 { _M_stringbuf_init(__mode); }
235#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
239 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
241 allocator_type get_allocator() const noexcept
242 {
return _M_string.get_allocator(); }
253 __xfer_bufptrs __st{__rhs,
this};
254 const __streambuf_type&
__base = __rhs;
255 __streambuf_type::operator=(__base);
259 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
267 __xfer_bufptrs __r_st{__rhs,
this};
268 __streambuf_type&
__base = __rhs;
269 __streambuf_type::swap(__base);
270 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
271 std::swap(
_M_mode, __rhs._M_mode);
272 std::swap(_M_string, __rhs._M_string);
288 str() const _GLIBCXX_LVAL_REF_QUAL
290 __string_type __ret(_M_string.get_allocator());
291 if (char_type* __hi = _M_high_mark())
298#if __cplusplus > 201703L
299#if _GLIBCXX_USE_CXX11_ABI
302 template<__allocator_like _SAlloc>
305 str(
const _SAlloc& __sa)
const
308 return { __sv.data(), __sv.size(), __sa };
316 if (char_type* __hi = _M_high_mark())
319 _M_string._M_set_length(_M_high_mark() - this->
pbase());
323 _M_sync(_M_string.data(), 0, 0);
328 _GLIBCXX_SSTREAM_ALWAYS_INLINE
329 basic_string_view<char_type, traits_type>
330 view() const noexcept
332 if (char_type* __hi = _M_high_mark())
333 return { this->
pbase(), __hi };
347 str(
const __string_type& __s)
355#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
358 template<__allocator_like _SAlloc>
359 requires (!is_same_v<_SAlloc, _Alloc>)
369 str(__string_type&& __s)
376#ifdef __cpp_lib_sstream_from_string_view
377 template <
typename _Tp>
380 requires (is_convertible_v<
const _Tp&,
381 basic_string_view<_CharT, _Traits>>)
383 basic_string_view<_CharT, _Traits> __sv{__t};
395 __size_type __len = 0;
397 __len = _M_string.size();
398 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
417 pbackfail(int_type __c = traits_type::eof());
420 overflow(int_type __c = traits_type::eof());
433 virtual __streambuf_type*
447 _M_sync(__s, __n, 0);
464 _M_sync(char_type* __base, __size_type __i, __size_type __o);
471 if (char_type* __pptr = this->
pptr())
473 char_type* __egptr = this->
egptr();
474 if (!__egptr || __pptr > __egptr)
479 this->
setg(__pptr, __pptr, __pptr);
487 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
494 __attribute__((__always_inline__))
496 _M_high_mark() const _GLIBCXX_NOEXCEPT
498 if (char_type* __pptr = this->
pptr())
500 char_type* __egptr = this->
egptr();
501 if (!__egptr || __pptr > __egptr)
509#if __cplusplus >= 201103L
510#if _GLIBCXX_USE_CXX11_ABI
513 struct __xfer_bufptrs
516 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
518 const _CharT*
const __str = __from._M_string.data();
519 const _CharT* __end =
nullptr;
522 _M_goff[0] = __from.eback() - __str;
523 _M_goff[1] = __from.gptr() - __str;
524 _M_goff[2] = __from.egptr() - __str;
525 __end = __from.egptr();
529 _M_poff[0] = __from.pbase() - __str;
530 _M_poff[1] = __from.pptr() - __from.pbase();
531 _M_poff[2] = __from.epptr() - __str;
532 if (!__end || __from.pptr() > __end)
533 __end = __from.pptr();
542 __mut_from._M_string._M_length(__end - __str);
549 if (_M_goff[0] != -1)
550 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
551 if (_M_poff[0] != -1)
552 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
561 struct __xfer_bufptrs
570 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
574#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
581 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
604 template<
typename _CharT,
typename _Traits,
typename _Alloc>
609 typedef _CharT char_type;
610 typedef _Traits traits_type;
613 typedef _Alloc allocator_type;
614 typedef typename traits_type::int_type int_type;
615 typedef typename traits_type::pos_type pos_type;
616 typedef typename traits_type::off_type off_type;
624 __stringbuf_type _M_stringbuf;
639 : __istream_type(), _M_stringbuf(
ios_base::
in)
656 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
675 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
687#if __cplusplus >= 201103L
691 : __istream_type(
std::
move(__rhs)),
692 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
695#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
698 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
704 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
707 template<
typename _SAlloc>
709 const allocator_type& __a)
713 template<
typename _SAlloc>
716 const allocator_type& __a)
717 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
720 template<
typename _SAlloc>
728#ifdef __cpp_lib_sstream_from_string_view
729 template <
typename _Tp>
733 requires (is_convertible_v<
const _Tp&,
734 basic_string_view<_CharT, _Traits>>)
738 template <
typename _Tp>
740 requires (is_convertible_v<
const _Tp&,
741 basic_string_view<_CharT, _Traits>>)
745 template <
typename _Tp>
747 const allocator_type& __a)
748 requires (is_convertible_v<
const _Tp&,
749 basic_string_view<_CharT, _Traits>>)
750 : __istream_type(), _M_stringbuf(__t, __mode | ios_base::
in, __a)
762 __istream_type::operator=(
std::move(__rhs));
763 _M_stringbuf =
std::move(__rhs._M_stringbuf);
770 __istream_type::swap(__rhs);
771 _M_stringbuf.swap(__rhs._M_stringbuf);
793 str() const _GLIBCXX_LVAL_REF_QUAL
794 {
return _M_stringbuf.str(); }
796#if __cplusplus > 201703L
797#if _GLIBCXX_USE_CXX11_ABI
800 template<__allocator_like _SAlloc>
803 str(
const _SAlloc& __sa)
const
804 {
return _M_stringbuf.str(__sa); }
810 {
return std::move(_M_stringbuf).str(); }
813 _GLIBCXX_SSTREAM_ALWAYS_INLINE
814 basic_string_view<char_type, traits_type>
815 view() const noexcept
816 {
return _M_stringbuf.view(); }
826 str(
const __string_type& __s)
827 { _M_stringbuf.str(__s); }
829#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
832 template<__allocator_like _SAlloc>
833 requires (!is_same_v<_SAlloc, _Alloc>)
836 { _M_stringbuf.str(__s); }
840 str(__string_type&& __s)
844#ifdef __cpp_lib_sstream_from_string_view
845 template<
typename _Tp>
848 requires (is_convertible_v<
const _Tp&,
849 basic_string_view<_CharT, _Traits>>)
850 { _M_stringbuf.str(__t); }
870 template <
typename _CharT,
typename _Traits,
typename _Alloc>
875 typedef _CharT char_type;
876 typedef _Traits traits_type;
879 typedef _Alloc allocator_type;
880 typedef typename traits_type::int_type int_type;
881 typedef typename traits_type::pos_type pos_type;
882 typedef typename traits_type::off_type off_type;
890 __stringbuf_type _M_stringbuf;
922 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
941 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
953#if __cplusplus >= 201103L
957 : __ostream_type(
std::
move(__rhs)),
958 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
961#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
964 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
970 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
973 template<
typename _SAlloc>
975 const allocator_type& __a)
979 template<
typename _SAlloc>
982 const allocator_type& __a)
983 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
986 template<
typename _SAlloc>
994#ifdef __cpp_lib_sstream_from_string_view
995 template <
typename _Tp>
999 requires (is_convertible_v<
const _Tp&,
1000 basic_string_view<_CharT, _Traits>>)
1004 template <
typename _Tp>
1006 requires (is_convertible_v<
const _Tp&,
1007 basic_string_view<_CharT, _Traits>>)
1011 template <
typename _Tp>
1013 const allocator_type& __a)
1014 requires (is_convertible_v<
const _Tp&,
1015 basic_string_view<_CharT, _Traits>>)
1016 : __ostream_type(), _M_stringbuf(__t, __mode | ios_base::
out, __a)
1028 __ostream_type::operator=(
std::move(__rhs));
1029 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1036 __ostream_type::swap(__rhs);
1037 _M_stringbuf.swap(__rhs._M_stringbuf);
1059 str() const _GLIBCXX_LVAL_REF_QUAL
1060 {
return _M_stringbuf.str(); }
1062#if __cplusplus > 201703L
1063#if _GLIBCXX_USE_CXX11_ABI
1066 template<__allocator_like _SAlloc>
1069 str(
const _SAlloc& __sa)
const
1070 {
return _M_stringbuf.str(__sa); }
1076 {
return std::move(_M_stringbuf).str(); }
1079 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1080 basic_string_view<char_type, traits_type>
1081 view() const noexcept
1082 {
return _M_stringbuf.view(); }
1093 { _M_stringbuf.str(__s); }
1095#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1098 template<__allocator_like _SAlloc>
1099 requires (!is_same_v<_SAlloc, _Alloc>)
1102 { _M_stringbuf.str(__s); }
1106 str(__string_type&& __s)
1110#ifdef __cpp_lib_sstream_from_string_view
1111 template<
typename _Tp>
1114 requires (is_convertible_v<
const _Tp&,
1115 basic_string_view<_CharT, _Traits>>)
1116 { _M_stringbuf.str(__t); }
1136 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1141 typedef _CharT char_type;
1142 typedef _Traits traits_type;
1145 typedef _Alloc allocator_type;
1146 typedef typename traits_type::int_type int_type;
1147 typedef typename traits_type::pos_type pos_type;
1148 typedef typename traits_type::off_type off_type;
1156 __stringbuf_type _M_stringbuf;
1186 : __iostream_type(), _M_stringbuf(__m)
1203 : __iostream_type(), _M_stringbuf(__str, __m)
1215#if __cplusplus >= 201103L
1219 : __iostream_type(
std::
move(__rhs)),
1220 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1223#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1226 : __iostream_type(), _M_stringbuf(__mode, __a)
1233 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1236 template<
typename _SAlloc>
1238 const allocator_type& __a)
1242 template<
typename _SAlloc>
1245 const allocator_type& __a)
1246 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1249 template<
typename _SAlloc>
1258#ifdef __cpp_lib_sstream_from_string_view
1259 template <
typename _Tp>
1263 requires (is_convertible_v<
const _Tp&,
1264 basic_string_view<_CharT, _Traits>>)
1268 template <
typename _Tp>
1270 requires (is_convertible_v<
const _Tp&,
1271 basic_string_view<_CharT, _Traits>>)
1275 template <
typename _Tp>
1277 const allocator_type& __a)
1278 requires (is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>)
1279 : __iostream_type(), _M_stringbuf(__t, __mode, __a)
1291 __iostream_type::operator=(
std::move(__rhs));
1292 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1299 __iostream_type::swap(__rhs);
1300 _M_stringbuf.swap(__rhs._M_stringbuf);
1322 str() const _GLIBCXX_LVAL_REF_QUAL
1323 {
return _M_stringbuf.str(); }
1325#if __cplusplus > 201703L
1326#if _GLIBCXX_USE_CXX11_ABI
1329 template<__allocator_like _SAlloc>
1332 str(
const _SAlloc& __sa)
const
1333 {
return _M_stringbuf.str(__sa); }
1339 {
return std::move(_M_stringbuf).str(); }
1342 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1343 basic_string_view<char_type, traits_type>
1344 view() const noexcept
1345 {
return _M_stringbuf.view(); }
1356 { _M_stringbuf.str(__s); }
1358#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1361 template<__allocator_like _SAlloc>
1362 requires (!is_same_v<_SAlloc, _Alloc>)
1365 { _M_stringbuf.str(__s); }
1369 str(__string_type&& __s)
1373#ifdef __cpp_lib_sstream_from_string_view
1374 template<
typename _Tp>
1377 requires (is_convertible_v<
const _Tp&,
1378 basic_string_view<_CharT, _Traits>>)
1379 { _M_stringbuf.str(__t); }
1383#if __cplusplus >= 201103L
1385 template <
class _CharT,
class _Traits,
class _Allocator>
1389 noexcept(
noexcept(__x.swap(__y)))
1393 template <
class _CharT,
class _Traits,
class _Allocator>
1400 template <
class _CharT,
class _Traits,
class _Allocator>
1407 template <
class _CharT,
class _Traits,
class _Allocator>
1414_GLIBCXX_END_NAMESPACE_CXX11
1415_GLIBCXX_END_NAMESPACE_VERSION
1418#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1419#undef _GLIBCXX_LVAL_REF_QUAL
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
Return the data pointer of a container.
constexpr _Iterator __base(_Iterator __it)
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
char_type * pptr() const
Access to the put area.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * eback() const
Access to the get area.
char_type * egptr() const
Access to the get area.
char_type * gptr() const
Access to the get area.
locale pubimbue(const locale &__loc)
Entry point for imbue().
char_type * pbase() const
Access to the put area.
traits_type::off_type off_type
basic_streambuf()
Base constructor.
basic_istream(__streambuf_type *__sb)
Base constructor.
basic_ostream(__streambuf_type *__sb)
Base constructor.
basic_iostream(basic_streambuf< _CharT, _Traits > *__sb)
Constructor does nothing.
The actual work of input and output (for std::string).
virtual streamsize showmanyc()
Investigating the data available.
virtual int_type underflow()
Fetches more data from the controlled sequence.
virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
basic_stringbuf()
Starts with an empty string buffer.
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
__string_type str() const &
Copying out the string buffer.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
ios_base::openmode _M_mode
Controlling input for std::string.
void str(const __string_type &__s)
Setting a new buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
~basic_istringstream()
The destructor does nothing.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
__string_type str() const &
Copying out the string buffer.
basic_istringstream()
Default constructor starts with an empty string buffer.
basic_istringstream(ios_base::openmode __mode)
Starts with an empty string buffer.
Controlling output for std::string.
~basic_ostringstream()
The destructor does nothing.
void str(const __string_type &__s)
Setting a new buffer.
basic_ostringstream()
Default constructor starts with an empty string buffer.
basic_ostringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::out)
Starts with an existing string buffer.
__string_type str() const &
Copying out the string buffer.
basic_ostringstream(ios_base::openmode __mode)
Starts with an empty string buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
Controlling input and output for std::string.
~basic_stringstream()
The destructor does nothing.
basic_stringstream(const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
Starts with an existing string buffer.
basic_stringstream()
Default constructor starts with an empty string buffer.
void str(const __string_type &__s)
Setting a new buffer.
__string_type str() const &
Copying out the string buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_stringstream(ios_base::openmode __m)
Starts with an empty string buffer.
Uniform interface to all allocator types.
typename __detected_or_t< is_empty< _Alloc >, __equal, _Alloc >::type is_always_equal
Whether all instances of the allocator type compare equal.
__detected_or_t< false_type, __pocs, _Alloc > propagate_on_container_swap
How the allocator is propagated on swap.
Managing sequences of characters and character-like objects.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr const _CharT * data() const noexcept
Return const pointer to contents.
constexpr basic_string & assign(const basic_string &__str)
Set value to contents of another string.
The base of the I/O class hierarchy.
static const openmode in
Open for input. Default for ifstream and fstream.
static const openmode out
Open for output. Default for ofstream and fstream.
_Ios_Openmode openmode
This is a bitmask type.
static const openmode app
Seek to end before each write.
_Ios_Seekdir seekdir
This is an enumerated type.
static const openmode ate
Open and seek to end immediately after opening.