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())
318 if (_M_string.data() == this->pbase()) [[likely]]
320 _M_string._M_set_length(__hi - this->
pbase());
322 _M_string.assign(this->
pbase(), __hi);
326 _M_sync(_M_string.data(), 0, 0);
331 _GLIBCXX_SSTREAM_ALWAYS_INLINE
332 basic_string_view<char_type, traits_type>
333 view() const noexcept
335 if (char_type* __hi = _M_high_mark())
336 return { this->
pbase(), __hi };
350 str(
const __string_type& __s)
358#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
361 template<__allocator_like _SAlloc>
362 requires (!is_same_v<_SAlloc, _Alloc>)
372 str(__string_type&& __s)
379#ifdef __cpp_lib_sstream_from_string_view
380 template <
typename _Tp>
383 requires (is_convertible_v<
const _Tp&,
384 basic_string_view<_CharT, _Traits>>)
386 basic_string_view<_CharT, _Traits> __sv{__t};
398 __size_type __len = 0;
400 __len = _M_string.size();
401 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
420 pbackfail(int_type __c = traits_type::eof());
423 overflow(int_type __c = traits_type::eof());
436 virtual __streambuf_type*
450 _M_sync(__s, __n, 0);
467 _M_sync(char_type* __base, __size_type __i, __size_type __o);
474 if (char_type* __pptr = this->
pptr())
476 char_type* __egptr = this->
egptr();
477 if (!__egptr || __pptr > __egptr)
482 this->
setg(__pptr, __pptr, __pptr);
490 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
497 __attribute__((__always_inline__))
499 _M_high_mark() const _GLIBCXX_NOEXCEPT
501 if (char_type* __pptr = this->
pptr())
503 char_type* __egptr = this->
egptr();
504 if (!__egptr || __pptr > __egptr)
512#if __cplusplus >= 201103L
513#if _GLIBCXX_USE_CXX11_ABI
516 struct __xfer_bufptrs
519 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
521 const _CharT*
const __str = __from._M_string.data();
522 const _CharT* __end =
nullptr;
525 _M_goff[0] = __from.eback() - __str;
526 _M_goff[1] = __from.gptr() - __str;
527 _M_goff[2] = __from.egptr() - __str;
528 __end = __from.egptr();
532 _M_poff[0] = __from.pbase() - __str;
533 _M_poff[1] = __from.pptr() - __from.pbase();
534 _M_poff[2] = __from.epptr() - __str;
535 if (!__end || __from.pptr() > __end)
536 __end = __from.pptr();
545 __mut_from._M_string._M_length(__end - __str);
552 if (_M_goff[0] != -1)
553 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
554 if (_M_poff[0] != -1)
555 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
564 struct __xfer_bufptrs
573 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
577#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
584 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
607 template<
typename _CharT,
typename _Traits,
typename _Alloc>
612 typedef _CharT char_type;
613 typedef _Traits traits_type;
616 typedef _Alloc allocator_type;
617 typedef typename traits_type::int_type int_type;
618 typedef typename traits_type::pos_type pos_type;
619 typedef typename traits_type::off_type off_type;
627 __stringbuf_type _M_stringbuf;
642 : __istream_type(), _M_stringbuf(
ios_base::
in)
659 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
678 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
690#if __cplusplus >= 201103L
694 : __istream_type(
std::
move(__rhs)),
695 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
698#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
701 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
707 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
710 template<
typename _SAlloc>
712 const allocator_type& __a)
716 template<
typename _SAlloc>
719 const allocator_type& __a)
720 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
723 template<
typename _SAlloc>
731#ifdef __cpp_lib_sstream_from_string_view
732 template <
typename _Tp>
736 requires (is_convertible_v<
const _Tp&,
737 basic_string_view<_CharT, _Traits>>)
741 template <
typename _Tp>
743 requires (is_convertible_v<
const _Tp&,
744 basic_string_view<_CharT, _Traits>>)
748 template <
typename _Tp>
750 const allocator_type& __a)
751 requires (is_convertible_v<
const _Tp&,
752 basic_string_view<_CharT, _Traits>>)
753 : __istream_type(), _M_stringbuf(__t, __mode | ios_base::
in, __a)
765 __istream_type::operator=(
std::move(__rhs));
766 _M_stringbuf =
std::move(__rhs._M_stringbuf);
773 __istream_type::swap(__rhs);
774 _M_stringbuf.swap(__rhs._M_stringbuf);
796 str() const _GLIBCXX_LVAL_REF_QUAL
797 {
return _M_stringbuf.str(); }
799#if __cplusplus > 201703L
800#if _GLIBCXX_USE_CXX11_ABI
803 template<__allocator_like _SAlloc>
806 str(
const _SAlloc& __sa)
const
807 {
return _M_stringbuf.str(__sa); }
813 {
return std::move(_M_stringbuf).str(); }
816 _GLIBCXX_SSTREAM_ALWAYS_INLINE
817 basic_string_view<char_type, traits_type>
818 view() const noexcept
819 {
return _M_stringbuf.view(); }
829 str(
const __string_type& __s)
830 { _M_stringbuf.str(__s); }
832#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
835 template<__allocator_like _SAlloc>
836 requires (!is_same_v<_SAlloc, _Alloc>)
839 { _M_stringbuf.str(__s); }
843 str(__string_type&& __s)
847#ifdef __cpp_lib_sstream_from_string_view
848 template<
typename _Tp>
851 requires (is_convertible_v<
const _Tp&,
852 basic_string_view<_CharT, _Traits>>)
853 { _M_stringbuf.str(__t); }
873 template <
typename _CharT,
typename _Traits,
typename _Alloc>
878 typedef _CharT char_type;
879 typedef _Traits traits_type;
882 typedef _Alloc allocator_type;
883 typedef typename traits_type::int_type int_type;
884 typedef typename traits_type::pos_type pos_type;
885 typedef typename traits_type::off_type off_type;
893 __stringbuf_type _M_stringbuf;
925 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
944 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
956#if __cplusplus >= 201103L
960 : __ostream_type(
std::
move(__rhs)),
961 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
964#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
967 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
973 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
976 template<
typename _SAlloc>
978 const allocator_type& __a)
982 template<
typename _SAlloc>
985 const allocator_type& __a)
986 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
989 template<
typename _SAlloc>
997#ifdef __cpp_lib_sstream_from_string_view
998 template <
typename _Tp>
1002 requires (is_convertible_v<
const _Tp&,
1003 basic_string_view<_CharT, _Traits>>)
1007 template <
typename _Tp>
1009 requires (is_convertible_v<
const _Tp&,
1010 basic_string_view<_CharT, _Traits>>)
1014 template <
typename _Tp>
1016 const allocator_type& __a)
1017 requires (is_convertible_v<
const _Tp&,
1018 basic_string_view<_CharT, _Traits>>)
1019 : __ostream_type(), _M_stringbuf(__t, __mode | ios_base::
out, __a)
1031 __ostream_type::operator=(
std::move(__rhs));
1032 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1039 __ostream_type::swap(__rhs);
1040 _M_stringbuf.swap(__rhs._M_stringbuf);
1062 str() const _GLIBCXX_LVAL_REF_QUAL
1063 {
return _M_stringbuf.str(); }
1065#if __cplusplus > 201703L
1066#if _GLIBCXX_USE_CXX11_ABI
1069 template<__allocator_like _SAlloc>
1072 str(
const _SAlloc& __sa)
const
1073 {
return _M_stringbuf.str(__sa); }
1079 {
return std::move(_M_stringbuf).str(); }
1082 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1083 basic_string_view<char_type, traits_type>
1084 view() const noexcept
1085 {
return _M_stringbuf.view(); }
1096 { _M_stringbuf.str(__s); }
1098#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1101 template<__allocator_like _SAlloc>
1102 requires (!is_same_v<_SAlloc, _Alloc>)
1105 { _M_stringbuf.str(__s); }
1109 str(__string_type&& __s)
1113#ifdef __cpp_lib_sstream_from_string_view
1114 template<
typename _Tp>
1117 requires (is_convertible_v<
const _Tp&,
1118 basic_string_view<_CharT, _Traits>>)
1119 { _M_stringbuf.str(__t); }
1139 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1144 typedef _CharT char_type;
1145 typedef _Traits traits_type;
1148 typedef _Alloc allocator_type;
1149 typedef typename traits_type::int_type int_type;
1150 typedef typename traits_type::pos_type pos_type;
1151 typedef typename traits_type::off_type off_type;
1159 __stringbuf_type _M_stringbuf;
1189 : __iostream_type(), _M_stringbuf(__m)
1206 : __iostream_type(), _M_stringbuf(__str, __m)
1218#if __cplusplus >= 201103L
1222 : __iostream_type(
std::
move(__rhs)),
1223 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1226#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1229 : __iostream_type(), _M_stringbuf(__mode, __a)
1236 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1239 template<
typename _SAlloc>
1241 const allocator_type& __a)
1245 template<
typename _SAlloc>
1248 const allocator_type& __a)
1249 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1252 template<
typename _SAlloc>
1261#ifdef __cpp_lib_sstream_from_string_view
1262 template <
typename _Tp>
1266 requires (is_convertible_v<
const _Tp&,
1267 basic_string_view<_CharT, _Traits>>)
1271 template <
typename _Tp>
1273 requires (is_convertible_v<
const _Tp&,
1274 basic_string_view<_CharT, _Traits>>)
1278 template <
typename _Tp>
1280 const allocator_type& __a)
1281 requires (is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>)
1282 : __iostream_type(), _M_stringbuf(__t, __mode, __a)
1294 __iostream_type::operator=(
std::move(__rhs));
1295 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1302 __iostream_type::swap(__rhs);
1303 _M_stringbuf.swap(__rhs._M_stringbuf);
1325 str() const _GLIBCXX_LVAL_REF_QUAL
1326 {
return _M_stringbuf.str(); }
1328#if __cplusplus > 201703L
1329#if _GLIBCXX_USE_CXX11_ABI
1332 template<__allocator_like _SAlloc>
1335 str(
const _SAlloc& __sa)
const
1336 {
return _M_stringbuf.str(__sa); }
1342 {
return std::move(_M_stringbuf).str(); }
1345 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1346 basic_string_view<char_type, traits_type>
1347 view() const noexcept
1348 {
return _M_stringbuf.view(); }
1359 { _M_stringbuf.str(__s); }
1361#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1364 template<__allocator_like _SAlloc>
1365 requires (!is_same_v<_SAlloc, _Alloc>)
1368 { _M_stringbuf.str(__s); }
1372 str(__string_type&& __s)
1376#ifdef __cpp_lib_sstream_from_string_view
1377 template<
typename _Tp>
1380 requires (is_convertible_v<
const _Tp&,
1381 basic_string_view<_CharT, _Traits>>)
1382 { _M_stringbuf.str(__t); }
1386#if __cplusplus >= 201103L
1388 template <
class _CharT,
class _Traits,
class _Allocator>
1392 noexcept(
noexcept(__x.swap(__y)))
1396 template <
class _CharT,
class _Traits,
class _Allocator>
1403 template <
class _CharT,
class _Traits,
class _Allocator>
1410 template <
class _CharT,
class _Traits,
class _Allocator>
1417_GLIBCXX_END_NAMESPACE_CXX11
1418_GLIBCXX_END_NAMESPACE_VERSION
1421#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1422#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.