33#ifndef _GLIBCXX_SSTREAM
34#define _GLIBCXX_SSTREAM 1
37#pragma GCC system_header
48#define __glibcxx_want_sstream_from_string_view
51#ifdef __cpp_lib_sstream_from_string_view
55#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
56# define _GLIBCXX_LVAL_REF_QUAL &
57# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
59# define _GLIBCXX_LVAL_REF_QUAL
61# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
67_GLIBCXX_BEGIN_NAMESPACE_CXX11
87 template<
typename _CharT,
typename _Traits,
typename _Alloc>
90 struct __xfer_bufptrs;
92#if __cplusplus >= 201103L
101 typedef _CharT char_type;
102 typedef _Traits traits_type;
105 typedef _Alloc allocator_type;
106 typedef typename traits_type::int_type int_type;
107 typedef typename traits_type::pos_type pos_type;
108 typedef typename traits_type::off_type off_type;
112 typedef typename __string_type::size_type __size_type;
119 __string_type _M_string;
143 : __streambuf_type(),
_M_mode(__mode), _M_string()
157 : __streambuf_type(),
_M_mode(),
158 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
159 { _M_stringbuf_init(__mode); }
161#if __cplusplus >= 201103L
166 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
168#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
176 const allocator_type& __a)
177 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
184 : __streambuf_type(),
_M_mode(__mode), _M_string(std::
move(__s))
185 { _M_stringbuf_init(__mode); }
187 template<
typename _SAlloc>
189 const allocator_type& __a)
193 template<
typename _SAlloc>
196 const allocator_type& __a)
197 : __streambuf_type(),
_M_mode(__mode),
198 _M_string(__s.
data(), __s.
size(), __a)
199 { _M_stringbuf_init(__mode); }
201 template<
typename _SAlloc>
210#ifdef __cpp_lib_sstream_from_string_view
211 template<
typename _Tp>
215 requires (is_convertible_v<
const _Tp&,
216 basic_string_view<_CharT, _Traits>>)
220 template<
typename _Tp>
222 requires (is_convertible_v<
const _Tp&,
223 basic_string_view<_CharT, _Traits>>)
227 template<
typename _Tp>
229 const allocator_type& __a)
230 requires (is_convertible_v<
const _Tp&,
231 basic_string_view<_CharT, _Traits>>)
232 : _M_string(__t, __a)
233 { _M_stringbuf_init(__mode); }
236#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
240 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
242 allocator_type get_allocator() const noexcept
243 {
return _M_string.get_allocator(); }
254 __xfer_bufptrs __st{__rhs,
this};
255 const __streambuf_type&
__base = __rhs;
256 __streambuf_type::operator=(__base);
260 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
268 __xfer_bufptrs __r_st{__rhs,
this};
269 __streambuf_type&
__base = __rhs;
270 __streambuf_type::swap(__base);
271 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
272 std::swap(
_M_mode, __rhs._M_mode);
273 std::swap(_M_string, __rhs._M_string);
289 str() const _GLIBCXX_LVAL_REF_QUAL
291 __string_type __ret(_M_string.get_allocator());
292 if (char_type* __hi = _M_high_mark())
299#if __cplusplus > 201703L
300#if _GLIBCXX_USE_CXX11_ABI
303 template<__allocator_like _SAlloc>
306 str(
const _SAlloc& __sa)
const
309 return { __sv.data(), __sv.size(), __sa };
317 if (char_type* __hi = _M_high_mark())
319 if (_M_string.data() == this->pbase()) [[likely]]
321 _M_string._M_set_length(__hi - this->
pbase());
323 _M_string.assign(this->
pbase(), __hi);
327 _M_sync(_M_string.data(), 0, 0);
332 _GLIBCXX_SSTREAM_ALWAYS_INLINE
333 basic_string_view<char_type, traits_type>
334 view() const noexcept
336 if (char_type* __hi = _M_high_mark())
337 return { this->
pbase(), __hi };
351 str(
const __string_type& __s)
359#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
362 template<__allocator_like _SAlloc>
363 requires (!is_same_v<_SAlloc, _Alloc>)
373 str(__string_type&& __s)
380#ifdef __cpp_lib_sstream_from_string_view
381 template <
typename _Tp>
384 requires (is_convertible_v<
const _Tp&,
385 basic_string_view<_CharT, _Traits>>)
387 basic_string_view<_CharT, _Traits> __sv{__t};
399 __size_type __len = 0;
401 __len = _M_string.size();
402 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
421 pbackfail(int_type __c = traits_type::eof());
424 overflow(int_type __c = traits_type::eof());
437 virtual __streambuf_type*
451 _M_sync(__s, __n, 0);
468 _M_sync(char_type* __base, __size_type __i, __size_type __o);
475 if (char_type* __pptr = this->
pptr())
477 char_type* __egptr = this->
egptr();
478 if (!__egptr || __pptr > __egptr)
483 this->
setg(__pptr, __pptr, __pptr);
491 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
498 __attribute__((__always_inline__))
500 _M_high_mark() const _GLIBCXX_NOEXCEPT
502 if (char_type* __pptr = this->
pptr())
504 char_type* __egptr = this->
egptr();
505 if (!__egptr || __pptr > __egptr)
513#if __cplusplus >= 201103L
514#if _GLIBCXX_USE_CXX11_ABI
517 struct __xfer_bufptrs
520 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
522 const _CharT*
const __str = __from._M_string.data();
523 const _CharT* __end =
nullptr;
526 _M_goff[0] = __from.eback() - __str;
527 _M_goff[1] = __from.gptr() - __str;
528 _M_goff[2] = __from.egptr() - __str;
529 __end = __from.egptr();
533 _M_poff[0] = __from.pbase() - __str;
534 _M_poff[1] = __from.pptr() - __from.pbase();
535 _M_poff[2] = __from.epptr() - __str;
536 if (!__end || __from.pptr() > __end)
537 __end = __from.pptr();
546 __mut_from._M_string._M_length(__end - __str);
553 if (_M_goff[0] != -1)
554 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
555 if (_M_poff[0] != -1)
556 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
565 struct __xfer_bufptrs
574 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
578#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
585 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
608 template<
typename _CharT,
typename _Traits,
typename _Alloc>
613 typedef _CharT char_type;
614 typedef _Traits traits_type;
617 typedef _Alloc allocator_type;
618 typedef typename traits_type::int_type int_type;
619 typedef typename traits_type::pos_type pos_type;
620 typedef typename traits_type::off_type off_type;
628 __stringbuf_type _M_stringbuf;
643 : __istream_type(), _M_stringbuf(
ios_base::
in)
660 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
679 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
691#if __cplusplus >= 201103L
695 : __istream_type(
std::
move(__rhs)),
696 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
699#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
702 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
708 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
711 template<
typename _SAlloc>
713 const allocator_type& __a)
717 template<
typename _SAlloc>
720 const allocator_type& __a)
721 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
724 template<
typename _SAlloc>
732#ifdef __cpp_lib_sstream_from_string_view
733 template <
typename _Tp>
737 requires (is_convertible_v<
const _Tp&,
738 basic_string_view<_CharT, _Traits>>)
742 template <
typename _Tp>
744 requires (is_convertible_v<
const _Tp&,
745 basic_string_view<_CharT, _Traits>>)
749 template <
typename _Tp>
751 const allocator_type& __a)
752 requires (is_convertible_v<
const _Tp&,
753 basic_string_view<_CharT, _Traits>>)
754 : __istream_type(), _M_stringbuf(__t, __mode | ios_base::
in, __a)
766 __istream_type::operator=(
std::move(__rhs));
767 _M_stringbuf =
std::move(__rhs._M_stringbuf);
774 __istream_type::swap(__rhs);
775 _M_stringbuf.swap(__rhs._M_stringbuf);
797 str() const _GLIBCXX_LVAL_REF_QUAL
798 {
return _M_stringbuf.str(); }
800#if __cplusplus > 201703L
801#if _GLIBCXX_USE_CXX11_ABI
804 template<__allocator_like _SAlloc>
807 str(
const _SAlloc& __sa)
const
808 {
return _M_stringbuf.str(__sa); }
814 {
return std::move(_M_stringbuf).str(); }
817 _GLIBCXX_SSTREAM_ALWAYS_INLINE
818 basic_string_view<char_type, traits_type>
819 view() const noexcept
820 {
return _M_stringbuf.view(); }
830 str(
const __string_type& __s)
831 { _M_stringbuf.str(__s); }
833#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
836 template<__allocator_like _SAlloc>
837 requires (!is_same_v<_SAlloc, _Alloc>)
840 { _M_stringbuf.str(__s); }
844 str(__string_type&& __s)
848#ifdef __cpp_lib_sstream_from_string_view
849 template<
typename _Tp>
852 requires (is_convertible_v<
const _Tp&,
853 basic_string_view<_CharT, _Traits>>)
854 { _M_stringbuf.str(__t); }
874 template <
typename _CharT,
typename _Traits,
typename _Alloc>
879 typedef _CharT char_type;
880 typedef _Traits traits_type;
883 typedef _Alloc allocator_type;
884 typedef typename traits_type::int_type int_type;
885 typedef typename traits_type::pos_type pos_type;
886 typedef typename traits_type::off_type off_type;
894 __stringbuf_type _M_stringbuf;
926 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
945 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
957#if __cplusplus >= 201103L
961 : __ostream_type(
std::
move(__rhs)),
962 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
965#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
968 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
974 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
977 template<
typename _SAlloc>
979 const allocator_type& __a)
983 template<
typename _SAlloc>
986 const allocator_type& __a)
987 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
990 template<
typename _SAlloc>
998#ifdef __cpp_lib_sstream_from_string_view
999 template <
typename _Tp>
1003 requires (is_convertible_v<
const _Tp&,
1004 basic_string_view<_CharT, _Traits>>)
1008 template <
typename _Tp>
1010 requires (is_convertible_v<
const _Tp&,
1011 basic_string_view<_CharT, _Traits>>)
1015 template <
typename _Tp>
1017 const allocator_type& __a)
1018 requires (is_convertible_v<
const _Tp&,
1019 basic_string_view<_CharT, _Traits>>)
1020 : __ostream_type(), _M_stringbuf(__t, __mode | ios_base::
out, __a)
1032 __ostream_type::operator=(
std::move(__rhs));
1033 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1040 __ostream_type::swap(__rhs);
1041 _M_stringbuf.swap(__rhs._M_stringbuf);
1063 str() const _GLIBCXX_LVAL_REF_QUAL
1064 {
return _M_stringbuf.str(); }
1066#if __cplusplus > 201703L
1067#if _GLIBCXX_USE_CXX11_ABI
1070 template<__allocator_like _SAlloc>
1073 str(
const _SAlloc& __sa)
const
1074 {
return _M_stringbuf.str(__sa); }
1080 {
return std::move(_M_stringbuf).str(); }
1083 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1084 basic_string_view<char_type, traits_type>
1085 view() const noexcept
1086 {
return _M_stringbuf.view(); }
1097 { _M_stringbuf.str(__s); }
1099#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1102 template<__allocator_like _SAlloc>
1103 requires (!is_same_v<_SAlloc, _Alloc>)
1106 { _M_stringbuf.str(__s); }
1110 str(__string_type&& __s)
1114#ifdef __cpp_lib_sstream_from_string_view
1115 template<
typename _Tp>
1118 requires (is_convertible_v<
const _Tp&,
1119 basic_string_view<_CharT, _Traits>>)
1120 { _M_stringbuf.str(__t); }
1140 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1145 typedef _CharT char_type;
1146 typedef _Traits traits_type;
1149 typedef _Alloc allocator_type;
1150 typedef typename traits_type::int_type int_type;
1151 typedef typename traits_type::pos_type pos_type;
1152 typedef typename traits_type::off_type off_type;
1160 __stringbuf_type _M_stringbuf;
1190 : __iostream_type(), _M_stringbuf(__m)
1207 : __iostream_type(), _M_stringbuf(__str, __m)
1219#if __cplusplus >= 201103L
1223 : __iostream_type(
std::
move(__rhs)),
1224 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1227#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1230 : __iostream_type(), _M_stringbuf(__mode, __a)
1237 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1240 template<
typename _SAlloc>
1242 const allocator_type& __a)
1246 template<
typename _SAlloc>
1249 const allocator_type& __a)
1250 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1253 template<
typename _SAlloc>
1262#ifdef __cpp_lib_sstream_from_string_view
1263 template <
typename _Tp>
1267 requires (is_convertible_v<
const _Tp&,
1268 basic_string_view<_CharT, _Traits>>)
1272 template <
typename _Tp>
1274 requires (is_convertible_v<
const _Tp&,
1275 basic_string_view<_CharT, _Traits>>)
1279 template <
typename _Tp>
1281 const allocator_type& __a)
1282 requires (is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>)
1283 : __iostream_type(), _M_stringbuf(__t, __mode, __a)
1295 __iostream_type::operator=(
std::move(__rhs));
1296 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1303 __iostream_type::swap(__rhs);
1304 _M_stringbuf.swap(__rhs._M_stringbuf);
1326 str() const _GLIBCXX_LVAL_REF_QUAL
1327 {
return _M_stringbuf.str(); }
1329#if __cplusplus > 201703L
1330#if _GLIBCXX_USE_CXX11_ABI
1333 template<__allocator_like _SAlloc>
1336 str(
const _SAlloc& __sa)
const
1337 {
return _M_stringbuf.str(__sa); }
1343 {
return std::move(_M_stringbuf).str(); }
1346 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1347 basic_string_view<char_type, traits_type>
1348 view() const noexcept
1349 {
return _M_stringbuf.view(); }
1360 { _M_stringbuf.str(__s); }
1362#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1365 template<__allocator_like _SAlloc>
1366 requires (!is_same_v<_SAlloc, _Alloc>)
1369 { _M_stringbuf.str(__s); }
1373 str(__string_type&& __s)
1377#ifdef __cpp_lib_sstream_from_string_view
1378 template<
typename _Tp>
1381 requires (is_convertible_v<
const _Tp&,
1382 basic_string_view<_CharT, _Traits>>)
1383 { _M_stringbuf.str(__t); }
1387#if __cplusplus >= 201103L
1389 template <
class _CharT,
class _Traits,
class _Allocator>
1393 noexcept(
noexcept(__x.swap(__y)))
1397 template <
class _CharT,
class _Traits,
class _Allocator>
1404 template <
class _CharT,
class _Traits,
class _Allocator>
1411 template <
class _CharT,
class _Traits,
class _Allocator>
1418_GLIBCXX_END_NAMESPACE_CXX11
1419_GLIBCXX_END_NAMESPACE_VERSION
1422#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1423#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)
basic_istream(__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.
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.
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.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
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.
basic_ostream(__streambuf_type *__sb)
Base constructor.