mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Upgrade to 2022-era LLVM LIBCXX
This commit is contained in:
parent
2f4ca71f26
commit
8e68384e15
2078 changed files with 165657 additions and 65010 deletions
635
third_party/libcxx/sstream
vendored
635
third_party/libcxx/sstream
vendored
|
@ -1,5 +1,5 @@
|
|||
// -*- C++ -*-
|
||||
//===--------------------------- sstream ----------------------------------===//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -10,24 +10,10 @@
|
|||
#ifndef _LIBCPP_SSTREAM
|
||||
#define _LIBCPP_SSTREAM
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/ostream"
|
||||
#include "third_party/libcxx/istream"
|
||||
#include "third_party/libcxx/string"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
/*
|
||||
sstream synopsis
|
||||
sstream synopsis [sstream.syn]
|
||||
|
||||
// Class template basic_stringbuf [stringbuf]
|
||||
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
class basic_stringbuf
|
||||
: public basic_streambuf<charT, traits>
|
||||
|
@ -40,22 +26,25 @@ public:
|
|||
typedef typename traits_type::off_type off_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
// 27.8.1.1 Constructors:
|
||||
explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
// [stringbuf.cons] constructors:
|
||||
explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
|
||||
basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
|
||||
explicit basic_stringbuf(ios_base::openmode which); // C++20
|
||||
explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
basic_stringbuf(basic_stringbuf&& rhs);
|
||||
|
||||
// 27.8.1.2 Assign and swap:
|
||||
// [stringbuf.assign] Assign and swap:
|
||||
basic_stringbuf& operator=(basic_stringbuf&& rhs);
|
||||
void swap(basic_stringbuf& rhs);
|
||||
|
||||
// 27.8.1.3 Get and set:
|
||||
// [stringbuf.members] Member functions:
|
||||
basic_string<char_type, traits_type, allocator_type> str() const;
|
||||
void str(const basic_string<char_type, traits_type, allocator_type>& s);
|
||||
basic_string_view<char_type, traits_type> view() const noexcept; // C++20
|
||||
|
||||
protected:
|
||||
// 27.8.1.4 Overridden virtual functions:
|
||||
// [stringbuf.virtuals] Overridden virtual functions:
|
||||
virtual int_type underflow();
|
||||
virtual int_type pbackfail(int_type c = traits_type::eof());
|
||||
virtual int_type overflow (int_type c = traits_type::eof());
|
||||
|
@ -66,6 +55,7 @@ protected:
|
|||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
};
|
||||
|
||||
// [stringbuf.assign] non member swap
|
||||
template <class charT, class traits, class Allocator>
|
||||
void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
||||
basic_stringbuf<charT, traits, Allocator>& y);
|
||||
|
@ -73,6 +63,7 @@ template <class charT, class traits, class Allocator>
|
|||
typedef basic_stringbuf<char> stringbuf;
|
||||
typedef basic_stringbuf<wchar_t> wstringbuf;
|
||||
|
||||
// Class template basic_istringstream [istringstream]
|
||||
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
class basic_istringstream
|
||||
: public basic_istream<charT, traits>
|
||||
|
@ -85,20 +76,24 @@ public:
|
|||
typedef typename traits_type::off_type off_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
// 27.8.2.1 Constructors:
|
||||
explicit basic_istringstream(ios_base::openmode which = ios_base::in);
|
||||
// [istringstream.cons] Constructors:
|
||||
explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
|
||||
basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
|
||||
explicit basic_istringstream(ios_base::openmode which); // C++20
|
||||
|
||||
explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
|
||||
ios_base::openmode which = ios_base::in);
|
||||
basic_istringstream(basic_istringstream&& rhs);
|
||||
|
||||
// 27.8.2.2 Assign and swap:
|
||||
// [istringstream.assign] Assign and swap:
|
||||
basic_istringstream& operator=(basic_istringstream&& rhs);
|
||||
void swap(basic_istringstream& rhs);
|
||||
|
||||
// 27.8.2.3 Members:
|
||||
// [istringstream.members] Member functions:
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
basic_string<char_type, traits_type, allocator_type> str() const;
|
||||
void str(const basic_string<char_type, traits_type, allocator_type>& s);
|
||||
basic_string_view<char_type, traits_type> view() const noexcept; // C++20
|
||||
};
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
|
@ -108,6 +103,7 @@ template <class charT, class traits, class Allocator>
|
|||
typedef basic_istringstream<char> istringstream;
|
||||
typedef basic_istringstream<wchar_t> wistringstream;
|
||||
|
||||
// Class template basic_ostringstream [ostringstream]
|
||||
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
class basic_ostringstream
|
||||
: public basic_ostream<charT, traits>
|
||||
|
@ -121,20 +117,24 @@ public:
|
|||
typedef typename traits_type::off_type off_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
// 27.8.3.1 Constructors/destructor:
|
||||
explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
|
||||
// [ostringstream.cons] Constructors:
|
||||
explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
|
||||
basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
|
||||
explicit basic_ostringstream(ios_base::openmode which); // C++20
|
||||
|
||||
explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
|
||||
ios_base::openmode which = ios_base::out);
|
||||
basic_ostringstream(basic_ostringstream&& rhs);
|
||||
|
||||
// 27.8.3.2 Assign/swap:
|
||||
// [ostringstream.assign] Assign and swap:
|
||||
basic_ostringstream& operator=(basic_ostringstream&& rhs);
|
||||
void swap(basic_ostringstream& rhs);
|
||||
|
||||
// 27.8.3.3 Members:
|
||||
// [ostringstream.members] Member functions:
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
basic_string<char_type, traits_type, allocator_type> str() const;
|
||||
void str(const basic_string<char_type, traits_type, allocator_type>& s);
|
||||
basic_string_view<char_type, traits_type> view() const noexcept; // C++20
|
||||
};
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
|
@ -144,6 +144,7 @@ template <class charT, class traits, class Allocator>
|
|||
typedef basic_ostringstream<char> ostringstream;
|
||||
typedef basic_ostringstream<wchar_t> wostringstream;
|
||||
|
||||
// Class template basic_stringstream [stringstream]
|
||||
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
class basic_stringstream
|
||||
: public basic_iostream<charT, traits>
|
||||
|
@ -157,20 +158,24 @@ public:
|
|||
typedef typename traits_type::off_type off_type;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
// constructors/destructor
|
||||
explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
|
||||
// [stringstream.cons] constructors
|
||||
explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
|
||||
basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
|
||||
explicit basic_stringstream(ios_base::openmode which); // C++20
|
||||
|
||||
explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
|
||||
ios_base::openmode which = ios_base::out|ios_base::in);
|
||||
basic_stringstream(basic_stringstream&& rhs);
|
||||
|
||||
// 27.8.5.1 Assign/swap:
|
||||
// [stringstream.assign] Assign and swap:
|
||||
basic_stringstream& operator=(basic_stringstream&& rhs);
|
||||
void swap(basic_stringstream& rhs);
|
||||
|
||||
// Members:
|
||||
// [stringstream.members] Member functions:
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
basic_string<char_type, traits_type, allocator_type> str() const;
|
||||
void str(const basic_string<char_type, traits_type, allocator_type>& str);
|
||||
basic_string_view<char_type, traits_type> view() const noexcept; // C++20
|
||||
};
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
|
@ -184,7 +189,26 @@ typedef basic_stringstream<wchar_t> wstringstream;
|
|||
|
||||
*/
|
||||
|
||||
// basic_stringbuf
|
||||
#include <__assert> // all public C++ headers provide the assertion handler
|
||||
#include <__config>
|
||||
#include <__fwd/sstream.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <version>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// Class template basic_stringbuf [stringbuf]
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
class _LIBCPP_TEMPLATE_VIS basic_stringbuf
|
||||
|
@ -207,55 +231,51 @@ private:
|
|||
ios_base::openmode __mode_;
|
||||
|
||||
public:
|
||||
// 27.8.1.1 Constructors:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
// [stringbuf.cons] constructors:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf()
|
||||
: __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringbuf(ios_base::openmode __wch)
|
||||
: __hm_(nullptr), __mode_(__wch) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringbuf(const string_type& __s,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out)
|
||||
: __str_(__s.get_allocator()), __hm_(nullptr), __mode_(__wch)
|
||||
{
|
||||
str(__s);
|
||||
}
|
||||
|
||||
basic_stringbuf(basic_stringbuf&& __rhs);
|
||||
|
||||
// 27.8.1.2 Assign and swap:
|
||||
// [stringbuf.assign] Assign and swap:
|
||||
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
|
||||
#endif
|
||||
void swap(basic_stringbuf& __rhs);
|
||||
|
||||
// 27.8.1.3 Get and set:
|
||||
// [stringbuf.members] Member functions:
|
||||
string_type str() const;
|
||||
void str(const string_type& __s);
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
basic_string_view<char_type, traits_type> view() const noexcept;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// 27.8.1.4 Overridden virtual functions:
|
||||
virtual int_type underflow();
|
||||
virtual int_type pbackfail(int_type __c = traits_type::eof());
|
||||
virtual int_type overflow (int_type __c = traits_type::eof());
|
||||
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
virtual pos_type seekpos(pos_type __sp,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
// [stringbuf.virtuals] Overridden virtual functions:
|
||||
int_type underflow() override;
|
||||
int_type pbackfail(int_type __c = traits_type::eof()) override;
|
||||
int_type overflow (int_type __c = traits_type::eof()) override;
|
||||
pos_type seekoff(off_type __off, ios_base::seekdir __way,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out) override;
|
||||
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
|
||||
pos_type seekpos(pos_type __sp,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out) override {
|
||||
return seekoff(__sp, ios_base::beg, __wch);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
|
||||
: __hm_(0),
|
||||
__mode_(__wch)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
|
||||
ios_base::openmode __wch)
|
||||
: __str_(__s.get_allocator()),
|
||||
__hm_(0),
|
||||
__mode_(__wch)
|
||||
{
|
||||
str(__s);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
|
||||
: __mode_(__rhs.__mode_)
|
||||
|
@ -345,8 +365,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
|
|||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
|
||||
|
@ -437,6 +455,9 @@ template <class _CharT, class _Traits, class _Allocator>
|
|||
basic_string<_CharT, _Traits, _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
|
||||
{
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
return string_type(view(), __str_.get_allocator());
|
||||
#else // _LIBCPP_STD_VER >= 20
|
||||
if (__mode_ & ios_base::out)
|
||||
{
|
||||
if (__hm_ < this->pptr())
|
||||
|
@ -446,6 +467,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
|
|||
else if (__mode_ & ios_base::in)
|
||||
return string_type(this->eback(), this->egptr(), __str_.get_allocator());
|
||||
return string_type(__str_.get_allocator());
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
|
@ -453,7 +475,7 @@ void
|
|||
basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
||||
{
|
||||
__str_ = __s;
|
||||
__hm_ = 0;
|
||||
__hm_ = nullptr;
|
||||
if (__mode_ & ios_base::in)
|
||||
{
|
||||
__hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
|
||||
|
@ -481,6 +503,20 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
|||
}
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
|
||||
if (__mode_ & ios_base::out) {
|
||||
if (__hm_ < this->pptr())
|
||||
__hm_ = this->pptr();
|
||||
return basic_string_view<_CharT, _Traits>(this->pbase(), __hm_);
|
||||
} else if (__mode_ & ios_base::in)
|
||||
return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr());
|
||||
return basic_string_view<_CharT, _Traits>();
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
|
||||
|
@ -532,10 +568,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
|
|||
{
|
||||
if (!(__mode_ & ios_base::out))
|
||||
return traits_type::eof();
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
|
||||
ptrdiff_t __nout = this->pptr() - this->pbase();
|
||||
ptrdiff_t __hm = __hm_ - this->pbase();
|
||||
__str_.push_back(char_type());
|
||||
|
@ -544,13 +580,13 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
|
|||
this->setp(__p, __p + __str_.size());
|
||||
this->__pbump(__nout);
|
||||
__hm_ = this->pbase() + __hm;
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
|
||||
}
|
||||
__hm_ = _VSTD::max(this->pptr() + 1, __hm_);
|
||||
if (__mode_ & ios_base::in)
|
||||
|
@ -600,9 +636,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
|
|||
return pos_type(-1);
|
||||
if (__noff != 0)
|
||||
{
|
||||
if ((__wch & ios_base::in) && this->gptr() == 0)
|
||||
if ((__wch & ios_base::in) && this->gptr() == nullptr)
|
||||
return pos_type(-1);
|
||||
if ((__wch & ios_base::out) && this->pptr() == 0)
|
||||
if ((__wch & ios_base::out) && this->pptr() == nullptr)
|
||||
return pos_type(-1);
|
||||
}
|
||||
if (__wch & ios_base::in)
|
||||
|
@ -610,20 +646,12 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
|
|||
if (__wch & ios_base::out)
|
||||
{
|
||||
this->setp(this->pbase(), this->epptr());
|
||||
this->pbump(__noff);
|
||||
this->__pbump(__noff);
|
||||
}
|
||||
return pos_type(__noff);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
|
||||
ios_base::openmode __wch)
|
||||
{
|
||||
return seekoff(__sp, ios_base::beg, __wch);
|
||||
}
|
||||
|
||||
// basic_istringstream
|
||||
// Class template basic_istringstream [istringstream]
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
class _LIBCPP_TEMPLATE_VIS basic_istringstream
|
||||
|
@ -643,74 +671,63 @@ private:
|
|||
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
|
||||
|
||||
public:
|
||||
// 27.8.2.1 Constructors:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
// [istringstream.cons] Constructors:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istringstream()
|
||||
: basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_istringstream(ios_base::openmode __wch)
|
||||
: basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_istringstream(const string_type& __s,
|
||||
ios_base::openmode __wch = ios_base::in);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_istringstream(basic_istringstream&& __rhs);
|
||||
ios_base::openmode __wch = ios_base::in)
|
||||
: basic_istream<_CharT, _Traits>(&__sb_)
|
||||
, __sb_(__s, __wch | ios_base::in)
|
||||
{ }
|
||||
|
||||
// 27.8.2.2 Assign and swap:
|
||||
basic_istringstream& operator=(basic_istringstream&& __rhs);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_istringstream& __rhs);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istringstream(basic_istringstream&& __rhs)
|
||||
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
|
||||
, __sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
// 27.8.2.3 Members:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s);
|
||||
// [istringstream.assign] Assign and swap:
|
||||
basic_istringstream& operator=(basic_istringstream&& __rhs) {
|
||||
basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_istringstream& __rhs) {
|
||||
basic_istream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
// [istringstream.members] Member functions:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const {
|
||||
return __sb_.str();
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s) {
|
||||
__sb_.str(__s);
|
||||
}
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
basic_string_view<char_type, traits_type> view() const noexcept {
|
||||
return __sb_.view();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
|
||||
: basic_istream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__wch | ios_base::in)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
|
||||
ios_base::openmode __wch)
|
||||
: basic_istream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__s, __wch | ios_base::in)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
|
||||
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>&
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
|
||||
{
|
||||
basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
|
||||
{
|
||||
basic_istream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
|
@ -720,27 +737,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
|
|||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>*
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
|
||||
{
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
basic_istringstream<_CharT, _Traits, _Allocator>::str() const
|
||||
{
|
||||
return __sb_.str();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
||||
{
|
||||
__sb_.str(__s);
|
||||
}
|
||||
|
||||
// basic_ostringstream
|
||||
// Class template basic_ostringstream [ostringstream]
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
class _LIBCPP_TEMPLATE_VIS basic_ostringstream
|
||||
|
@ -760,75 +757,64 @@ private:
|
|||
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
|
||||
|
||||
public:
|
||||
// 27.8.2.1 Constructors:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
// [ostringstream.cons] Constructors:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostringstream()
|
||||
: basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ostringstream(ios_base::openmode __wch)
|
||||
: basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ostringstream(const string_type& __s,
|
||||
ios_base::openmode __wch = ios_base::out);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostringstream(basic_ostringstream&& __rhs);
|
||||
ios_base::openmode __wch = ios_base::out)
|
||||
: basic_ostream<_CharT, _Traits>(&__sb_)
|
||||
, __sb_(__s, __wch | ios_base::out)
|
||||
{ }
|
||||
|
||||
// 27.8.2.2 Assign and swap:
|
||||
basic_ostringstream& operator=(basic_ostringstream&& __rhs);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_ostringstream& __rhs);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostringstream(basic_ostringstream&& __rhs)
|
||||
: basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs))
|
||||
, __sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
// 27.8.2.3 Members:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s);
|
||||
// [ostringstream.assign] Assign and swap:
|
||||
basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
|
||||
basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_ostringstream& __rhs) {
|
||||
basic_ostream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
// [ostringstream.members] Member functions:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const {
|
||||
return __sb_.str();
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s) {
|
||||
__sb_.str(__s);
|
||||
}
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
basic_string_view<char_type, traits_type> view() const noexcept {
|
||||
return __sb_.view();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
|
||||
: basic_ostream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__wch | ios_base::out)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
|
||||
ios_base::openmode __wch)
|
||||
: basic_ostream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__s, __wch | ios_base::out)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
|
||||
: basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>&
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
|
||||
{
|
||||
basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
|
||||
{
|
||||
basic_ostream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
|
@ -838,28 +824,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
|
|||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>*
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
|
||||
{
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
|
||||
{
|
||||
return __sb_.str();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void
|
||||
basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
||||
{
|
||||
__sb_.str(__s);
|
||||
}
|
||||
|
||||
// basic_stringstream
|
||||
// Class template basic_stringstream [stringstream]
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
class _LIBCPP_TEMPLATE_VIS basic_stringstream
|
||||
|
@ -879,75 +844,63 @@ private:
|
|||
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
|
||||
|
||||
public:
|
||||
// 27.8.2.1 Constructors:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
// [stringstream.cons] constructors
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringstream()
|
||||
: basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringstream(ios_base::openmode __wch)
|
||||
: basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_stringstream(const string_type& __s,
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringstream(basic_stringstream&& __rhs);
|
||||
ios_base::openmode __wch = ios_base::in | ios_base::out)
|
||||
: basic_iostream<_CharT, _Traits>(&__sb_)
|
||||
, __sb_(__s, __wch)
|
||||
{ }
|
||||
|
||||
// 27.8.2.2 Assign and swap:
|
||||
basic_stringstream& operator=(basic_stringstream&& __rhs);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_stringstream& __rhs);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringstream(basic_stringstream&& __rhs)
|
||||
: basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs))
|
||||
, __sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
// 27.8.2.3 Members:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const;
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s);
|
||||
// [stringstream.assign] Assign and swap:
|
||||
basic_stringstream& operator=(basic_stringstream&& __rhs) {
|
||||
basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_stringstream& __rhs) {
|
||||
basic_iostream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
// [stringstream.members] Member functions:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
string_type str() const {
|
||||
return __sb_.str();
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void str(const string_type& __s) {
|
||||
__sb_.str(__s);
|
||||
}
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
basic_string_view<char_type, traits_type> view() const noexcept {
|
||||
return __sb_.view();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
|
||||
: basic_iostream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__wch)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
|
||||
ios_base::openmode __wch)
|
||||
: basic_iostream<_CharT, _Traits>(&__sb_),
|
||||
__sb_(__s, __wch)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
|
||||
: basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>&
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
|
||||
{
|
||||
basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
|
||||
{
|
||||
basic_iostream<char_type, traits_type>::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
|
@ -957,29 +910,19 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
|
|||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>*
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
|
||||
{
|
||||
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::str() const
|
||||
{
|
||||
return __sb_.str();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
void
|
||||
basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
||||
{
|
||||
__sb_.str(__s);
|
||||
}
|
||||
#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_SSTREAM
|
||||
#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_SSTREAM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue