Upgrade to 2022-era LLVM LIBCXX

This commit is contained in:
Justine Tunney 2024-05-27 02:12:27 -07:00
parent 2f4ca71f26
commit 8e68384e15
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2078 changed files with 165657 additions and 65010 deletions

View file

@ -1,5 +1,5 @@
// -*- C++ -*-
//===--------------------------- istream ----------------------------------===//
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -10,20 +10,6 @@
#ifndef _LIBCPP_ISTREAM
#define _LIBCPP_ISTREAM
#include "third_party/libcxx/__config"
#include "third_party/libcxx/version"
#include "third_party/libcxx/ostream"
#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
/*
istream synopsis
@ -164,14 +150,36 @@ template <class charT, class traits>
basic_istream<charT,traits>&
ws(basic_istream<charT,traits>& is);
template <class charT, class traits, class T>
basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>&& is, T& x);
// rvalue stream extraction
template <class Stream, class T>
Stream&& operator>>(Stream&& is, T&& x);
} // std
*/
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__fwd/istream.h>
#include <__iterator/istreambuf_iterator.h>
#include <__type_traits/conjunction.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_base_of.h>
#include <__utility/declval.h>
#include <__utility/forward.h>
#include <ostream>
#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
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_istream
: virtual public basic_ios<_CharT, _Traits>
@ -189,16 +197,14 @@ public:
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
{ this->init(__sb); }
virtual ~basic_istream();
~basic_istream() override;
protected:
#ifndef _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
basic_istream(basic_istream&& __rhs);
// 27.7.1.1.2 Assign/swap:
inline _LIBCPP_INLINE_VISIBILITY
basic_istream& operator=(basic_istream&& __rhs);
#endif
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_istream& __rhs) {
@ -206,10 +212,8 @@ protected:
basic_ios<char_type, traits_type>::swap(__rhs);
}
#ifndef _LIBCPP_CXX03_LANG
basic_istream (const basic_istream& __rhs) = delete;
basic_istream& operator=(const basic_istream& __rhs) = delete;
#endif
public:
// 27.7.1.1.3 Prefix/suffix:
@ -294,16 +298,15 @@ class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry
{
bool __ok_;
sentry(const sentry&); // = delete;
sentry& operator=(const sentry&); // = delete;
public:
explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
// ~sentry() = default;
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_EXPLICIT
operator bool() const {return __ok_;}
explicit operator bool() const {return __ok_;}
sentry(const sentry&) = delete;
sentry& operator=(const sentry&) = delete;
};
template <class _CharT, class _Traits>
@ -318,7 +321,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
if (!__noskipws && (__is.flags() & ios_base::skipws))
{
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
_Ip __i(__is);
_Ip __eof;
for (; __i != __eof; ++__i)
@ -333,8 +336,6 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
__is.setstate(ios_base::failbit);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
: __gc_(__rhs.__gc_)
@ -351,29 +352,27 @@ basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
return *this;
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>::~basic_istream()
{
}
template <class _Tp, class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
#ifndef _LIBCPP_NO_EXCEPTIONS
std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -468,21 +467,21 @@ basic_istream<_CharT, _Traits>::operator>>(void*& __n)
}
template <class _Tp, class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
long __temp;
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
if (__temp < numeric_limits<_Tp>::min())
{
__state |= ios_base::failbit;
@ -497,7 +496,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
{
__n = static_cast<_Tp>(__temp);
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -508,7 +507,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
@ -537,12 +536,12 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
_CharT* __s = __p;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (__s != __p + (__n-1))
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@ -561,7 +560,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
__is.width(0);
if (__s == __p)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -578,7 +577,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
return __is;
}
#if _LIBCPP_STD_VER > 17
#if _LIBCPP_STD_VER >= 20
template<class _CharT, class _Traits, size_t _Np>
inline _LIBCPP_INLINE_VISIBILITY
@ -636,17 +635,17 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
return __is >> (char*)__s;
}
#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP_STD_VER >= 20
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
{
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
@ -655,7 +654,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
__state |= ios_base::eofbit | ios_base::failbit;
else
__c = _Traits::to_char_type(__i);
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -699,10 +698,10 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
{
if (__sb)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
@ -720,7 +719,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
}
if (__gc_ == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -734,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
else
{
@ -755,7 +754,7 @@ basic_istream<_CharT, _Traits>::get()
sentry __s(*this, true);
if (__s)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
@ -764,7 +763,7 @@ basic_istream<_CharT, _Traits>::get()
__state |= ios_base::failbit | ios_base::eofbit;
else
__gc_ = 1;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -791,7 +790,7 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
{
if (__n > 0)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
@ -812,7 +811,7 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
}
if (__gc_ == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -851,10 +850,10 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
@ -871,14 +870,14 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
++__gc_;
this->rdbuf()->sbumpc();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
__state |= ios_base::badbit;
// according to the spec, exceptions here are caught but not rethrown
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (__gc_ == 0)
__state |= ios_base::failbit;
this->setstate(__state);
@ -895,10 +894,10 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
@ -923,7 +922,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
this->rdbuf()->sbumpc();
++__gc_;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -938,7 +937,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
if (__n > 0)
*__s = char_type();
@ -957,10 +956,10 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (__n == numeric_limits<streamsize>::max())
{
while (true)
@ -991,7 +990,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
break;
}
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1002,7 +1001,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@ -1018,14 +1017,14 @@ basic_istream<_CharT, _Traits>::peek()
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__r = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
__state |= ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1036,7 +1035,7 @@ basic_istream<_CharT, _Traits>::peek()
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@ -1051,14 +1050,14 @@ basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__gc_ = this->rdbuf()->sgetn(__s, __n);
if (__gc_ != __n)
__state |= ios_base::failbit | ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1069,7 +1068,7 @@ basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
else
{
@ -1088,10 +1087,10 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
streamsize __c = this->rdbuf()->in_avail();
switch (__c)
{
@ -1107,7 +1106,7 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
__state |= ios_base::failbit | ios_base::eofbit;
break;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1118,7 +1117,7 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
else
{
@ -1138,13 +1137,13 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1155,7 +1154,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
else
{
@ -1175,13 +1174,13 @@ basic_istream<_CharT, _Traits>::unget()
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1192,7 +1191,7 @@ basic_istream<_CharT, _Traits>::unget()
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
else
{
@ -1211,18 +1210,18 @@ basic_istream<_CharT, _Traits>::sync()
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0)
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf() == nullptr)
return -1;
if (this->rdbuf()->pubsync() == -1)
{
__state |= ios_base::badbit;
return -1;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1233,7 +1232,7 @@ basic_istream<_CharT, _Traits>::sync()
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@ -1248,12 +1247,12 @@ basic_istream<_CharT, _Traits>::tellg()
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1264,7 +1263,7 @@ basic_istream<_CharT, _Traits>::tellg()
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@ -1279,13 +1278,13 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1296,7 +1295,7 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@ -1311,13 +1310,13 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
sentry __sen(*this, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1328,25 +1327,25 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is)
{
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (true)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@ -1359,7 +1358,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
break;
__is.rdbuf()->sbumpc();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1370,25 +1369,31 @@ ws(basic_istream<_CharT, _Traits>& __is)
throw;
}
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Stream, class _Tp, class = void>
struct __is_istreamable : false_type { };
template <class _CharT, class _Traits, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)
template <class _Stream, class _Tp>
struct __is_istreamable<_Stream, _Tp, decltype(
std::declval<_Stream>() >> std::declval<_Tp>(), void()
)> : true_type { };
template <class _Stream, class _Tp, class = typename enable_if<
_And<is_base_of<ios_base, _Stream>,
__is_istreamable<_Stream&, _Tp&&> >::value
>::type>
_LIBCPP_INLINE_VISIBILITY
_Stream&& operator>>(_Stream&& __is, _Tp&& __x)
{
__is >> _VSTD::forward<_Tp>(__x);
return __is;
return _VSTD::move(__is);
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_iostream
: public basic_istream<_CharT, _Traits>,
@ -1408,23 +1413,20 @@ public:
: basic_istream<_CharT, _Traits>(__sb)
{}
virtual ~basic_iostream();
~basic_iostream() override;
protected:
#ifndef _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream(basic_iostream&& __rhs);
// assign/swap
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream& operator=(basic_iostream&& __rhs);
#endif
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_iostream& __rhs)
{ basic_istream<char_type, traits_type>::swap(__rhs); }
};
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
@ -1439,15 +1441,13 @@ basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
return *this;
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>::~basic_iostream()
{
}
template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>&
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
@ -1455,7 +1455,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
@ -1466,7 +1466,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
if (__n <= 0)
__n = numeric_limits<streamsize>::max();
streamsize __c = 0;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (__c < __n)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@ -1485,7 +1485,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
__is.width(0);
if (__c == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1503,7 +1503,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
}
template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>&
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
@ -1511,7 +1511,7 @@ getline(basic_istream<_CharT, _Traits>& __is,
typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
@ -1538,7 +1538,7 @@ getline(basic_istream<_CharT, _Traits>& __is,
}
if (__extr == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1561,18 +1561,16 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
return getline(__is, __str, __is.widen('\n'));
return std::getline(__is, __str, __is.widen('\n'));
}
#ifndef _LIBCPP_CXX03_LANG
template<class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
return getline(__is, __str, __dlm);
return std::getline(__is, __str, __dlm);
}
template<class _CharT, class _Traits, class _Allocator>
@ -1581,29 +1579,27 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
return getline(__is, __str, __is.widen('\n'));
return std::getline(__is, __str, __is.widen('\n'));
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, size_t _Size>
basic_istream<_CharT, _Traits>&
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif
basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
size_t __c = 0;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
while (__c < _Size)
while (__c != _Size)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
@ -1621,7 +1617,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
__x = bitset<_Size>(__str);
if (_Size > 0 && __c == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1638,14 +1634,19 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is;
}
#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
#endif
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
_LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <concepts>
# include <type_traits>
#endif
_LIBCPP_POP_MACROS
#endif // _LIBCPP_ISTREAM
#endif // _LIBCPP_ISTREAM