diff options
author | Paolo Carlini <pcarlini@suse.de> | 2006-01-24 00:06:15 +0000 |
---|---|---|
committer | Paolo Carlini <pcarlini@suse.de> | 2006-01-24 00:06:15 +0000 |
commit | fa9355fda7c8ff35f87923e394be801a275a05ef (patch) | |
tree | a068224a1d895a1051142f39d1f833bef104b313 /libstdc++-v3/include/std | |
parent | 9e9f6f4b8ac43b3acdbbcfdc13e4aa80e74b9d23 (diff) |
2006-01-23 Paolo Carlini <pcarlini@suse.de>
Merged to mainline at revision 110135.
(adjusted include/c_std/cmath.tcc vs _GLIBCXX_BEGIN_NAMESPACE;
roughly merged in gnu.ver symbols)
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/libstdcxx_so_7-branch@110151 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r-- | libstdc++-v3/include/std/std_bitset.h | 61 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_istream.h | 73 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_ostream.h | 71 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_valarray.h | 12 |
4 files changed, 173 insertions, 44 deletions
diff --git a/libstdc++-v3/include/std/std_bitset.h b/libstdc++-v3/include/std/std_bitset.h index c1cfadad7bd..ad47238ed62 100644 --- a/libstdc++-v3/include/std/std_bitset.h +++ b/libstdc++-v3/include/std/std_bitset.h @@ -1144,19 +1144,20 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) template<size_t _Nb> template<class _CharT, class _Traits, class _Alloc> void - bitset<_Nb>::_M_copy_from_string(const std::basic_string<_CharT, _Traits, - _Alloc>& __s, size_t __pos, size_t __n) + bitset<_Nb>:: + _M_copy_from_string(const std::basic_string<_CharT, _Traits, + _Alloc>& __s, size_t __pos, size_t __n) { reset(); const size_t __nbits = std::min(_Nb, std::min(__n, __s.size() - __pos)); - for (size_t __i = 0; __i < __nbits; ++__i) + for (size_t __i = __nbits; __i > 0; --__i) { - switch(__s[__pos + __nbits - __i - 1]) + switch(__s[__pos + __nbits - __i]) { case '0': break; case '1': - set(__i); + set(__i - 1); break; default: __throw_invalid_argument(__N("bitset::_M_copy_from_string")); @@ -1167,13 +1168,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) template<size_t _Nb> template<class _CharT, class _Traits, class _Alloc> void - bitset<_Nb>::_M_copy_to_string(std::basic_string<_CharT, _Traits, - _Alloc>& __s) const + bitset<_Nb>:: + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s) const { __s.assign(_Nb, '0'); - for (size_t __i = 0; __i < _Nb; ++__i) - if (_Unchecked_test(__i)) - __s[_Nb - 1 - __i] = '1'; + for (size_t __i = _Nb; __i > 0; --__i) + if (_Unchecked_test(__i - 1)) + __s[_Nb - __i] = '1'; } // 23.3.5.3 bitset operations: @@ -1242,7 +1243,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) // 303. Bitset input operator underspecified const char_type __zero = __is.widen('0'); const char_type __one = __is.widen('1'); - for (size_t __i = 0; __i < _Nb; ++__i) + for (size_t __i = _Nb; __i > 0; --__i) { static typename _Traits::int_type __eof = _Traits::eof(); @@ -1290,6 +1291,44 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) __x._M_copy_to_string(__tmp); return __os << __tmp; } + + // Specializations for zero-sized bitsets, to avoid "unsigned comparison + // with zero" warnings. + template<> + inline bitset<0>& + bitset<0>:: + set(size_t, bool) + { + __throw_out_of_range(__N("bitset::set")); + return *this; + } + + template<> + inline bitset<0>& + bitset<0>:: + reset(size_t) + { + __throw_out_of_range(__N("bitset::reset")); + return *this; + } + + template<> + inline bitset<0>& + bitset<0>:: + flip(size_t) + { + __throw_out_of_range(__N("bitset::flip")); + return *this; + } + + template<> + inline bool + bitset<0>:: + test(size_t) const + { + __throw_out_of_range(__N("bitset::test")); + return false; + } //@} _GLIBCXX_END_NESTED_NAMESPACE 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); }; /** diff --git a/libstdc++-v3/include/std/std_valarray.h b/libstdc++-v3/include/std/std_valarray.h index 82b2fb891a7..ada7aea4062 100644 --- a/libstdc++-v3/include/std/std_valarray.h +++ b/libstdc++-v3/include/std/std_valarray.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- valarray class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -583,7 +583,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) valarray<_Tp>::valarray(const slice_array<_Tp>& __sa) : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz)) { - std::__valarray_copy + std::__valarray_copy_construct (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); } @@ -593,7 +593,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : _M_size(__ga._M_index.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) { - std::__valarray_copy + std::__valarray_copy_construct (__ga._M_array, _Array<size_t>(__ga._M_index), _Array<_Tp>(_M_data), _M_size); } @@ -603,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) valarray<_Tp>::valarray(const mask_array<_Tp>& __ma) : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) { - std::__valarray_copy + std::__valarray_copy_construct (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); } @@ -612,7 +612,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia) : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz)) { - std::__valarray_copy + std::__valarray_copy_construct (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); } @@ -620,7 +620,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e) : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) - { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); } + { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); } template<typename _Tp> inline |