summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-02 09:57:49 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-02 09:57:49 +0000
commit3f3b33e59b846004e2d25825d020c6ac906d25ef (patch)
treef19f281bfa2b6d65105d46eb53236d70bfa0d498 /libstdc++-v3/include
parent843c10540b9652b8ceb880bb24e43e34429aed15 (diff)
downloadppe42-gcc-3f3b33e59b846004e2d25825d020c6ac906d25ef.tar.gz
ppe42-gcc-3f3b33e59b846004e2d25825d020c6ac906d25ef.zip
2006-01-02 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/24645 * include/std/std_istream.h (basic_istream<>::_M_extract): New. (operator>>(bool&), operator>>(short&), operator>>(unsigned short&), operator>>(int&), operator>>(unsigned int&), operator>>(long&), operator>>(unsigned long&), operator>>(long long&), operator>> (unsigned long long&), operator>>(float&), operator>>(double&), operator>>(long double&), operator>>(void*&)): Use it. * include/bits/istream.tcc (basic_istream<>::_M_extract): Define. * include/std/std_ostream.h (basic_ostream<>::_M_insert): New. (operator<<(long), operator<<(unsigned long), operator<<(bool), operator<<(short), operator<<(unsigned short), operator<<(int), operator<<(unsigned int), operator<<(long long), operator<< (unsigned long long), operator<<(double), operator<<(float), operator<<(long double), operator<<(const void*): Use it. * include/bits/ostream.tcc (basic_ostream<>::_M_insert): Define. * src/istream-inst.cc: Add _M_insert instantiations. * src/ostream-inst.cc: Add _M_extract instantiations. * config/abi/pre/gnu.ver: Export the new symbols @GLIBCXX_3.4.7; detail existing @GLIBCXX_3.4 exports of basic_ostream, num_put, money_put, etc., symbols to avoid exporting _M_insert symbols @GLIBCXX_3.4. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109236 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/istream.tcc325
-rw-r--r--libstdc++-v3/include/bits/ostream.tcc350
-rw-r--r--libstdc++-v3/include/std/std_istream.h73
-rw-r--r--libstdc++-v3/include/std/std_ostream.h71
4 files changed, 161 insertions, 658 deletions
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index 541e75afb80..184c2bd613f 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -110,310 +110,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(bool& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(short& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- long __l;
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __l);
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 118. basic_istream uses nonexistent num_get member functions.
- if (!(__err & ios_base::failbit)
- && (numeric_limits<short>::min() <= __l
- && __l <= numeric_limits<short>::max()))
- __n = __l;
- else
- __err |= ios_base::failbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(unsigned short& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(int& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- long __l;
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __l);
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 118. basic_istream uses nonexistent num_get member functions.
- if (!(__err & ios_base::failbit)
- && (numeric_limits<int>::min() <= __l
- && __l <= numeric_limits<int>::max()))
- __n = __l;
- else
- __err |= ios_base::failbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(unsigned int& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(long& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(unsigned long& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
-#ifdef _GLIBCXX_USE_LONG_LONG
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(long long& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(unsigned long long& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-#endif
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(float& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(double& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(long double& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(void*& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __n);
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
+ template<typename _ValueT>
+ basic_istream<_CharT, _Traits>&
+ basic_istream<_CharT, _Traits>::
+ _M_extract(_ValueT& __v)
+ {
+ sentry __cerb(*this, false);
+ if (__cerb)
+ {
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ try
+ {
+ const __num_get_type& __ng = __check_facet(this->_M_num_get);
+ __ng.get(*this, 0, *this, __err, __v);
+ }
+ catch(...)
+ { this->_M_setstate(ios_base::badbit); }
+ if (__err)
+ this->setstate(__err);
+ }
+ return *this;
+ }
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc
index 1642583845f..7b80495c7e8 100644
--- a/libstdc++-v3/include/bits/ostream.tcc
+++ b/libstdc++-v3/include/bits/ostream.tcc
@@ -97,333 +97,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(bool __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(short __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 117. basic_ostream uses nonexistent num_put member functions.
- long __l;
- const ios_base::fmtflags __fmt = (this->flags()
- & ios_base::basefield);
- if (__fmt == ios_base::oct || __fmt == ios_base::hex)
- __l = static_cast<long>(static_cast<unsigned short>(__n));
- else
- __l = static_cast<long>(__n);
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __l).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(unsigned short __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 117. basic_ostream uses nonexistent num_put member functions.
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(),
- static_cast<unsigned long>(__n)).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(int __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 117. basic_ostream uses nonexistent num_put member functions.
- long __l;
- const ios_base::fmtflags __fmt = (this->flags()
- & ios_base::basefield);
- if (__fmt == ios_base::oct || __fmt == ios_base::hex)
- __l = static_cast<long>(static_cast<unsigned int>(__n));
- else
- __l = static_cast<long>(__n);
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __l).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(unsigned int __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 117. basic_ostream uses nonexistent num_put member functions.
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(),
- static_cast<unsigned long>(__n)).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(long __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(unsigned long __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
-#ifdef _GLIBCXX_USE_LONG_LONG
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(long long __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(unsigned long long __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-#endif
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(float __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 117. basic_ostream uses nonexistent num_put member functions.
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(),
- static_cast<double>(__n)).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(double __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(long double __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(const void* __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __n).failed())
- __err |= ios_base::badbit;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
-
+ template<typename _ValueT>
+ basic_ostream<_CharT, _Traits>&
+ basic_ostream<_CharT, _Traits>::
+ _M_insert(_ValueT __v)
+ {
+ sentry __cerb(*this);
+ if (__cerb)
+ {
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ try
+ {
+ const __num_put_type& __np = __check_facet(this->_M_num_put);
+ if (__np.put(*this, *this, this->fill(), __v).failed())
+ __err |= ios_base::badbit;
+ }
+ catch(...)
+ { this->_M_setstate(ios_base::badbit); }
+ if (__err)
+ this->setstate(__err);
+ }
+ return *this;
+ }
+
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
diff --git a/libstdc++-v3/include/std/std_istream.h b/libstdc++-v3/include/std/std_istream.h
index 2c5c572286a..659d3e2a2d7 100644
--- a/libstdc++-v3/include/std/std_istream.h
+++ b/libstdc++-v3/include/std/std_istream.h
@@ -166,45 +166,86 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* @c num_get facet) to parse the input data.
*/
__istream_type&
- operator>>(bool& __n);
+ operator>>(bool& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(short& __n);
+ operator>>(short& __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 118. basic_istream uses nonexistent num_get member functions.
+ long __l;
+ _M_extract(__l);
+ if (!this->fail())
+ {
+ if (numeric_limits<short>::min() <= __l
+ && __l <= numeric_limits<short>::max())
+ __n = __l;
+ else
+ this->setstate(ios_base::failbit);
+ }
+ return *this;
+ }
__istream_type&
- operator>>(unsigned short& __n);
+ operator>>(unsigned short& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(int& __n);
-
+ operator>>(int& __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 118. basic_istream uses nonexistent num_get member functions.
+ long __l;
+ _M_extract(__l);
+ if (!this->fail())
+ {
+ if (numeric_limits<int>::min() <= __l
+ && __l <= numeric_limits<int>::max())
+ __n = __l;
+ else
+ this->setstate(ios_base::failbit);
+ }
+ return *this;
+ }
+
__istream_type&
- operator>>(unsigned int& __n);
+ operator>>(unsigned int& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(long& __n);
+ operator>>(long& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(unsigned long& __n);
+ operator>>(unsigned long& __n)
+ { return _M_extract(__n); }
#ifdef _GLIBCXX_USE_LONG_LONG
__istream_type&
- operator>>(long long& __n);
+ operator>>(long long& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(unsigned long long& __n);
+ operator>>(unsigned long long& __n)
+ { return _M_extract(__n); }
#endif
__istream_type&
- operator>>(float& __f);
+ operator>>(float& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(double& __f);
+ operator>>(double& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(long double& __f);
+ operator>>(long double& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(void*& __p);
+ operator>>(void*& __p)
+ { return _M_extract(__p); }
/**
* @brief Extracting into another streambuf.
@@ -572,6 +613,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
protected:
explicit
basic_istream(): _M_gcount(streamsize(0)) { }
+
+ template<typename _ValueT>
+ __istream_type&
+ _M_extract(_ValueT& __v);
};
// Explicit specialization declarations, defined in src/istream.cc.
diff --git a/libstdc++-v3/include/std/std_ostream.h b/libstdc++-v3/include/std/std_ostream.h
index 8d4228238e7..8dc398ed0ef 100644
--- a/libstdc++-v3/include/std/std_ostream.h
+++ b/libstdc++-v3/include/std/std_ostream.h
@@ -164,45 +164,86 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* @c num_get facet) to perform numeric formatting.
*/
__ostream_type&
- operator<<(long __n);
+ operator<<(long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(unsigned long __n);
+ operator<<(unsigned long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(bool __n);
+ operator<<(bool __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(short __n);
+ operator<<(short __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
+ if (__fmt == ios_base::oct || __fmt == ios_base::hex)
+ return _M_insert(static_cast<long>(static_cast<unsigned short>(__n)));
+ else
+ return _M_insert(static_cast<long>(__n));
+ }
__ostream_type&
- operator<<(unsigned short __n);
+ operator<<(unsigned short __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
__ostream_type&
- operator<<(int __n);
+ operator<<(int __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
+ if (__fmt == ios_base::oct || __fmt == ios_base::hex)
+ return _M_insert(static_cast<long>(static_cast<unsigned int>(__n)));
+ else
+ return _M_insert(static_cast<long>(__n));
+ }
__ostream_type&
- operator<<(unsigned int __n);
+ operator<<(unsigned int __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
#ifdef _GLIBCXX_USE_LONG_LONG
__ostream_type&
- operator<<(long long __n);
+ operator<<(long long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(unsigned long long __n);
+ operator<<(unsigned long long __n)
+ { return _M_insert(__n); }
#endif
__ostream_type&
- operator<<(double __f);
+ operator<<(double __f)
+ { return _M_insert(__f); }
__ostream_type&
- operator<<(float __f);
+ operator<<(float __f)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<double>(__f));
+ }
__ostream_type&
- operator<<(long double __f);
+ operator<<(long double __f)
+ { return _M_insert(__f); }
__ostream_type&
- operator<<(const void* __p);
+ operator<<(const void* __p)
+ { return _M_insert(__p); }
/**
* @brief Extracting from another streambuf.
@@ -339,6 +380,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
protected:
explicit
basic_ostream() { }
+
+ template<typename _ValueT>
+ __ostream_type&
+ _M_insert(_ValueT __v);
};
/**
OpenPOWER on IntegriCloud