33 #ifndef _GLIBCXX_ISTREAM
34 #define _GLIBCXX_ISTREAM 1
36 #ifdef _GLIBCXX_SYSHDR
37 #pragma GCC system_header
45 #if __cplusplus > 202302L
49 namespace std _GLIBCXX_VISIBILITY(default)
51 _GLIBCXX_BEGIN_NAMESPACE_VERSION
65 template<
typename _CharT,
typename _Traits>
66 class basic_istream :
virtual public basic_ios<_CharT, _Traits>
70 typedef _CharT char_type;
71 typedef typename _Traits::int_type int_type;
72 typedef typename _Traits::pos_type pos_type;
73 typedef typename _Traits::off_type off_type;
74 typedef _Traits traits_type;
77 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
78 typedef basic_ios<_CharT, _Traits> __ios_type;
79 typedef basic_istream<_CharT, _Traits> __istream_type;
80 typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
82 typedef ctype<_CharT> __ctype_type;
103 { this->init(__sb); }
129 {
return __pf(*
this); }
177 {
return _M_extract(__n); }
184 {
return _M_extract(__n); }
191 {
return _M_extract(__n); }
195 {
return _M_extract(__n); }
199 {
return _M_extract(__n); }
201 #ifdef _GLIBCXX_USE_LONG_LONG
202 #pragma GCC diagnostic push
203 #pragma GCC diagnostic ignored "-Wlong-long"
206 {
return _M_extract(__n); }
210 {
return _M_extract(__n); }
211 #pragma GCC diagnostic pop
226 {
return _M_extract(__f); }
230 {
return _M_extract(__f); }
234 {
return _M_extract(__f); }
237 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
238 __attribute__((__always_inline__))
243 __istream_type& __ret = _M_extract(__flt);
245 if (__flt < -__FLT16_MAX__)
247 __f = -__FLT16_MAX__;
250 else if (__flt > __FLT16_MAX__)
256 __f =
static_cast<_Float16
>(__flt);
258 this->setstate(__err);
263 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
264 __attribute__((__always_inline__))
269 __istream_type& __ret = _M_extract(__flt);
270 __f =
static_cast<_Float32
> (__flt);
275 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
276 __attribute__((__always_inline__))
281 __istream_type& __ret = _M_extract(__dbl);
282 __f =
static_cast<_Float64
> (__dbl);
287 #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
288 __attribute__((__always_inline__))
293 __istream_type& __ret = _M_extract(__ldbl);
294 __f =
static_cast<_Float128
> (__ldbl);
299 #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
300 __attribute__((__always_inline__))
305 __istream_type& __ret = _M_extract(__flt);
307 if (__flt < -__BFLT16_MAX__)
309 __f = -__BFLT16_MAX__;
312 else if (__flt > __BFLT16_MAX__)
314 __f = __BFLT16_MAX__;
318 __f =
static_cast<__gnu_cxx::__bfloat16_t
>(__flt);
320 this->setstate(__err);
335 {
return _M_extract(__p); }
454 {
return this->
get(__s, __n, this->widen(
'\n')); }
476 get(__streambuf_type& __sb, char_type __delim);
487 {
return this->
get(__sb, this->widen(
'\n')); }
527 {
return this->
getline(__s, __n, this->widen(
'\n')); }
558 #if __cplusplus > 202302L
559 [[__gnu__::__always_inline__]]
562 {
return ignore(__n, traits_type::to_int_type(__delim)); }
716 #if __cplusplus >= 201103L
722 __ios_type::move(__rhs);
731 operator=(basic_istream&& __rhs)
738 swap(basic_istream& __rhs)
740 __ios_type::swap(__rhs);
745 template<
typename _ValueT>
747 _M_extract(_ValueT& __v);
766 #ifdef _GLIBCXX_USE_WCHAR_T
768 basic_istream<wchar_t>&
773 basic_istream<wchar_t>&
778 basic_istream<wchar_t>&
791 template<
typename _CharT,
typename _Traits>
802 typedef typename __istream_type::__ctype_type __ctype_type;
803 typedef typename _Traits::int_type __int_type;
837 #if __cplusplus >= 201103L
840 operator bool()
const
856 template<
typename _CharT,
typename _Traits>
860 template<
class _Traits>
863 {
return (__in >>
reinterpret_cast<char&
>(__c)); }
865 template<
class _Traits>
866 inline basic_istream<char, _Traits>&
868 {
return (__in >>
reinterpret_cast<char&
>(__c)); }
872 template<
typename _CharT,
typename _Traits>
874 __istream_extract(basic_istream<_CharT, _Traits>&, _CharT*,
streamsize);
905 #if __cplusplus <= 201703L
906 template<
typename _CharT,
typename _Traits>
907 __attribute__((__nonnull__(2), __access__(__write_only__, 2)))
908 inline basic_istream<_CharT, _Traits>&
909 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
914 size_t __n = __builtin_object_size(__s, 0);
915 if (__n <
sizeof(_CharT))
918 __glibcxx_assert(__n >=
sizeof(_CharT));
923 else if (__n != (
size_t)-1)
925 __n /=
sizeof(_CharT);
927 std::__istream_extract(__in, __s, __n);
928 if (__in.good() && (__w <= 0 || __n < (
size_t)__w))
932 const typename _Traits::int_type __c = __in.rdbuf()->sgetc();
933 const bool __eof = _Traits::eq_int_type(__c, _Traits::eof());
934 if (__builtin_expect(__eof,
true))
942 streamsize __n = __gnu_cxx::__numeric_traits<streamsize>::__max;
943 __n /=
sizeof(_CharT);
944 std::__istream_extract(__in, __s, __n);
949 template<
class _Traits>
950 __attribute__((__nonnull__(2), __access__(__write_only__, 2)))
951 inline basic_istream<
char, _Traits>&
952 operator>>(basic_istream<
char, _Traits>& __in,
unsigned char* __s)
953 {
return __in >>
reinterpret_cast<char*
>(__s); }
955 template<
class _Traits>
956 __attribute__((__nonnull__(2), __access__(__write_only__, 2)))
957 inline basic_istream<
char, _Traits>&
958 operator>>(basic_istream<
char, _Traits>& __in,
signed char* __s)
959 {
return __in >>
reinterpret_cast<char*
>(__s); }
963 template<
typename _CharT,
typename _Traits,
size_t _Num>
964 inline basic_istream<_CharT, _Traits>&
967 static_assert(_Num <= __gnu_cxx::__numeric_traits<streamsize>::__max);
968 std::__istream_extract(__in, __s, _Num);
972 template<
class _Traits,
size_t _Num>
973 inline basic_istream<char, _Traits>&
975 {
return __in >>
reinterpret_cast<char(&)[_Num]
>(__s); }
977 template<
class _Traits,
size_t _Num>
978 inline basic_istream<char, _Traits>&
980 {
return __in >>
reinterpret_cast<char(&)[_Num]
>(__s); }
995 template<
typename _CharT,
typename _Traits>
997 :
public basic_istream<_CharT, _Traits>,
998 public basic_ostream<_CharT, _Traits>
1004 typedef _CharT char_type;
1005 typedef typename _Traits::int_type int_type;
1006 typedef typename _Traits::pos_type pos_type;
1007 typedef typename _Traits::off_type off_type;
1008 typedef _Traits traits_type;
1011 typedef basic_istream<_CharT, _Traits> __istream_type;
1012 typedef basic_ostream<_CharT, _Traits> __ostream_type;
1032 : __istream_type(), __ostream_type() { }
1034 #if __cplusplus >= 201103L
1035 basic_iostream(
const basic_iostream&) =
delete;
1037 basic_iostream(basic_iostream&& __rhs)
1038 : __istream_type(
std::
move(__rhs)), __ostream_type(*this)
1046 operator=(basic_iostream&& __rhs)
1053 swap(basic_iostream& __rhs)
1054 { __istream_type::swap(__rhs); }
1078 template<
typename _CharT,
typename _Traits>
1079 basic_istream<_CharT, _Traits>&
1080 ws(basic_istream<_CharT, _Traits>& __is);
1082 #if __cplusplus >= 201103L
1088 #if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates
1089 template<
typename _Is,
typename _Tp>
1090 requires __derived_from_ios_base<_Is>
1091 && requires (_Is& __is, _Tp&& __t) { __is >> std::forward<_Tp>(__t); }
1092 using __rvalue_stream_extraction_t = _Is&&;
1094 template<
typename _Is,
typename _Tp,
1095 typename = _Require_derived_from_ios_base<_Is>,
1096 typename = decltype(std::declval<_Is&>() >> std::declval<_Tp>())>
1097 using __rvalue_stream_extraction_t = _Is&&;
1110 template<
typename _Istream,
typename _Tp>
1111 inline __rvalue_stream_extraction_t<_Istream, _Tp>
1114 __is >> std::forward<_Tp>(__x);
1119 _GLIBCXX_END_NAMESPACE_VERSION