From 49d5c016dae45d256509c0ea80c983e431dce5cd Mon Sep 17 00:00:00 2001 From: Paolo Carlini <pcarlini@suse.de> Date: Mon, 2 Jan 2006 09:57:49 +0000 Subject: [PATCH] re PR libstdc++/24645 (Commonize arithmetic inserters/extractors bodies) 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. From-SVN: r109236 --- libstdc++-v3/ChangeLog | 24 ++ libstdc++-v3/config/abi/pre/gnu.ver | 132 +++++++--- libstdc++-v3/include/bits/istream.tcc | 325 ++--------------------- libstdc++-v3/include/bits/ostream.tcc | 350 ++----------------------- libstdc++-v3/include/std/std_istream.h | 73 +++++- libstdc++-v3/include/std/std_ostream.h | 71 ++++- libstdc++-v3/src/istream-inst.cc | 28 ++ libstdc++-v3/src/ostream-inst.cc | 24 +- 8 files changed, 327 insertions(+), 700 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ef546e60d770..a673370c60a1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,27 @@ +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. + 2005-12-28 Paolo Carlini <pcarlini@suse.de> * docs/html/ext/lwg-active.html, lwg-defects.html: Import Revision 40. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index c76bdf94850e..831951d0d695 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -42,7 +42,10 @@ GLIBCXX_3.4 { std::basic_[j-n]*; std::basic_o[a-e]*; # std::basic_ofstream; - std::basic_o[g-z]*; +# std::basic_o[g-z]*; + std::basic_o[g-r]*; + std::basic_ostr[a-d]*; + std::basic_ostr[f-z]*; std::basic_[p-r]*; std::basic_streambuf*; # std::basic_string @@ -86,7 +89,12 @@ GLIBCXX_3.4 { std::locale::_[J-Ra-z]*; std::locale::_S_normalize_category*; std::locale::_[T-Za-z]*; - std::[A-Zm-r]*; +# std::[A-Zm-r]*; + std::[A-Zm-n]*; + std::[p-r]*; + std::ostrstream*; + std::out_of_range*; + std::overflow_error*; std::set_new_handler*; std::set_terminate*; std::set_unexpected*; @@ -257,7 +265,7 @@ GLIBCXX_3.4 { _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreE[il][ijlm]; _ZNSt13basic_istreamIwSt11char_traitsIwEErsE*; - # std::istream operators and inserters + # std::istream operators and extractors _ZSt7getlineI[cw]St11char_traitsI[cw]ESaI[cw]EERSt13basic_istream*; _ZSt2wsI[cw]St11char_traitsI[cw]EE*; _ZStrsI[cw]St11char_traitsI[cw]EERSt13basic_istream*; @@ -267,6 +275,37 @@ GLIBCXX_3.4 { _ZStrsIe[cw]St11char_traitsI[cw]EERSt13basic_istream*; _ZStrsIf[cw]St11char_traitsI[cw]EERSt13basic_istream*; + # std::basic_ostream<char> + _ZNSoC*; + _ZNSoD*; + _ZNKSo6sentrycvbEv; + _ZNSo8_M_write*; + _ZNSo[0-9][a-z]*; + _ZNSolsE*; + + # std::basic_ostream<wchar_t> + _ZNSt13basic_ostreamIwSt11char_traitsIwEEC*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEED*; + _ZNKSt13basic_ostreamIwSt11char_traitsIwEE[0-9][a-z]*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE5seekpE*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE5tellpEv; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE5writeEPKw*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE6sentry*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE8_M_write*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEElsE*; + + # std::ostream operators and inserters + _ZSt4end[ls]I[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + _ZSt5flushI[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + _ZStlsI[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + _ZStlsI[cw]St11char_traitsI[cw]ESaI[cw]EERSt13basic_ostream*; + _ZStlsISt11char_traitsI[cw]EERSt13basic_ostream*; + _ZStlsId[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + _ZStlsIe[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + _ZStlsIf[cw]St11char_traitsI[cw]EERSt13basic_ostream*; + # std::locale destructors _ZNSt6localeD*; @@ -287,9 +326,15 @@ GLIBCXX_3.4 { # std::num_get _ZNKSt7num_getI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEE*; + # std::num_put + _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE*; + # std::money_get _ZNKSt9money_getI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEE*; + # std::money_put + _ZNKSt9money_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE*; + # std::_Rb_tree _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base; _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base; @@ -328,25 +373,25 @@ GLIBCXX_3.4 { _ZN9__gnu_cxx18__exchange_and_add*; # __gnu_debug -_ZN10__gnu_norm15_List_node_base4hookEPS0_; -_ZN10__gnu_norm15_List_node_base4swapERS0_S1_; -_ZN10__gnu_norm15_List_node_base6unhookEv; -_ZN10__gnu_norm15_List_node_base7reverseEv; -_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_; -_ZN11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb; -_ZN11__gnu_debug19_Safe_iterator_base9_M_detachEv; -_ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv; -_ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_; -_ZN11__gnu_debug19_Safe_sequence_base13_M_detach_allEv; -_ZN11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv; -_ZN11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv; -_ZN11__gnu_debug19_Safe_sequence_base7_M_swapERS0_; -_ZNK11__gnu_debug16_Error_formatter8_M_errorEv; -_ZNK11__gnu_debug16_Error_formatter10_M_messageENS_13_Debug_msg_idE; -_ZNK11__gnu_debug16_Error_formatter10_Parameter14_M_print_fieldEPKS0_PKc; -_ZNK11__gnu_debug16_Error_formatter10_Parameter20_M_print_descriptionEPKS0_; -_ZNK11__gnu_debug16_Error_formatter13_M_print_wordEPKc; -_ZNK11__gnu_debug16_Error_formatter15_M_print_stringEPKc; + _ZN10__gnu_norm15_List_node_base4hookEPS0_; + _ZN10__gnu_norm15_List_node_base4swapERS0_S1_; + _ZN10__gnu_norm15_List_node_base6unhookEv; + _ZN10__gnu_norm15_List_node_base7reverseEv; + _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_; + _ZN11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb; + _ZN11__gnu_debug19_Safe_iterator_base9_M_detachEv; + _ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv; + _ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_; + _ZN11__gnu_debug19_Safe_sequence_base13_M_detach_allEv; + _ZN11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv; + _ZN11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv; + _ZN11__gnu_debug19_Safe_sequence_base7_M_swapERS0_; + _ZNK11__gnu_debug16_Error_formatter8_M_errorEv; + _ZNK11__gnu_debug16_Error_formatter10_M_messageENS_13_Debug_msg_idE; + _ZNK11__gnu_debug16_Error_formatter10_Parameter14_M_print_fieldEPKS0_PKc; + _ZNK11__gnu_debug16_Error_formatter10_Parameter20_M_print_descriptionEPKS0_; + _ZNK11__gnu_debug16_Error_formatter13_M_print_wordEPKc; + _ZNK11__gnu_debug16_Error_formatter15_M_print_stringEPKc; # operator new(size_t) _Znw[jm]; @@ -596,25 +641,30 @@ GLIBCXX_3.4.7 { _ZNSt6locale5_Impl16_M_install_cacheEPKNS_5facetE[jm]; -_ZNSt10__gnu_norm15_List_node_base4hookEPS0_; -_ZNSt10__gnu_norm15_List_node_base4swapERS0_S1_; -_ZNSt10__gnu_norm15_List_node_base6unhookEv; -_ZNSt10__gnu_norm15_List_node_base7reverseEv; -_ZNSt10__gnu_norm15_List_node_base8transferEPS0_S1_; -_ZNKSt11__gnu_debug16_Error_formatter8_M_errorEv; -_ZNKSt11__gnu_debug16_Error_formatter10_M_messageENS_13_Debug_msg_idE; -_ZNKSt11__gnu_debug16_Error_formatter10_Parameter14_M_print_fieldEPKS0_PKc; -_ZNKSt11__gnu_debug16_Error_formatter10_Parameter20_M_print_descriptionEPKS0_; -_ZNKSt11__gnu_debug16_Error_formatter13_M_print_wordEPKc; -_ZNKSt11__gnu_debug16_Error_formatter15_M_print_stringEPKc; -_ZNKSt11__gnu_debug19_Safe_iterator_base11_M_singularEv; -_ZNKSt11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_; -_ZNSt11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb; -_ZNSt11__gnu_debug19_Safe_iterator_base9_M_detachEv; -_ZNSt11__gnu_debug19_Safe_sequence_base13_M_detach_allEv; -_ZNSt11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv; -_ZNSt11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv; -_ZNSt11__gnu_debug19_Safe_sequence_base7_M_swapERS0_; + _ZNSt10__gnu_norm15_List_node_base4hookEPS0_; + _ZNSt10__gnu_norm15_List_node_base4swapERS0_S1_; + _ZNSt10__gnu_norm15_List_node_base6unhookEv; + _ZNSt10__gnu_norm15_List_node_base7reverseEv; + _ZNSt10__gnu_norm15_List_node_base8transferEPS0_S1_; + _ZNKSt11__gnu_debug16_Error_formatter8_M_errorEv; + _ZNKSt11__gnu_debug16_Error_formatter10_M_messageENS_13_Debug_msg_idE; + _ZNKSt11__gnu_debug16_Error_formatter10_Parameter14_M_print_fieldEPKS0_PKc; + _ZNKSt11__gnu_debug16_Error_formatter10_Parameter20_M_print_descriptionEPKS0_; + _ZNKSt11__gnu_debug16_Error_formatter13_M_print_wordEPKc; + _ZNKSt11__gnu_debug16_Error_formatter15_M_print_stringEPKc; + _ZNKSt11__gnu_debug19_Safe_iterator_base11_M_singularEv; + _ZNKSt11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_; + _ZNSt11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb; + _ZNSt11__gnu_debug19_Safe_iterator_base9_M_detachEv; + _ZNSt11__gnu_debug19_Safe_sequence_base13_M_detach_allEv; + _ZNSt11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv; + _ZNSt11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv; + _ZNSt11__gnu_debug19_Safe_sequence_base7_M_swapERS0_; + + _ZNSo9_M_insertI*; + _ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertI*; + _ZNSi10_M_extractI*; + _ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractI*; } GLIBCXX_3.4.6; diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 541e75afb801..184c2bd613fc 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 1642583845fa..7b80495c7e86 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 2c5c572286a3..659d3e2a2d70 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 8d4228238e7a..8dc398ed0ef3 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); }; /** diff --git a/libstdc++-v3/src/istream-inst.cc b/libstdc++-v3/src/istream-inst.cc index d71314d3d995..2e5c7d344187 100644 --- a/libstdc++-v3/src/istream-inst.cc +++ b/libstdc++-v3/src/istream-inst.cc @@ -53,6 +53,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template istream& operator>>(istream&, _Setprecision); template istream& operator>>(istream&, _Setw); + template istream& istream::_M_extract(unsigned short&); + template istream& istream::_M_extract(unsigned int&); + template istream& istream::_M_extract(long&); + template istream& istream::_M_extract(unsigned long&); + template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + template istream& istream::_M_extract(long long&); + template istream& istream::_M_extract(unsigned long long&); +#endif + template istream& istream::_M_extract(float&); + template istream& istream::_M_extract(double&); + template istream& istream::_M_extract(long double&); + template istream& istream::_M_extract(void*&); + #ifdef _GLIBCXX_USE_WCHAR_T template class basic_istream<wchar_t>; template wistream& ws(wistream&); @@ -65,6 +79,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template wistream& operator>>(wistream&, _Setbase); template wistream& operator>>(wistream&, _Setprecision); template wistream& operator>>(wistream&, _Setw); + + template wistream& wistream::_M_extract(unsigned short&); + template wistream& wistream::_M_extract(unsigned int&); + template wistream& wistream::_M_extract(long&); + template wistream& wistream::_M_extract(unsigned long&); + template wistream& wistream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + template wistream& wistream::_M_extract(long long&); + template wistream& wistream::_M_extract(unsigned long long&); +#endif + template wistream& wistream::_M_extract(float&); + template wistream& wistream::_M_extract(double&); + template wistream& wistream::_M_extract(long double&); + template wistream& wistream::_M_extract(void*&); #endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/src/ostream-inst.cc b/libstdc++-v3/src/ostream-inst.cc index 4568dca5cde3..70df37beb76d 100644 --- a/libstdc++-v3/src/ostream-inst.cc +++ b/libstdc++-v3/src/ostream-inst.cc @@ -1,6 +1,6 @@ // Explicit instantiation file. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2005 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -56,6 +56,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template ostream& operator<<(ostream&, _Setprecision); template ostream& operator<<(ostream&, _Setw); + template ostream& ostream::_M_insert(long); + template ostream& ostream::_M_insert(unsigned long); + template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + template ostream& ostream::_M_insert(long long); + template ostream& ostream::_M_insert(unsigned long long); +#endif + template ostream& ostream::_M_insert(double); + template ostream& ostream::_M_insert(long double); + template ostream& ostream::_M_insert(const void*); + #ifdef _GLIBCXX_USE_WCHAR_T template class basic_ostream<wchar_t>; template wostream& endl(wostream&); @@ -72,6 +83,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template wostream& operator<<(wostream&, _Setbase); template wostream& operator<<(wostream&, _Setprecision); template wostream& operator<<(wostream&, _Setw); + + template wostream& wostream::_M_insert(long); + template wostream& wostream::_M_insert(unsigned long); + template wostream& wostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + template wostream& wostream::_M_insert(long long); + template wostream& wostream::_M_insert(unsigned long long); +#endif + template wostream& wostream::_M_insert(double); + template wostream& wostream::_M_insert(long double); + template wostream& wostream::_M_insert(const void*); #endif _GLIBCXX_END_NAMESPACE -- GitLab