Warning, /include/c++/v1/__cxx03/sstream is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP___CXX03_SSTREAM
0011 #define _LIBCPP___CXX03_SSTREAM
0012
0013 // clang-format off
0014
0015 /*
0016 sstream synopsis [sstream.syn]
0017
0018 // Class template basic_stringbuf [stringbuf]
0019 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
0020 class basic_stringbuf
0021 : public basic_streambuf<charT, traits>
0022 {
0023 public:
0024 typedef charT char_type;
0025 typedef traits traits_type;
0026 typedef typename traits_type::int_type int_type;
0027 typedef typename traits_type::pos_type pos_type;
0028 typedef typename traits_type::off_type off_type;
0029 typedef Allocator allocator_type;
0030
0031 // [stringbuf.cons] constructors:
0032 explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
0033 basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
0034 explicit basic_stringbuf(ios_base::openmode which); // C++20
0035 explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& s,
0036 ios_base::openmode which = ios_base::in | ios_base::out);
0037 explicit basic_stringbuf(const allocator_type& a)
0038 : basic_stringbuf(ios_base::in | ios_base::out, a) {} // C++20
0039 basic_stringbuf(ios_base::openmode which, const allocator_type& a); // C++20
0040 explicit basic_stringbuf(basic_string<char_type, traits_type, allocator_type>&& s,
0041 ios_base::openmode which = ios_base::in | ios_base::out); // C++20
0042 template <class SAlloc>
0043 basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s, const allocator_type& a)
0044 : basic_stringbuf(s, ios_base::in | ios_base::out, a) {} // C++20
0045 template <class SAlloc>
0046 basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
0047 ios_base::openmode which, const allocator_type& a); // C++20
0048 template <class SAlloc>
0049 explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
0050 ios_base::openmode which = ios_base::in | ios_base::out); // C++20
0051 template<class T>
0052 explicit basic_stringbuf(const T& t,
0053 ios_base::openmode which = ios_base::in | ios_base::out); // Since C++26
0054 template<class T>
0055 basic_stringbuf(const T& t, const Allocator& a); // Since C++26
0056 template<class T>
0057 basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
0058 basic_stringbuf(const basic_stringbuf&) = delete;
0059 basic_stringbuf(basic_stringbuf&& rhs);
0060 basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20
0061
0062 // [stringbuf.assign] Assign and swap:
0063 basic_stringbuf& operator=(const basic_stringbuf&) = delete;
0064 basic_stringbuf& operator=(basic_stringbuf&& rhs);
0065 void swap(basic_stringbuf& rhs) noexcept(see below); // conditionally noexcept since C++20
0066
0067 // [stringbuf.members] Member functions:
0068 allocator_type get_allocator() const noexcept; // C++20
0069 basic_string<char_type, traits_type, allocator_type> str() const; // before C++20
0070 basic_string<char_type, traits_type, allocator_type> str() const &; // C++20
0071 template <class SAlloc>
0072 basic_string<char_type, traits_type, SAlloc> str(const SAlloc& sa) const; // C++20
0073 basic_string<char_type, traits_type, allocator_type> str() &&; // C++20
0074 basic_string_view<char_type, traits_type> view() const noexcept; // C++20
0075 void str(const basic_string<char_type, traits_type, allocator_type>& s);
0076 template <class SAlloc>
0077 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
0078 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
0079 template<class T>
0080 void str(const T& t); // Since C++26
0081
0082 protected:
0083 // [stringbuf.virtuals] Overridden virtual functions:
0084 virtual int_type underflow();
0085 virtual int_type pbackfail(int_type c = traits_type::eof());
0086 virtual int_type overflow (int_type c = traits_type::eof());
0087 virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
0088 virtual pos_type seekoff(off_type off, ios_base::seekdir way,
0089 ios_base::openmode which = ios_base::in | ios_base::out);
0090 virtual pos_type seekpos(pos_type sp,
0091 ios_base::openmode which = ios_base::in | ios_base::out);
0092 };
0093
0094 // [stringbuf.assign] non member swap
0095 template <class charT, class traits, class Allocator>
0096 void swap(basic_stringbuf<charT, traits, Allocator>& x,
0097 basic_stringbuf<charT, traits, Allocator>& y); // conditionally noexcept since C++20
0098
0099 typedef basic_stringbuf<char> stringbuf;
0100 typedef basic_stringbuf<wchar_t> wstringbuf;
0101
0102 // Class template basic_istringstream [istringstream]
0103 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
0104 class basic_istringstream
0105 : public basic_istream<charT, traits>
0106 {
0107 public:
0108 typedef charT char_type;
0109 typedef traits traits_type;
0110 typedef typename traits_type::int_type int_type;
0111 typedef typename traits_type::pos_type pos_type;
0112 typedef typename traits_type::off_type off_type;
0113 typedef Allocator allocator_type;
0114
0115 // [istringstream.cons] Constructors:
0116 explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
0117 basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
0118 explicit basic_istringstream(ios_base::openmode which); // C++20
0119 explicit basic_istringstream(const basic_string<char_type, traits_type, allocator_type>& s,
0120 ios_base::openmode which = ios_base::in);
0121 basic_istringstream(ios_base::openmode which, const allocator_type& a); // C++20
0122 explicit basic_istringstream(basic_string<char_type, traits_type, allocator_type>&& s,
0123 ios_base::openmode which = ios_base::in); // C++20
0124 template <class SAlloc>
0125 basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, const allocator_type& a)
0126 : basic_istringstream(s, ios_base::in, a) {} // C++20
0127 template <class SAlloc>
0128 basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0129 ios_base::openmode which, const allocator_type& a); // C++20
0130 template <class SAlloc>
0131 explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0132 ios_base::openmode which = ios_base::in); // C++20
0133 template<class T>
0134 explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in); // Since C++26
0135 template<class T>
0136 basic_istringstream(const T& t, const Allocator& a); // Since C++26
0137 template<class T>
0138 basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
0139 basic_istringstream(const basic_istringstream&) = delete;
0140 basic_istringstream(basic_istringstream&& rhs);
0141
0142 // [istringstream.assign] Assign and swap:
0143 basic_istringstream& operator=(const basic_istringstream&) = delete;
0144 basic_istringstream& operator=(basic_istringstream&& rhs);
0145 void swap(basic_istringstream& rhs);
0146
0147 // [istringstream.members] Member functions:
0148 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
0149 basic_string<char_type, traits_type, allocator_type> str() const; // before C++20
0150 basic_string<char_type, traits_type, allocator_type> str() const &; // C++20
0151 template <class SAlloc>
0152 basic_string<char_type, traits_type, SAlloc> str(const SAlloc& sa) const; // C++20
0153 basic_string<char_type, traits_type, allocator_type> str() &&; // C++20
0154 basic_string_view<char_type, traits_type> view() const noexcept; // C++20
0155 void str(const basic_string<char_type, traits_type, allocator_type>& s);
0156 template <class SAlloc>
0157 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
0158 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
0159 template<class T>
0160 void str(const T& t); // Since C++26
0161 };
0162
0163 template <class charT, class traits, class Allocator>
0164 void swap(basic_istringstream<charT, traits, Allocator>& x,
0165 basic_istringstream<charT, traits, Allocator>& y);
0166
0167 typedef basic_istringstream<char> istringstream;
0168 typedef basic_istringstream<wchar_t> wistringstream;
0169
0170 // Class template basic_ostringstream [ostringstream]
0171 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
0172 class basic_ostringstream
0173 : public basic_ostream<charT, traits>
0174 {
0175 public:
0176 // types:
0177 typedef charT char_type;
0178 typedef traits traits_type;
0179 typedef typename traits_type::int_type int_type;
0180 typedef typename traits_type::pos_type pos_type;
0181 typedef typename traits_type::off_type off_type;
0182 typedef Allocator allocator_type;
0183
0184 // [ostringstream.cons] Constructors:
0185 explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
0186 basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
0187 explicit basic_ostringstream(ios_base::openmode which); // C++20
0188 explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& s,
0189 ios_base::openmode which = ios_base::out);
0190 basic_ostringstream(ios_base::openmode which, const allocator_type& a); // C++20
0191 explicit basic_ostringstream(basic_string<char_type, traits_type, allocator_type>&& s,
0192 ios_base::openmode which = ios_base::out); // C++20
0193 template <class SAlloc>
0194 basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s, const allocator_type& a)
0195 : basic_ostringstream(s, ios_base::out, a) {} // C++20
0196 template <class SAlloc>
0197 basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0198 ios_base::openmode which, const allocator_type& a); // C++20
0199 template <class SAlloc>
0200 explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0201 ios_base::openmode which = ios_base::out); // C++20
0202 template<class T>
0203 explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); // Since C++26
0204 template<class T>
0205 basic_ostringstream(const T& t, const Allocator& a); // Since C++26
0206 template<class T>
0207 basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
0208 basic_ostringstream(const basic_ostringstream&) = delete;
0209 basic_ostringstream(basic_ostringstream&& rhs);
0210
0211 // [ostringstream.assign] Assign and swap:
0212 basic_ostringstream& operator=(const basic_ostringstream&) = delete;
0213 basic_ostringstream& operator=(basic_ostringstream&& rhs);
0214 void swap(basic_ostringstream& rhs);
0215
0216 // [ostringstream.members] Member functions:
0217 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
0218 basic_string<char_type, traits_type, allocator_type> str() const; // before C++20
0219 basic_string<char_type, traits_type, allocator_type> str() const &; // C++20
0220 template <class SAlloc>
0221 basic_string<char_type, traits_type, SAlloc> str(const SAlloc& sa) const; // C++20
0222 basic_string<char_type, traits_type, allocator_type> str() &&; // C++20
0223 basic_string_view<char_type, traits_type> view() const noexcept; // C++20
0224 void str(const basic_string<char_type, traits_type, allocator_type>& s);
0225 template <class SAlloc>
0226 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
0227 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
0228 template<class T>
0229 void str(const T& t); // Since C++26
0230 };
0231
0232 template <class charT, class traits, class Allocator>
0233 void swap(basic_ostringstream<charT, traits, Allocator>& x,
0234 basic_ostringstream<charT, traits, Allocator>& y);
0235
0236 typedef basic_ostringstream<char> ostringstream;
0237 typedef basic_ostringstream<wchar_t> wostringstream;
0238
0239 // Class template basic_stringstream [stringstream]
0240 template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
0241 class basic_stringstream
0242 : public basic_iostream<charT, traits>
0243 {
0244 public:
0245 // types:
0246 typedef charT char_type;
0247 typedef traits traits_type;
0248 typedef typename traits_type::int_type int_type;
0249 typedef typename traits_type::pos_type pos_type;
0250 typedef typename traits_type::off_type off_type;
0251 typedef Allocator allocator_type;
0252
0253 // [stringstream.cons] constructors
0254 explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
0255 basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
0256 explicit basic_stringstream(ios_base::openmode which); // C++20
0257 explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& s,
0258 ios_base::openmode which = ios_base::out | ios_base::in);
0259 basic_stringstream(ios_base::openmode which, const allocator_type& a); // C++20
0260 explicit basic_stringstream(basic_string<char_type, traits_type, allocator_type>&& s,
0261 ios_base::openmode which = ios_base::out | ios_base::in); // C++20
0262 template <class SAlloc>
0263 basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s, const allocator_type& a)
0264 : basic_stringstream(s, ios_base::out | ios_base::in, a) {} // C++20
0265 template <class SAlloc>
0266 basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0267 ios_base::openmode which, const allocator_type& a); // C++20
0268 template <class SAlloc>
0269 explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
0270 ios_base::openmode which = ios_base::out | ios_base::in); // C++20
0271 template<class T>
0272 explicit basic_stringstream(const T& t,
0273 ios_base::openmode which = ios_base::out | ios_base::in); // Since C++26
0274 template<class T>
0275 basic_stringstream(const T& t, const Allocator& a); // Since C++26
0276 template<class T>
0277 basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
0278 basic_stringstream(const basic_stringstream&) = delete;
0279 basic_stringstream(basic_stringstream&& rhs);
0280
0281 // [stringstream.assign] Assign and swap:
0282 basic_stringstream& operator=(const basic_stringstream&) = delete;
0283 basic_stringstream& operator=(basic_stringstream&& rhs);
0284 void swap(basic_stringstream& rhs);
0285
0286 // [stringstream.members] Member functions:
0287 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
0288 basic_string<char_type, traits_type, allocator_type> str() const; // before C++20
0289 basic_string<char_type, traits_type, allocator_type> str() const &; // C++20
0290 template <class SAlloc>
0291 basic_string<char_type, traits_type, SAlloc> str(const SAlloc& sa) const; // C++20
0292 basic_string<char_type, traits_type, allocator_type> str() &&; // C++20
0293 basic_string_view<char_type, traits_type> view() const noexcept; // C++20
0294 void str(const basic_string<char_type, traits_type, allocator_type>& s);
0295 template <class SAlloc>
0296 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
0297 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
0298 template<class T>
0299 void str(const T& t); // Since C++26
0300 };
0301
0302 template <class charT, class traits, class Allocator>
0303 void swap(basic_stringstream<charT, traits, Allocator>& x,
0304 basic_stringstream<charT, traits, Allocator>& y);
0305
0306 typedef basic_stringstream<char> stringstream;
0307 typedef basic_stringstream<wchar_t> wstringstream;
0308
0309 } // std
0310
0311 */
0312
0313 // clang-format on
0314
0315 #include <__cxx03/__config>
0316 #include <__cxx03/__fwd/sstream.h>
0317 #include <__cxx03/__ostream/basic_ostream.h>
0318 #include <__cxx03/__type_traits/is_convertible.h>
0319 #include <__cxx03/__utility/swap.h>
0320 #include <__cxx03/istream>
0321 #include <__cxx03/string>
0322 #include <__cxx03/string_view>
0323 #include <__cxx03/version>
0324
0325 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0326 # pragma GCC system_header
0327 #endif
0328
0329 _LIBCPP_PUSH_MACROS
0330 #include <__cxx03/__undef_macros>
0331
0332 _LIBCPP_BEGIN_NAMESPACE_STD
0333
0334 // Class template basic_stringbuf [stringbuf]
0335
0336 template <class _CharT, class _Traits, class _Allocator>
0337 class _LIBCPP_TEMPLATE_VIS basic_stringbuf : public basic_streambuf<_CharT, _Traits> {
0338 public:
0339 typedef _CharT char_type;
0340 typedef _Traits traits_type;
0341 typedef typename traits_type::int_type int_type;
0342 typedef typename traits_type::pos_type pos_type;
0343 typedef typename traits_type::off_type off_type;
0344 typedef _Allocator allocator_type;
0345
0346 typedef basic_string<char_type, traits_type, allocator_type> string_type;
0347
0348 private:
0349 string_type __str_;
0350 mutable char_type* __hm_;
0351 ios_base::openmode __mode_;
0352 _LIBCPP_HIDE_FROM_ABI void __init_buf_ptrs();
0353 _LIBCPP_HIDE_FROM_ABI void __move_init(basic_stringbuf&& __rhs);
0354
0355 public:
0356 // [stringbuf.cons] constructors:
0357 _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
0358
0359 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) {}
0360
0361 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const string_type& __s,
0362 ios_base::openmode __wch = ios_base::in | ios_base::out)
0363 : __str_(__s.get_allocator()), __hm_(nullptr), __mode_(__wch) {
0364 str(__s);
0365 }
0366
0367 #if _LIBCPP_STD_VER >= 20
0368 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a)
0369 : basic_stringbuf(ios_base::in | ios_base::out, __a) {}
0370
0371 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(ios_base::openmode __wch, const allocator_type& __a)
0372 : __str_(__a), __hm_(nullptr), __mode_(__wch) {}
0373
0374 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(string_type&& __s,
0375 ios_base::openmode __wch = ios_base::in | ios_base::out)
0376 : __str_(std::move(__s)), __hm_(nullptr), __mode_(__wch) {
0377 __init_buf_ptrs();
0378 }
0379
0380 template <class _SAlloc>
0381 _LIBCPP_HIDE_FROM_ABI
0382 basic_stringbuf(const basic_string<char_type, traits_type, _SAlloc>& __s, const allocator_type& __a)
0383 : basic_stringbuf(__s, ios_base::in | ios_base::out, __a) {}
0384
0385 template <class _SAlloc>
0386 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(
0387 const basic_string<char_type, traits_type, _SAlloc>& __s, ios_base::openmode __wch, const allocator_type& __a)
0388 : __str_(__s, __a), __hm_(nullptr), __mode_(__wch) {
0389 __init_buf_ptrs();
0390 }
0391
0392 template <class _SAlloc>
0393 requires(!is_same_v<_SAlloc, allocator_type>)
0394 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const basic_string<char_type, traits_type, _SAlloc>& __s,
0395 ios_base::openmode __wch = ios_base::in | ios_base::out)
0396 : __str_(__s), __hm_(nullptr), __mode_(__wch) {
0397 __init_buf_ptrs();
0398 }
0399 #endif // _LIBCPP_STD_VER >= 20
0400
0401 #if _LIBCPP_STD_VER >= 26
0402
0403 template <class _Tp>
0404 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0405 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const _Tp& __t,
0406 ios_base::openmode __which = ios_base::in | ios_base::out)
0407 : basic_stringbuf(__t, __which, _Allocator()) {}
0408
0409 template <class _Tp>
0410 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0411 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, const _Allocator& __a)
0412 : basic_stringbuf(__t, ios_base::in | ios_base::out, __a) {}
0413
0414 template <class _Tp>
0415 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0416 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
0417 : __hm_(nullptr), __mode_(__which) {
0418 basic_string_view<_CharT, _Traits> __sv = __t;
0419 __str_ = string_type(__sv, __a);
0420 __init_buf_ptrs();
0421 }
0422
0423 #endif // _LIBCPP_STD_VER >= 26
0424
0425 basic_stringbuf(const basic_stringbuf&) = delete;
0426 basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
0427
0428 #if _LIBCPP_STD_VER >= 20
0429 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
0430 : basic_stringbuf(__rhs.__mode_, __a) {
0431 __move_init(std::move(__rhs));
0432 }
0433 #endif
0434
0435 // [stringbuf.assign] Assign and swap:
0436 basic_stringbuf& operator=(const basic_stringbuf&) = delete;
0437 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
0438 void swap(basic_stringbuf& __rhs)
0439 #if _LIBCPP_STD_VER >= 20
0440 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
0441 allocator_traits<allocator_type>::is_always_equal::value)
0442 #endif
0443 ;
0444
0445 // [stringbuf.members] Member functions:
0446
0447 #if _LIBCPP_STD_VER >= 20
0448 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); }
0449 #endif
0450
0451 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
0452 string_type str() const;
0453 #else
0454 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); }
0455
0456 _LIBCPP_HIDE_FROM_ABI string_type str() && {
0457 const basic_string_view<_CharT, _Traits> __view = view();
0458 typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data();
0459 // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator());
0460 // But we need something that works in C++20 also.
0461 string_type __result(std::move(__str_), __str_.get_allocator());
0462 __result.resize(__pos + __view.size());
0463 __result.erase(0, __pos);
0464 __init_buf_ptrs();
0465 return __result;
0466 }
0467 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
0468
0469 #if _LIBCPP_STD_VER >= 20
0470 template <class _SAlloc>
0471 requires __is_allocator<_SAlloc>::value
0472 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
0473 return basic_string<_CharT, _Traits, _SAlloc>(view(), __sa);
0474 }
0475
0476 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept;
0477 #endif // _LIBCPP_STD_VER >= 20
0478
0479 void str(const string_type& __s) {
0480 __str_ = __s;
0481 __init_buf_ptrs();
0482 }
0483
0484 #if _LIBCPP_STD_VER >= 20
0485 template <class _SAlloc>
0486 requires(!is_same_v<_SAlloc, allocator_type>)
0487 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
0488 __str_ = __s;
0489 __init_buf_ptrs();
0490 }
0491
0492 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) {
0493 __str_ = std::move(__s);
0494 __init_buf_ptrs();
0495 }
0496 #endif // _LIBCPP_STD_VER >= 20
0497
0498 #if _LIBCPP_STD_VER >= 26
0499
0500 template <class _Tp>
0501 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0502 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
0503 basic_string_view<_CharT, _Traits> __sv = __t;
0504 __str_ = __sv;
0505 __init_buf_ptrs();
0506 }
0507
0508 #endif // _LIBCPP_STD_VER >= 26
0509
0510 protected:
0511 // [stringbuf.virtuals] Overridden virtual functions:
0512 int_type underflow() override;
0513 int_type pbackfail(int_type __c = traits_type::eof()) override;
0514 int_type overflow(int_type __c = traits_type::eof()) override;
0515 pos_type
0516 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out) override;
0517 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
0518 pos_type seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out) override {
0519 return seekoff(__sp, ios_base::beg, __wch);
0520 }
0521 };
0522
0523 template <class _CharT, class _Traits, class _Allocator>
0524 _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__move_init(basic_stringbuf&& __rhs) {
0525 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
0526 ptrdiff_t __binp = -1;
0527 ptrdiff_t __ninp = -1;
0528 ptrdiff_t __einp = -1;
0529 if (__rhs.eback() != nullptr) {
0530 __binp = __rhs.eback() - __p;
0531 __ninp = __rhs.gptr() - __p;
0532 __einp = __rhs.egptr() - __p;
0533 }
0534 ptrdiff_t __bout = -1;
0535 ptrdiff_t __nout = -1;
0536 ptrdiff_t __eout = -1;
0537 if (__rhs.pbase() != nullptr) {
0538 __bout = __rhs.pbase() - __p;
0539 __nout = __rhs.pptr() - __p;
0540 __eout = __rhs.epptr() - __p;
0541 }
0542 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
0543 __str_ = std::move(__rhs.__str_);
0544 __p = const_cast<char_type*>(__str_.data());
0545 if (__binp != -1)
0546 this->setg(__p + __binp, __p + __ninp, __p + __einp);
0547 if (__bout != -1) {
0548 this->setp(__p + __bout, __p + __eout);
0549 this->__pbump(__nout);
0550 }
0551 __hm_ = __hm == -1 ? nullptr : __p + __hm;
0552 __p = const_cast<char_type*>(__rhs.__str_.data());
0553 __rhs.setg(__p, __p, __p);
0554 __rhs.setp(__p, __p);
0555 __rhs.__hm_ = __p;
0556 this->pubimbue(__rhs.getloc());
0557 }
0558
0559 template <class _CharT, class _Traits, class _Allocator>
0560 basic_stringbuf<_CharT, _Traits, _Allocator>&
0561 basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) {
0562 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
0563 ptrdiff_t __binp = -1;
0564 ptrdiff_t __ninp = -1;
0565 ptrdiff_t __einp = -1;
0566 if (__rhs.eback() != nullptr) {
0567 __binp = __rhs.eback() - __p;
0568 __ninp = __rhs.gptr() - __p;
0569 __einp = __rhs.egptr() - __p;
0570 }
0571 ptrdiff_t __bout = -1;
0572 ptrdiff_t __nout = -1;
0573 ptrdiff_t __eout = -1;
0574 if (__rhs.pbase() != nullptr) {
0575 __bout = __rhs.pbase() - __p;
0576 __nout = __rhs.pptr() - __p;
0577 __eout = __rhs.epptr() - __p;
0578 }
0579 ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
0580 __str_ = std::move(__rhs.__str_);
0581 __p = const_cast<char_type*>(__str_.data());
0582 if (__binp != -1)
0583 this->setg(__p + __binp, __p + __ninp, __p + __einp);
0584 else
0585 this->setg(nullptr, nullptr, nullptr);
0586 if (__bout != -1) {
0587 this->setp(__p + __bout, __p + __eout);
0588 this->__pbump(__nout);
0589 } else
0590 this->setp(nullptr, nullptr);
0591
0592 __hm_ = __hm == -1 ? nullptr : __p + __hm;
0593 __mode_ = __rhs.__mode_;
0594 __p = const_cast<char_type*>(__rhs.__str_.data());
0595 __rhs.setg(__p, __p, __p);
0596 __rhs.setp(__p, __p);
0597 __rhs.__hm_ = __p;
0598 this->pubimbue(__rhs.getloc());
0599 return *this;
0600 }
0601
0602 template <class _CharT, class _Traits, class _Allocator>
0603 void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
0604 #if _LIBCPP_STD_VER >= 20
0605 noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value ||
0606 allocator_traits<_Allocator>::is_always_equal::value)
0607 #endif
0608 {
0609 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
0610 ptrdiff_t __rbinp = -1;
0611 ptrdiff_t __rninp = -1;
0612 ptrdiff_t __reinp = -1;
0613 if (__rhs.eback() != nullptr) {
0614 __rbinp = __rhs.eback() - __p;
0615 __rninp = __rhs.gptr() - __p;
0616 __reinp = __rhs.egptr() - __p;
0617 }
0618 ptrdiff_t __rbout = -1;
0619 ptrdiff_t __rnout = -1;
0620 ptrdiff_t __reout = -1;
0621 if (__rhs.pbase() != nullptr) {
0622 __rbout = __rhs.pbase() - __p;
0623 __rnout = __rhs.pptr() - __p;
0624 __reout = __rhs.epptr() - __p;
0625 }
0626 ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
0627 __p = const_cast<char_type*>(__str_.data());
0628 ptrdiff_t __lbinp = -1;
0629 ptrdiff_t __lninp = -1;
0630 ptrdiff_t __leinp = -1;
0631 if (this->eback() != nullptr) {
0632 __lbinp = this->eback() - __p;
0633 __lninp = this->gptr() - __p;
0634 __leinp = this->egptr() - __p;
0635 }
0636 ptrdiff_t __lbout = -1;
0637 ptrdiff_t __lnout = -1;
0638 ptrdiff_t __leout = -1;
0639 if (this->pbase() != nullptr) {
0640 __lbout = this->pbase() - __p;
0641 __lnout = this->pptr() - __p;
0642 __leout = this->epptr() - __p;
0643 }
0644 ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
0645 std::swap(__mode_, __rhs.__mode_);
0646 __str_.swap(__rhs.__str_);
0647 __p = const_cast<char_type*>(__str_.data());
0648 if (__rbinp != -1)
0649 this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
0650 else
0651 this->setg(nullptr, nullptr, nullptr);
0652 if (__rbout != -1) {
0653 this->setp(__p + __rbout, __p + __reout);
0654 this->__pbump(__rnout);
0655 } else
0656 this->setp(nullptr, nullptr);
0657 __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
0658 __p = const_cast<char_type*>(__rhs.__str_.data());
0659 if (__lbinp != -1)
0660 __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
0661 else
0662 __rhs.setg(nullptr, nullptr, nullptr);
0663 if (__lbout != -1) {
0664 __rhs.setp(__p + __lbout, __p + __leout);
0665 __rhs.__pbump(__lnout);
0666 } else
0667 __rhs.setp(nullptr, nullptr);
0668 __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
0669 locale __tl = __rhs.getloc();
0670 __rhs.pubimbue(this->getloc());
0671 this->pubimbue(__tl);
0672 }
0673
0674 template <class _CharT, class _Traits, class _Allocator>
0675 inline _LIBCPP_HIDE_FROM_ABI void
0676 swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
0677 #if _LIBCPP_STD_VER >= 20
0678 noexcept(noexcept(__x.swap(__y)))
0679 #endif
0680 {
0681 __x.swap(__y);
0682 }
0683
0684 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
0685 template <class _CharT, class _Traits, class _Allocator>
0686 basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const {
0687 if (__mode_ & ios_base::out) {
0688 if (__hm_ < this->pptr())
0689 __hm_ = this->pptr();
0690 return string_type(this->pbase(), __hm_, __str_.get_allocator());
0691 } else if (__mode_ & ios_base::in)
0692 return string_type(this->eback(), this->egptr(), __str_.get_allocator());
0693 return string_type(__str_.get_allocator());
0694 }
0695 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
0696
0697 template <class _CharT, class _Traits, class _Allocator>
0698 _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() {
0699 __hm_ = nullptr;
0700 char_type* __data = const_cast<char_type*>(__str_.data());
0701 typename string_type::size_type __sz = __str_.size();
0702 if (__mode_ & ios_base::in) {
0703 __hm_ = __data + __sz;
0704 this->setg(__data, __data, __hm_);
0705 }
0706 if (__mode_ & ios_base::out) {
0707 __hm_ = __data + __sz;
0708 __str_.resize(__str_.capacity());
0709 this->setp(__data, __data + __str_.size());
0710 if (__mode_ & (ios_base::app | ios_base::ate)) {
0711 while (__sz > INT_MAX) {
0712 this->pbump(INT_MAX);
0713 __sz -= INT_MAX;
0714 }
0715 if (__sz > 0)
0716 this->pbump(__sz);
0717 }
0718 }
0719 }
0720
0721 #if _LIBCPP_STD_VER >= 20
0722 template <class _CharT, class _Traits, class _Allocator>
0723 _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits>
0724 basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
0725 if (__mode_ & ios_base::out) {
0726 if (__hm_ < this->pptr())
0727 __hm_ = this->pptr();
0728 return basic_string_view<_CharT, _Traits>(this->pbase(), __hm_);
0729 } else if (__mode_ & ios_base::in)
0730 return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr());
0731 return basic_string_view<_CharT, _Traits>();
0732 }
0733 #endif // _LIBCPP_STD_VER >= 20
0734
0735 template <class _CharT, class _Traits, class _Allocator>
0736 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
0737 basic_stringbuf<_CharT, _Traits, _Allocator>::underflow() {
0738 if (__hm_ < this->pptr())
0739 __hm_ = this->pptr();
0740 if (__mode_ & ios_base::in) {
0741 if (this->egptr() < __hm_)
0742 this->setg(this->eback(), this->gptr(), __hm_);
0743 if (this->gptr() < this->egptr())
0744 return traits_type::to_int_type(*this->gptr());
0745 }
0746 return traits_type::eof();
0747 }
0748
0749 template <class _CharT, class _Traits, class _Allocator>
0750 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
0751 basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c) {
0752 if (__hm_ < this->pptr())
0753 __hm_ = this->pptr();
0754 if (this->eback() < this->gptr()) {
0755 if (traits_type::eq_int_type(__c, traits_type::eof())) {
0756 this->setg(this->eback(), this->gptr() - 1, __hm_);
0757 return traits_type::not_eof(__c);
0758 }
0759 if ((__mode_ & ios_base::out) || traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) {
0760 this->setg(this->eback(), this->gptr() - 1, __hm_);
0761 *this->gptr() = traits_type::to_char_type(__c);
0762 return __c;
0763 }
0764 }
0765 return traits_type::eof();
0766 }
0767
0768 template <class _CharT, class _Traits, class _Allocator>
0769 typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
0770 basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
0771 if (!traits_type::eq_int_type(__c, traits_type::eof())) {
0772 ptrdiff_t __ninp = this->gptr() - this->eback();
0773 if (this->pptr() == this->epptr()) {
0774 if (!(__mode_ & ios_base::out))
0775 return traits_type::eof();
0776 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0777 try {
0778 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
0779 ptrdiff_t __nout = this->pptr() - this->pbase();
0780 ptrdiff_t __hm = __hm_ - this->pbase();
0781 __str_.push_back(char_type());
0782 __str_.resize(__str_.capacity());
0783 char_type* __p = const_cast<char_type*>(__str_.data());
0784 this->setp(__p, __p + __str_.size());
0785 this->__pbump(__nout);
0786 __hm_ = this->pbase() + __hm;
0787 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0788 } catch (...) {
0789 return traits_type::eof();
0790 }
0791 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
0792 }
0793 __hm_ = std::max(this->pptr() + 1, __hm_);
0794 if (__mode_ & ios_base::in) {
0795 char_type* __p = const_cast<char_type*>(__str_.data());
0796 this->setg(__p, __p + __ninp, __hm_);
0797 }
0798 return this->sputc(traits_type::to_char_type(__c));
0799 }
0800 return traits_type::not_eof(__c);
0801 }
0802
0803 template <class _CharT, class _Traits, class _Allocator>
0804 typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(
0805 off_type __off, ios_base::seekdir __way, ios_base::openmode __wch) {
0806 if (__hm_ < this->pptr())
0807 __hm_ = this->pptr();
0808 if ((__wch & (ios_base::in | ios_base::out)) == 0)
0809 return pos_type(-1);
0810 if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) && __way == ios_base::cur)
0811 return pos_type(-1);
0812 const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data();
0813 off_type __noff;
0814 switch (__way) {
0815 case ios_base::beg:
0816 __noff = 0;
0817 break;
0818 case ios_base::cur:
0819 if (__wch & ios_base::in)
0820 __noff = this->gptr() - this->eback();
0821 else
0822 __noff = this->pptr() - this->pbase();
0823 break;
0824 case ios_base::end:
0825 __noff = __hm;
0826 break;
0827 default:
0828 return pos_type(-1);
0829 }
0830 __noff += __off;
0831 if (__noff < 0 || __hm < __noff)
0832 return pos_type(-1);
0833 if (__noff != 0) {
0834 if ((__wch & ios_base::in) && this->gptr() == nullptr)
0835 return pos_type(-1);
0836 if ((__wch & ios_base::out) && this->pptr() == nullptr)
0837 return pos_type(-1);
0838 }
0839 if (__wch & ios_base::in)
0840 this->setg(this->eback(), this->eback() + __noff, __hm_);
0841 if (__wch & ios_base::out) {
0842 this->setp(this->pbase(), this->epptr());
0843 this->__pbump(__noff);
0844 }
0845 return pos_type(__noff);
0846 }
0847
0848 // Class template basic_istringstream [istringstream]
0849
0850 template <class _CharT, class _Traits, class _Allocator>
0851 class _LIBCPP_TEMPLATE_VIS basic_istringstream : public basic_istream<_CharT, _Traits> {
0852 public:
0853 typedef _CharT char_type;
0854 typedef _Traits traits_type;
0855 typedef typename traits_type::int_type int_type;
0856 typedef typename traits_type::pos_type pos_type;
0857 typedef typename traits_type::off_type off_type;
0858 typedef _Allocator allocator_type;
0859
0860 typedef basic_string<char_type, traits_type, allocator_type> string_type;
0861
0862 private:
0863 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
0864
0865 public:
0866 // [istringstream.cons] Constructors:
0867 _LIBCPP_HIDE_FROM_ABI basic_istringstream() : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
0868
0869 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(ios_base::openmode __wch)
0870 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
0871
0872 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in)
0873 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::in) {}
0874
0875 #if _LIBCPP_STD_VER >= 20
0876 _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a)
0877 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {}
0878
0879 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(string_type&& __s, ios_base::openmode __wch = ios_base::in)
0880 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(std::move(__s), __wch | ios_base::in) {}
0881
0882 template <class _SAlloc>
0883 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, const _Allocator& __a)
0884 : basic_istringstream(__s, ios_base::in, __a) {}
0885
0886 template <class _SAlloc>
0887 _LIBCPP_HIDE_FROM_ABI basic_istringstream(
0888 const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch, const _Allocator& __a)
0889 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in, __a) {}
0890
0891 template <class _SAlloc>
0892 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
0893 ios_base::openmode __wch = ios_base::in)
0894 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
0895 #endif // _LIBCPP_STD_VER >= 20
0896
0897 #if _LIBCPP_STD_VER >= 26
0898
0899 template <class _Tp>
0900 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0901 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
0902 : basic_istringstream(__t, __which, _Allocator()) {}
0903
0904 template <class _Tp>
0905 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0906 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, const _Allocator& __a)
0907 : basic_istringstream(__t, ios_base::in, __a) {}
0908
0909 template <class _Tp>
0910 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0911 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
0912 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
0913
0914 #endif // _LIBCPP_STD_VER >= 26
0915
0916 basic_istringstream(const basic_istringstream&) = delete;
0917 _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
0918 : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
0919 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
0920 }
0921
0922 // [istringstream.assign] Assign and swap:
0923 basic_istringstream& operator=(const basic_istringstream&) = delete;
0924 basic_istringstream& operator=(basic_istringstream&& __rhs) {
0925 basic_istream<char_type, traits_type>::operator=(std::move(__rhs));
0926 __sb_ = std::move(__rhs.__sb_);
0927 return *this;
0928 }
0929 _LIBCPP_HIDE_FROM_ABI void swap(basic_istringstream& __rhs) {
0930 basic_istream<char_type, traits_type>::swap(__rhs);
0931 __sb_.swap(__rhs.__sb_);
0932 }
0933
0934 // [istringstream.members] Member functions:
0935 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
0936 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
0937 }
0938
0939 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
0940 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
0941 #else
0942 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
0943
0944 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
0945 #endif
0946
0947 #if _LIBCPP_STD_VER >= 20
0948 template <class _SAlloc>
0949 requires __is_allocator<_SAlloc>::value
0950 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
0951 return __sb_.str(__sa);
0952 }
0953
0954 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
0955 #endif // _LIBCPP_STD_VER >= 20
0956
0957 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
0958
0959 #if _LIBCPP_STD_VER >= 20
0960 template <class _SAlloc>
0961 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
0962 __sb_.str(__s);
0963 }
0964
0965 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
0966 #endif // _LIBCPP_STD_VER >= 20
0967
0968 #if _LIBCPP_STD_VER >= 26
0969 template <class _Tp>
0970 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
0971 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
0972 rdbuf()->str(__t);
0973 }
0974 #endif // _LIBCPP_STD_VER >= 26
0975 };
0976
0977 template <class _CharT, class _Traits, class _Allocator>
0978 inline _LIBCPP_HIDE_FROM_ABI void
0979 swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<_CharT, _Traits, _Allocator>& __y) {
0980 __x.swap(__y);
0981 }
0982
0983 // Class template basic_ostringstream [ostringstream]
0984
0985 template <class _CharT, class _Traits, class _Allocator>
0986 class _LIBCPP_TEMPLATE_VIS basic_ostringstream : public basic_ostream<_CharT, _Traits> {
0987 public:
0988 typedef _CharT char_type;
0989 typedef _Traits traits_type;
0990 typedef typename traits_type::int_type int_type;
0991 typedef typename traits_type::pos_type pos_type;
0992 typedef typename traits_type::off_type off_type;
0993 typedef _Allocator allocator_type;
0994
0995 typedef basic_string<char_type, traits_type, allocator_type> string_type;
0996
0997 private:
0998 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
0999
1000 public:
1001 // [ostringstream.cons] Constructors:
1002 _LIBCPP_HIDE_FROM_ABI basic_ostringstream() : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
1003
1004 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(ios_base::openmode __wch)
1005 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {}
1006
1007 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out)
1008 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::out) {}
1009
1010 #if _LIBCPP_STD_VER >= 20
1011 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a)
1012 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {}
1013
1014 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(string_type&& __s, ios_base::openmode __wch = ios_base::out)
1015 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(std::move(__s), __wch | ios_base::out) {}
1016
1017 template <class _SAlloc>
1018 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, const _Allocator& __a)
1019 : basic_ostringstream(__s, ios_base::out, __a) {}
1020
1021 template <class _SAlloc>
1022 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(
1023 const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch, const _Allocator& __a)
1024 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out, __a) {}
1025
1026 template <class _SAlloc>
1027 requires(!is_same_v<_SAlloc, allocator_type>)
1028 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
1029 ios_base::openmode __wch = ios_base::out)
1030 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
1031 #endif // _LIBCPP_STD_VER >= 20
1032
1033 #if _LIBCPP_STD_VER >= 26
1034
1035 template <class _Tp>
1036 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1037 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out)
1038 : basic_ostringstream(__t, __which | ios_base::out, _Allocator()) {}
1039
1040 template <class _Tp>
1041 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1042 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, const _Allocator& __a)
1043 : basic_ostringstream(__t, ios_base::out, __a) {}
1044
1045 template <class _Tp>
1046 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1047 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1048 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
1049
1050 #endif // _LIBCPP_STD_VER >= 26
1051
1052 basic_ostringstream(const basic_ostringstream&) = delete;
1053 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
1054 : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1055 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
1056 }
1057
1058 // [ostringstream.assign] Assign and swap:
1059 basic_ostringstream& operator=(const basic_ostringstream&) = delete;
1060 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
1061 basic_ostream<char_type, traits_type>::operator=(std::move(__rhs));
1062 __sb_ = std::move(__rhs.__sb_);
1063 return *this;
1064 }
1065
1066 _LIBCPP_HIDE_FROM_ABI void swap(basic_ostringstream& __rhs) {
1067 basic_ostream<char_type, traits_type>::swap(__rhs);
1068 __sb_.swap(__rhs.__sb_);
1069 }
1070
1071 // [ostringstream.members] Member functions:
1072 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
1073 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
1074 }
1075
1076 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1077 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1078 #else
1079 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
1080
1081 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1082 #endif
1083
1084 #if _LIBCPP_STD_VER >= 20
1085 template <class _SAlloc>
1086 requires __is_allocator<_SAlloc>::value
1087 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
1088 return __sb_.str(__sa);
1089 }
1090
1091 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1092 #endif // _LIBCPP_STD_VER >= 20
1093
1094 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
1095
1096 #if _LIBCPP_STD_VER >= 20
1097 template <class _SAlloc>
1098 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
1099 __sb_.str(__s);
1100 }
1101
1102 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
1103 #endif // _LIBCPP_STD_VER >= 20
1104
1105 #if _LIBCPP_STD_VER >= 26
1106 template <class _Tp>
1107 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1108 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1109 rdbuf()->str(__t);
1110 }
1111 #endif // _LIBCPP_STD_VER >= 26
1112 };
1113
1114 template <class _CharT, class _Traits, class _Allocator>
1115 inline _LIBCPP_HIDE_FROM_ABI void
1116 swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<_CharT, _Traits, _Allocator>& __y) {
1117 __x.swap(__y);
1118 }
1119
1120 // Class template basic_stringstream [stringstream]
1121
1122 template <class _CharT, class _Traits, class _Allocator>
1123 class _LIBCPP_TEMPLATE_VIS basic_stringstream : public basic_iostream<_CharT, _Traits> {
1124 public:
1125 typedef _CharT char_type;
1126 typedef _Traits traits_type;
1127 typedef typename traits_type::int_type int_type;
1128 typedef typename traits_type::pos_type pos_type;
1129 typedef typename traits_type::off_type off_type;
1130 typedef _Allocator allocator_type;
1131
1132 typedef basic_string<char_type, traits_type, allocator_type> string_type;
1133
1134 private:
1135 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
1136
1137 public:
1138 // [stringstream.cons] constructors
1139 _LIBCPP_HIDE_FROM_ABI basic_stringstream()
1140 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
1141
1142 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(ios_base::openmode __wch)
1143 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
1144
1145 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const string_type& __s,
1146 ios_base::openmode __wch = ios_base::in | ios_base::out)
1147 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch) {}
1148
1149 #if _LIBCPP_STD_VER >= 20
1150 _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a)
1151 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {}
1152
1153 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(string_type&& __s,
1154 ios_base::openmode __wch = ios_base::out | ios_base::in)
1155 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(std::move(__s), __wch) {}
1156
1157 template <class _SAlloc>
1158 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, const _Allocator& __a)
1159 : basic_stringstream(__s, ios_base::out | ios_base::in, __a) {}
1160
1161 template <class _SAlloc>
1162 _LIBCPP_HIDE_FROM_ABI
1163 basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch, const _Allocator& __a)
1164 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch, __a) {}
1165
1166 template <class _SAlloc>
1167 requires(!is_same_v<_SAlloc, allocator_type>)
1168 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
1169 ios_base::openmode __wch = ios_base::out | ios_base::in)
1170 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
1171 #endif // _LIBCPP_STD_VER >= 20
1172
1173 #if _LIBCPP_STD_VER >= 26
1174
1175 template <class _Tp>
1176 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1177 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const _Tp& __t,
1178 ios_base::openmode __which = ios_base::out | ios_base::in)
1179 : basic_stringstream(__t, __which, _Allocator()) {}
1180
1181 template <class _Tp>
1182 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1183 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, const _Allocator& __a)
1184 : basic_stringstream(__t, ios_base::out | ios_base::in, __a) {}
1185
1186 template <class _Tp>
1187 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1188 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1189 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}
1190
1191 #endif // _LIBCPP_STD_VER >= 26
1192
1193 basic_stringstream(const basic_stringstream&) = delete;
1194 _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
1195 : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1196 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
1197 }
1198
1199 // [stringstream.assign] Assign and swap:
1200 basic_stringstream& operator=(const basic_stringstream&) = delete;
1201 basic_stringstream& operator=(basic_stringstream&& __rhs) {
1202 basic_iostream<char_type, traits_type>::operator=(std::move(__rhs));
1203 __sb_ = std::move(__rhs.__sb_);
1204 return *this;
1205 }
1206 _LIBCPP_HIDE_FROM_ABI void swap(basic_stringstream& __rhs) {
1207 basic_iostream<char_type, traits_type>::swap(__rhs);
1208 __sb_.swap(__rhs.__sb_);
1209 }
1210
1211 // [stringstream.members] Member functions:
1212 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
1213 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
1214 }
1215
1216 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1217 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1218 #else
1219 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
1220
1221 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1222 #endif
1223
1224 #if _LIBCPP_STD_VER >= 20
1225 template <class _SAlloc>
1226 requires __is_allocator<_SAlloc>::value
1227 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
1228 return __sb_.str(__sa);
1229 }
1230
1231 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1232 #endif // _LIBCPP_STD_VER >= 20
1233
1234 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
1235
1236 #if _LIBCPP_STD_VER >= 20
1237 template <class _SAlloc>
1238 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
1239 __sb_.str(__s);
1240 }
1241
1242 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
1243 #endif // _LIBCPP_STD_VER >= 20
1244
1245 #if _LIBCPP_STD_VER >= 26
1246 template <class _Tp>
1247 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1248 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1249 rdbuf()->str(__t);
1250 }
1251 #endif // _LIBCPP_STD_VER >= 26
1252 };
1253
1254 template <class _CharT, class _Traits, class _Allocator>
1255 inline _LIBCPP_HIDE_FROM_ABI void
1256 swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_CharT, _Traits, _Allocator>& __y) {
1257 __x.swap(__y);
1258 }
1259
1260 #if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
1261 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
1262 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
1263 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
1264 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
1265 #endif
1266
1267 _LIBCPP_END_NAMESPACE_STD
1268
1269 _LIBCPP_POP_MACROS
1270
1271 #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
1272 # include <__cxx03/ostream>
1273 # include <__cxx03/type_traits>
1274 #endif
1275
1276 #endif // _LIBCPP___CXX03_SSTREAM