diff options
| author | Alexander Kabaev <kan@FreeBSD.org> | 2004-07-28 03:12:05 +0000 |
|---|---|---|
| committer | Alexander Kabaev <kan@FreeBSD.org> | 2004-07-28 03:12:05 +0000 |
| commit | ffeaf689a248da869b6bc8d4fd2233dfe513c060 (patch) | |
| tree | 75ef0e6da73746d6849e25a0996ae34e1aeff51d /contrib/libstdc++/include/std | |
| parent | 9a63ad9273061dc19cbd117762e365ea9634e241 (diff) | |
Notes
Diffstat (limited to 'contrib/libstdc++/include/std')
29 files changed, 1596 insertions, 1155 deletions
diff --git a/contrib/libstdc++/include/std/std_algorithm.h b/contrib/libstdc++/include/std/std_algorithm.h index bcc0c8a70cda..40e6246ce7f9 100644 --- a/contrib/libstdc++/include/std/std_algorithm.h +++ b/contrib/libstdc++/include/std/std_algorithm.h @@ -58,8 +58,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_ALGORITHM -#define _CPP_ALGORITHM 1 +#ifndef _GLIBCXX_ALGORITHM +#define _GLIBCXX_ALGORITHM 1 #pragma GCC system_header @@ -68,8 +68,4 @@ #include <bits/stl_uninitialized.h> #include <bits/stl_algo.h> -#endif /* _CPP_ALGORITHM */ - -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_ALGORITHM */ diff --git a/contrib/libstdc++/include/std/std_bitset.h b/contrib/libstdc++/include/std/std_bitset.h index ebe16504d188..01e3f904e470 100644 --- a/contrib/libstdc++/include/std/std_bitset.h +++ b/contrib/libstdc++/include/std/std_bitset.h @@ -1,6 +1,6 @@ // <bitset> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -45,29 +45,26 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _GLIBCPP_BITSET_H -#define _GLIBCPP_BITSET_H +#ifndef _GLIBCXX_BITSET +#define _GLIBCXX_BITSET 1 #pragma GCC system_header -#include <cstddef> // for size_t -#include <cstring> // for memset +#include <cstddef> // For size_t +#include <cstring> // For memset +#include <limits> // For numeric_limits #include <string> -#include <bits/functexcept.h> // for invalid_argument, out_of_range, +#include <bits/functexcept.h> // For invalid_argument, out_of_range, // overflow_error -#include <ostream> // for ostream (operator<<) -#include <istream> // for istream (operator>>) +#include <ostream> // For ostream (operator<<) +#include <istream> // For istream (operator>>) +#define _GLIBCXX_BITSET_BITS_PER_WORD numeric_limits<unsigned long>::digits +#define _GLIBCXX_BITSET_WORDS(__n) \ + ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1)/_GLIBCXX_BITSET_BITS_PER_WORD) -#define _GLIBCPP_BITSET_BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long)) -#define _GLIBCPP_BITSET_WORDS(__n) \ - ((__n) < 1 ? 0 : ((__n) + _GLIBCPP_BITSET_BITS_PER_WORD - 1)/_GLIBCPP_BITSET_BITS_PER_WORD) - -namespace std +namespace _GLIBCXX_STD { - extern unsigned char _S_bit_count[256]; - extern unsigned char _S_first_one[256]; - /** * @if maint * Base class, general case. It is a class inveriant that _Nw will be @@ -93,15 +90,15 @@ namespace std static size_t _S_whichword(size_t __pos ) - { return __pos / _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static size_t _S_whichbyte(size_t __pos ) - { return (__pos % _GLIBCPP_BITSET_BITS_PER_WORD) / CHAR_BIT; } + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static size_t _S_whichbit(size_t __pos ) - { return __pos % _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _WordT _S_maskbit(size_t __pos ) @@ -191,14 +188,8 @@ namespace std _M_do_count() const { size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)_M_w; - const unsigned char* __end_ptr = (const unsigned char*)(_M_w + _Nw); - - while ( __byte_ptr < __end_ptr ) - { - __result += _S_bit_count[*__byte_ptr]; - __byte_ptr++; - } + for (size_t __i = 0; __i < _Nw; __i++) + __result += __builtin_popcountl(_M_w[__i]); return __result; } @@ -221,22 +212,22 @@ namespace std { if (__builtin_expect(__shift != 0, 1)) { - const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD; - const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD; + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; if (__offset == 0) for (size_t __n = _Nw - 1; __n >= __wshift; --__n) _M_w[__n] = _M_w[__n - __wshift]; else { - const size_t __sub_offset = _GLIBCPP_BITSET_BITS_PER_WORD - __offset; + const size_t __sub_offset = _GLIBCXX_BITSET_BITS_PER_WORD - __offset; for (size_t __n = _Nw - 1; __n > __wshift; --__n) _M_w[__n] = (_M_w[__n - __wshift] << __offset) | (_M_w[__n - __wshift - 1] >> __sub_offset); _M_w[__wshift] = _M_w[0] << __offset; } - fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); + std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); } } @@ -246,8 +237,8 @@ namespace std { if (__builtin_expect(__shift != 0, 1)) { - const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD; - const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD; + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; const size_t __limit = _Nw - __wshift - 1; if (__offset == 0) @@ -255,14 +246,14 @@ namespace std _M_w[__n] = _M_w[__n + __wshift]; else { - const size_t __sub_offset = _GLIBCPP_BITSET_BITS_PER_WORD - __offset; + const size_t __sub_offset = _GLIBCXX_BITSET_BITS_PER_WORD - __offset; for (size_t __n = 0; __n < __limit; ++__n) _M_w[__n] = (_M_w[__n + __wshift] >> __offset) | (_M_w[__n + __wshift + 1] << __sub_offset); _M_w[__limit] = _M_w[_Nw-1] >> __offset; } - - fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); + + std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); } } @@ -272,7 +263,7 @@ namespace std { for (size_t __i = 1; __i < _Nw; ++__i) if (_M_w[__i]) - __throw_overflow_error("bitset -- too large to fit in unsigned long"); + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong")); return _M_w[0]; } @@ -280,23 +271,12 @@ namespace std size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const { - for (size_t __i = 0; __i < _Nw; __i++ ) + for (size_t __i = 0; __i < _Nw; __i++) { _WordT __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) - { - // find byte within word - for (size_t __j = 0; __j < sizeof(_WordT); __j++ ) - { - unsigned char __this_byte - = static_cast<unsigned char>(__thisword & (~(unsigned char)0)); - if (__this_byte) - return __i*_GLIBCPP_BITSET_BITS_PER_WORD + __j*CHAR_BIT + - _S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } + if (__thisword != static_cast<_WordT>(0)) + return __i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword); } // not found, so return an indication of failure. return __not_found; @@ -310,7 +290,7 @@ namespace std ++__prev; // check out of bounds - if ( __prev >= _Nw * _GLIBCPP_BITSET_BITS_PER_WORD ) + if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD) return __not_found; // search first word @@ -320,42 +300,18 @@ namespace std // mask off bits below bound __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); - if ( __thisword != static_cast<_WordT>(0) ) - { - // find byte within word - // get first byte into place - __thisword >>= _S_whichbyte(__prev) * CHAR_BIT; - for (size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++) - { - unsigned char __this_byte - = static_cast<unsigned char>(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*_GLIBCPP_BITSET_BITS_PER_WORD + __j*CHAR_BIT + - _S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } + if (__thisword != static_cast<_WordT>(0)) + return __i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword); // check subsequent words __i++; for ( ; __i < _Nw; __i++ ) { __thisword = _M_w[__i]; - if ( __thisword != static_cast<_WordT>(0) ) - { - // find byte within word - for (size_t __j = 0; __j < sizeof(_WordT); __j++ ) - { - unsigned char __this_byte - = static_cast<unsigned char>(__thisword & (~(unsigned char)0)); - if ( __this_byte ) - return __i*_GLIBCPP_BITSET_BITS_PER_WORD + __j*CHAR_BIT + - _S_first_one[__this_byte]; - - __thisword >>= CHAR_BIT; - } - } + if (__thisword != static_cast<_WordT>(0)) + return __i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword); } // not found, so return an indication of failure. return __not_found; @@ -380,15 +336,15 @@ namespace std static size_t _S_whichword(size_t __pos ) - { return __pos / _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static size_t _S_whichbyte(size_t __pos ) - { return (__pos % _GLIBCPP_BITSET_BITS_PER_WORD) / CHAR_BIT; } + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static size_t _S_whichbit(size_t __pos ) - { return __pos % _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _WordT _S_maskbit(size_t __pos ) @@ -438,29 +394,34 @@ namespace std _M_is_any() const { return _M_w != 0; } size_t - _M_do_count() const - { - size_t __result = 0; - const unsigned char* __byte_ptr = (const unsigned char*)&_M_w; - const unsigned char* __end_ptr - = ((const unsigned char*)&_M_w)+sizeof(_M_w); - while ( __byte_ptr < __end_ptr ) - { - __result += _S_bit_count[*__byte_ptr]; - __byte_ptr++; - } - return __result; - } + _M_do_count() const { return __builtin_popcountl(_M_w); } unsigned long _M_do_to_ulong() const { return _M_w; } size_t - _M_do_find_first(size_t __not_found) const; + _M_do_find_first(size_t __not_found) const + { + if (_M_w != 0) + return __builtin_ctzl(_M_w); + else + return __not_found; + } // find the next "on" bit that follows "prev" size_t - _M_do_find_next(size_t __prev, size_t __not_found) const; + _M_do_find_next(size_t __prev, size_t __not_found) const + { + ++__prev; + if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD)) + return __not_found; + + _WordT __x = _M_w >> __prev; + if (__x != 0) + return __builtin_ctzl(__x) + __prev; + else + return __not_found; + } }; @@ -481,15 +442,15 @@ namespace std static size_t _S_whichword(size_t __pos ) - { return __pos / _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } static size_t _S_whichbyte(size_t __pos ) - { return (__pos % _GLIBCPP_BITSET_BITS_PER_WORD) / CHAR_BIT; } + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } static size_t _S_whichbit(size_t __pos ) - { return __pos % _GLIBCPP_BITSET_BITS_PER_WORD; } + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } static _WordT _S_maskbit(size_t __pos ) @@ -504,7 +465,10 @@ namespace std // localized to this single should-never-get-this-far function. _WordT& _M_getword(size_t) const - { __throw_out_of_range("bitset -- zero-length"); return *new _WordT; } + { + __throw_out_of_range(__N("_Base_bitset::_M_getword")); + return *new _WordT; + } _WordT _M_hiword() const { return 0; } @@ -636,16 +600,16 @@ namespace std * @endif */ template<size_t _Nb> - class bitset : private _Base_bitset<_GLIBCPP_BITSET_WORDS(_Nb)> + class bitset : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> { private: - typedef _Base_bitset<_GLIBCPP_BITSET_WORDS(_Nb)> _Base; + typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base; typedef unsigned long _WordT; void _M_do_sanitize() { - _Sanitize<_Nb%_GLIBCPP_BITSET_BITS_PER_WORD>:: + _Sanitize<_Nb%_GLIBCXX_BITSET_BITS_PER_WORD>:: _S_do_sanitize(this->_M_hiword()); } @@ -681,7 +645,7 @@ namespace std ~reference() { } - // for b[i] = __x; + // For b[i] = __x; reference& operator=(bool __x) { @@ -692,7 +656,7 @@ namespace std return *this; } - // for b[i] = b[__j]; + // For b[i] = b[__j]; reference& operator=(const reference& __j) { @@ -703,16 +667,16 @@ namespace std return *this; } - // flips the bit + // Flips the bit bool operator~() const { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } - // for __x = b[i]; + // For __x = b[i]; operator bool() const { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } - // for b[i].flip(); + // For b[i].flip(); reference& flip() { @@ -733,7 +697,7 @@ namespace std /** * @brief Use a subset of a string. * @param s A string of '0' and '1' characters. - * @param pos Index of the first character in @a s to use; defaults + * @param position Index of the first character in @a s to use; defaults * to zero. * @throw std::out_of_range If @a pos is bigger the size of @a s. * @throw std::invalid_argument If a character appears in the string @@ -741,19 +705,19 @@ namespace std */ template<class _CharT, class _Traits, class _Alloc> explicit bitset(const basic_string<_CharT, _Traits, _Alloc>& __s, - size_t __pos = 0) : _Base() + size_t __position = 0) : _Base() { - if (__pos > __s.size()) - __throw_out_of_range("bitset -- initial position is larger than " - "the string itself"); - _M_copy_from_string(__s, __pos, + if (__position > __s.size()) + __throw_out_of_range(__N("bitset::bitset initial position " + "not valid")); + _M_copy_from_string(__s, __position, basic_string<_CharT, _Traits, _Alloc>::npos); } /** * @brief Use a subset of a string. * @param s A string of '0' and '1' characters. - * @param pos Index of the first character in @a s to use. + * @param position Index of the first character in @a s to use. * @param n The number of characters to copy. * @throw std::out_of_range If @a pos is bigger the size of @a s. * @throw std::invalid_argument If a character appears in the string @@ -761,12 +725,12 @@ namespace std */ template<class _CharT, class _Traits, class _Alloc> bitset(const basic_string<_CharT, _Traits, _Alloc>& __s, - size_t __pos, size_t __n) : _Base() + size_t __position, size_t __n) : _Base() { - if (__pos > __s.size()) - __throw_out_of_range("bitset -- initial position is larger than " - "the string itself"); - _M_copy_from_string(__s, __pos, __n); + if (__position > __s.size()) + __throw_out_of_range(__N("bitset::bitset initial position " + "not valid")); + _M_copy_from_string(__s, __position, __n); } // 23.3.5.2 bitset operations: @@ -802,16 +766,16 @@ namespace std //@{ /** * @brief Operations on bitsets. - * @param pos The number of places to shift. + * @param position The number of places to shift. * * These should be self-explanatory. */ bitset<_Nb>& - operator<<=(size_t __pos) + operator<<=(size_t __position) { - if (__builtin_expect(__pos < _Nb, 1)) + if (__builtin_expect(__position < _Nb, 1)) { - this->_M_do_left_shift(__pos); + this->_M_do_left_shift(__position); this->_M_do_sanitize(); } else @@ -820,11 +784,11 @@ namespace std } bitset<_Nb>& - operator>>=(size_t __pos) + operator>>=(size_t __position) { - if (__builtin_expect(__pos < _Nb, 1)) + if (__builtin_expect(__position < _Nb, 1)) { - this->_M_do_right_shift(__pos); + this->_M_do_right_shift(__position); this->_M_do_sanitize(); } else @@ -892,16 +856,16 @@ namespace std /** * @brief Sets a given bit to a particular value. - * @param pos The index of the bit. + * @param position The index of the bit. * @param val Either true or false, defaults to true. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bitset<_Nb>& - set(size_t __pos, bool __val = true) + set(size_t __position, bool __val = true) { - if (__pos >= _Nb) - __throw_out_of_range("bitset -- set() argument too large"); - return _Unchecked_set(__pos, __val); + if (__position >= _Nb) + __throw_out_of_range(__N("bitset::set")); + return _Unchecked_set(__position, __val); } /** @@ -916,17 +880,17 @@ namespace std /** * @brief Sets a given bit to false. - * @param pos The index of the bit. + * @param position The index of the bit. * @throw std::out_of_range If @a pos is bigger the size of the %set. * * Same as writing @c set(pos,false). */ bitset<_Nb>& - reset(size_t __pos) + reset(size_t __position) { - if (__pos >= _Nb) - __throw_out_of_range("bitset -- reset() argument too large"); - return _Unchecked_reset(__pos); + if (__position >= _Nb) + __throw_out_of_range(__N("bitset::reset")); + return _Unchecked_reset(__position); } /** @@ -942,15 +906,15 @@ namespace std /** * @brief Toggles a given bit to its opposite value. - * @param pos The index of the bit. + * @param position The index of the bit. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bitset<_Nb>& - flip(size_t __pos) + flip(size_t __position) { - if (__pos >= _Nb) - __throw_out_of_range("bitset -- flip() argument too large"); - return _Unchecked_flip(__pos); + if (__position >= _Nb) + __throw_out_of_range(__N("bitset::flip")); + return _Unchecked_flip(__position); } /// See the no-argument flip(). @@ -960,14 +924,14 @@ namespace std //@{ /** * @brief Array-indexing support. - * @param pos Index into the %bitset. + * @param position Index into the %bitset. * @return A bool for a 'const %bitset'. For non-const bitsets, an * instance of the reference proxy class. * @note These operators do no range checking and throw no exceptions, * as required by DR 11 to the standard. * * @if maint - * _GLIBCPP_RESOLVE_LIB_DEFECTS Note that this implementation already + * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already * resolves DR 11 (items 1 and 2), but does not do the range-checking * required by that DR's resolution. -pme * The DR has since been changed: range-checking is a precondition @@ -975,10 +939,10 @@ namespace std * @endif */ reference - operator[](size_t __pos) { return reference(*this,__pos); } + operator[](size_t __position) { return reference(*this,__position); } bool - operator[](size_t __pos) const { return _Unchecked_test(__pos); } + operator[](size_t __position) const { return _Unchecked_test(__position); } //@} /** @@ -1044,16 +1008,16 @@ namespace std /** * @brief Tests the value of a bit. - * @param pos The index of a bit. + * @param position The index of a bit. * @return The value at @a pos. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ bool - test(size_t __pos) const + test(size_t __position) const { - if (__pos >= _Nb) - __throw_out_of_range("bitset -- test() argument too large"); - return _Unchecked_test(__pos); + if (__position >= _Nb) + __throw_out_of_range(__N("bitset::test")); + return _Unchecked_test(__position); } /** @@ -1073,12 +1037,12 @@ namespace std //@{ /// Self-explanatory. bitset<_Nb> - operator<<(size_t __pos) const - { return bitset<_Nb>(*this) <<= __pos; } + operator<<(size_t __position) const + { return bitset<_Nb>(*this) <<= __position; } bitset<_Nb> - operator>>(size_t __pos) const - { return bitset<_Nb>(*this) >>= __pos; } + operator>>(size_t __position) const + { return bitset<_Nb>(*this) >>= __position; } //@} /** @@ -1107,10 +1071,11 @@ namespace std template<size_t _Nb> template<class _CharT, class _Traits, class _Alloc> void - bitset<_Nb>::_M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s, size_t __pos, size_t __n) + bitset<_Nb>::_M_copy_from_string(const basic_string<_CharT, _Traits, + _Alloc>& __s, size_t __pos, size_t __n) { reset(); - const size_t __nbits = min(_Nb, min(__n, __s.size() - __pos)); + const size_t __nbits = std::min(_Nb, std::min(__n, __s.size() - __pos)); for (size_t __i = 0; __i < __nbits; ++__i) { switch(__s[__pos + __nbits - __i - 1]) @@ -1121,8 +1086,7 @@ namespace std set(__i); break; default: - __throw_invalid_argument("bitset -- string contains characters " - "which are neither 0 nor 1"); + __throw_invalid_argument(__N("bitset::_M_copy_from_string")); } } } @@ -1130,7 +1094,8 @@ namespace std template<size_t _Nb> template<class _CharT, class _Traits, class _Alloc> void - bitset<_Nb>::_M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const + bitset<_Nb>::_M_copy_to_string(basic_string<_CharT, _Traits, + _Alloc>& __s) const { __s.assign(_Nb, '0'); for (size_t __i = 0; __i < _Nb; ++__i) @@ -1193,46 +1158,53 @@ namespace std basic_string<_CharT, _Traits> __tmp; __tmp.reserve(_Nb); - // Skip whitespace + ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sentry(__is); if (__sentry) { - ios_base::iostate __state = ios_base::goodbit; - basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); - for (size_t __i = 0; __i < _Nb; ++__i) + try { - static typename _Traits::int_type __eof = _Traits::eof(); - - typename _Traits::int_type __c1 = __buf->sbumpc(); - if (_Traits::eq_int_type(__c1, __eof)) - { - __state |= ios_base::eofbit; - break; - } - else + basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 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) { - char_type __c2 = _Traits::to_char_type(__c1); - char_type __c = __is.narrow(__c2, '*'); - - if (__c == '0' || __c == '1') - __tmp.push_back(__c); - else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __buf->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) { - __state |= ios_base::failbit; + __state |= ios_base::eofbit; break; } + else + { + char_type __c2 = _Traits::to_char_type(__c1); + if (__c2 == __zero) + __tmp.push_back('0'); + else if (__c2 == __one) + __tmp.push_back('1'); + else if (_Traits::eq_int_type(__buf->sputbackc(__c2), + __eof)) + { + __state |= ios_base::failbit; + break; + } + } } } - - if (__tmp.empty() && !_Nb) - __state |= ios_base::failbit; - else - __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb); - - if (__state != ios_base::goodbit) - __is.setstate(__state); // may throw an exception + catch(...) + { __is._M_setstate(ios_base::badbit); } } + if (__tmp.empty() && _Nb) + __state |= ios_base::failbit; + else + __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb); + if (__state) + __is.setstate(__state); return __is; } @@ -1247,6 +1219,11 @@ namespace std //@} } // namespace std -#undef _GLIBCPP_BITSET_WORDS +#undef _GLIBCXX_BITSET_WORDS +#undef _GLIBCXX_BITSET_BITS_PER_WORD + +#ifdef _GLIBCXX_DEBUG +# include <debug/bitset> +#endif -#endif /* _GLIBCPP_BITSET_H */ +#endif /* _GLIBCXX_BITSET */ diff --git a/contrib/libstdc++/include/std/std_complex.h b/contrib/libstdc++/include/std/std_complex.h index 252070b13895..e1027f65991f 100644 --- a/contrib/libstdc++/include/std/std_complex.h +++ b/contrib/libstdc++/include/std/std_complex.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- complex number classes. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -40,8 +40,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_COMPLEX -#define _CPP_COMPLEX 1 +#ifndef _GLIBCXX_COMPLEX +#define _GLIBCXX_COMPLEX 1 #pragma GCC system_header @@ -58,78 +58,135 @@ namespace std template<> class complex<double>; template<> class complex<long double>; + /// Return magnitude of @a z. template<typename _Tp> _Tp abs(const complex<_Tp>&); + /// Return phase angle of @a z. template<typename _Tp> _Tp arg(const complex<_Tp>&); + /// Return @a z magnitude squared. template<typename _Tp> _Tp norm(const complex<_Tp>&); + /// Return complex conjugate of @a z. template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&); + /// Return complex with magnitude @a rho and angle @a theta. template<typename _Tp> complex<_Tp> polar(const _Tp&, const _Tp& = 0); // Transcendentals: + /// Return complex cosine of @a z. template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&); + /// Return complex hyperbolic cosine of @a z. template<typename _Tp> complex<_Tp> cosh(const complex<_Tp>&); + /// Return complex base e exponential of @a z. template<typename _Tp> complex<_Tp> exp(const complex<_Tp>&); + /// Return complex natural logarithm of @a z. template<typename _Tp> complex<_Tp> log(const complex<_Tp>&); + /// Return complex base 10 logarithm of @a z. template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&); + /// Return complex cosine of @a z. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int); + /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&); + /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const complex<_Tp>&); + /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&); + /// Return complex sine of @a z. template<typename _Tp> complex<_Tp> sin(const complex<_Tp>&); + /// Return complex hyperbolic sine of @a z. template<typename _Tp> complex<_Tp> sinh(const complex<_Tp>&); + /// Return complex square root of @a z. template<typename _Tp> complex<_Tp> sqrt(const complex<_Tp>&); + /// Return complex tangent of @a z. template<typename _Tp> complex<_Tp> tan(const complex<_Tp>&); + /// Return complex hyperbolic tangent of @a z. template<typename _Tp> complex<_Tp> tanh(const complex<_Tp>&); + //@} // 26.2.2 Primary template class complex + /** + * Template to represent complex numbers. + * + * Specializations for float, double, and long double are part of the + * library. Results with any other type are not guaranteed. + * + * @param Tp Type of real and imaginary values. + */ template<typename _Tp> class complex { public: + /// Value typedef. typedef _Tp value_type; + /// Default constructor. First parameter is x, second parameter is y. + /// Unspecified parameters default to 0. complex(const _Tp& = _Tp(), const _Tp & = _Tp()); - // Let's the compiler synthetize the copy constructor + // Lets the compiler synthesize the copy constructor // complex (const complex<_Tp>&); + /// Copy constructor. template<typename _Up> complex(const complex<_Up>&); - - _Tp real() const; - _Tp imag() const; + /// Return real part of complex number. + _Tp& real(); + /// Return real part of complex number. + const _Tp& real() const; + /// Return imaginary part of complex number. + _Tp& imag(); + /// Return imaginary part of complex number. + const _Tp& imag() const; + + /// Assign this complex number to scalar @a t. complex<_Tp>& operator=(const _Tp&); + /// Add @a t to this complex number. complex<_Tp>& operator+=(const _Tp&); + /// Subtract @a t from this complex number. complex<_Tp>& operator-=(const _Tp&); + /// Multiply this complex number by @a t. complex<_Tp>& operator*=(const _Tp&); + /// Divide this complex number by @a t. complex<_Tp>& operator/=(const _Tp&); - // Let's the compiler synthetize the + // Lets the compiler synthesize the // copy and assignment operator // complex<_Tp>& operator= (const complex<_Tp>&); + /// Assign this complex number to complex @a z. template<typename _Up> complex<_Tp>& operator=(const complex<_Up>&); + /// Add @a z to this complex number. template<typename _Up> complex<_Tp>& operator+=(const complex<_Up>&); + /// Subtract @a z from this complex number. template<typename _Up> complex<_Tp>& operator-=(const complex<_Up>&); + /// Multiply this complex number by @a z. template<typename _Up> complex<_Tp>& operator*=(const complex<_Up>&); + /// Divide this complex number by @a z. template<typename _Up> complex<_Tp>& operator/=(const complex<_Up>&); private: - _Tp _M_real, _M_imag; + _Tp _M_real; + _Tp _M_imag; }; template<typename _Tp> - inline _Tp + inline _Tp& + complex<_Tp>::real() { return _M_real; } + + template<typename _Tp> + inline const _Tp& complex<_Tp>::real() const { return _M_real; } template<typename _Tp> - inline _Tp + inline _Tp& + complex<_Tp>::imag() { return _M_imag; } + + template<typename _Tp> + inline const _Tp& complex<_Tp>::imag() const { return _M_imag; } template<typename _Tp> @@ -243,83 +300,147 @@ namespace std complex<_Tp>::operator/=(const complex<_Up>& __z) { const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); - const _Tp __n = norm(__z); + const _Tp __n = std::norm(__z); _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n; _M_real = __r / __n; return *this; } // Operators: + //@{ + /// Return new complex value @a x plus @a y. template<typename _Tp> inline complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) += __y; } + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) - { return complex<_Tp> (__x) += __y; } + { + complex<_Tp> __r = __x; + __r.real() += __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__y) += __x; } + { + complex<_Tp> __r = __y; + __r.real() += __x; + return __r; + } + //@} + //@{ + /// Return new complex value @a x minus @a y. template<typename _Tp> inline complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) -= __y; } + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) - { return complex<_Tp> (__x) -= __y; } + { + complex<_Tp> __r = __x; + __r.real() -= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) -= __y; } + { + complex<_Tp> __r(__x, -__y.imag()); + __r.real() -= __y.real(); + return __r; + } + //@} + //@{ + /// Return new complex value @a x times @a y. template<typename _Tp> inline complex<_Tp> operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) *= __y; } + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) - { return complex<_Tp> (__x) *= __y; } + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__y) *= __x; } + { + complex<_Tp> __r = __y; + __r *= __x; + return __r; + } + //@} + //@{ + /// Return new complex value @a x divided by @a y. template<typename _Tp> inline complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) /= __y; } + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) - { return complex<_Tp> (__x) /= __y; } + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } template<typename _Tp> inline complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) - { return complex<_Tp> (__x) /= __y; } + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + //@} + /// Return @a x. template<typename _Tp> inline complex<_Tp> operator+(const complex<_Tp>& __x) { return __x; } + /// Return complex negation of @a x. template<typename _Tp> inline complex<_Tp> operator-(const complex<_Tp>& __x) { return complex<_Tp>(-__x.real(), -__x.imag()); } + //@{ + /// Return true if @a x is equal to @a y. template<typename _Tp> inline bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) @@ -334,7 +455,10 @@ namespace std inline bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && _Tp() == __y.imag(); } + //@} + //@{ + /// Return false if @a x is equal to @a y. template<typename _Tp> inline bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) @@ -349,7 +473,9 @@ namespace std inline bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || _Tp() != __y.imag(); } + //@} + /// Extraction operator for complex values. template<typename _Tp, typename _CharT, class _Traits> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) @@ -369,7 +495,7 @@ namespace std __is.setstate(ios_base::failbit); } else if (__ch == ')') - __x = complex<_Tp>(__re_x, _Tp(0)); + __x = __re_x; else __is.setstate(ios_base::failbit); } @@ -377,11 +503,12 @@ namespace std { __is.putback(__ch); __is >> __re_x; - __x = complex<_Tp>(__re_x, _Tp(0)); + __x = __re_x; } return __is; } + /// Insertion operator for complex values. template<typename _Tp, typename _CharT, class _Traits> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) @@ -396,12 +523,22 @@ namespace std // Values template<typename _Tp> - inline _Tp + inline _Tp& + real(complex<_Tp>& __z) + { return __z.real(); } + + template<typename _Tp> + inline const _Tp& real(const complex<_Tp>& __z) { return __z.real(); } template<typename _Tp> - inline _Tp + inline _Tp& + imag(complex<_Tp>& __z) + { return __z.imag(); } + + template<typename _Tp> + inline const _Tp& imag(const complex<_Tp>& __z) { return __z.imag(); } @@ -411,7 +548,7 @@ namespace std { _Tp __x = __z.real(); _Tp __y = __z.imag(); - const _Tp __s = max(abs(__x), abs(__y)); + const _Tp __s = std::max(abs(__x), abs(__y)); if (__s == _Tp()) // well ... return __s; __x /= __s; @@ -447,7 +584,7 @@ namespace std template<typename _Tp> static inline _Tp _S_do_it(const complex<_Tp>& __z) { - _Tp __res = abs(__z); + _Tp __res = std::abs(__z); return __res * __res; } }; @@ -456,7 +593,7 @@ namespace std inline _Tp norm(const complex<_Tp>& __z) { - return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCPP_FAST_MATH>::_S_do_it(__z); + return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); } template<typename _Tp> @@ -491,17 +628,17 @@ namespace std template<typename _Tp> inline complex<_Tp> exp(const complex<_Tp>& __z) - { return polar(exp(__z.real()), __z.imag()); } + { return std::polar(exp(__z.real()), __z.imag()); } template<typename _Tp> inline complex<_Tp> log(const complex<_Tp>& __z) - { return complex<_Tp>(log(abs(__z)), arg(__z)); } + { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); } template<typename _Tp> inline complex<_Tp> log10(const complex<_Tp>& __z) - { return log(__z) / log(_Tp(10.0)); } + { return std::log(__z) / log(_Tp(10.0)); } template<typename _Tp> inline complex<_Tp> @@ -535,7 +672,7 @@ namespace std } else { - _Tp __t = sqrt(2 * (abs(__z) + abs(__x))); + _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x))); _Tp __u = __t / 2; return __x > _Tp() ? complex<_Tp>(__u, __y / __t) @@ -547,48 +684,48 @@ namespace std inline complex<_Tp> tan(const complex<_Tp>& __z) { - return sin(__z) / cos(__z); + return std::sin(__z) / std::cos(__z); } template<typename _Tp> inline complex<_Tp> tanh(const complex<_Tp>& __z) { - return sinh(__z) / cosh(__z); + return std::sinh(__z) / std::cosh(__z); } template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __z, int __n) { - return __pow_helper(__z, __n); + return std::__pow_helper(__z, __n); } template<typename _Tp> complex<_Tp> pow(const complex<_Tp>& __x, const _Tp& __y) { - if (__x.imag() == _Tp()) + if (__x.imag() == _Tp() && __x.real() > _Tp()) return pow(__x.real(), __y); - complex<_Tp> __t = log(__x); - return polar(exp(__y * __t.real()), __y * __t.imag()); + complex<_Tp> __t = std::log(__x); + return std::polar(exp(__y * __t.real()), __y * __t.imag()); } template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { - return __x == _Tp() ? _Tp() : exp(__y * log(__x)); + return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); } template<typename _Tp> inline complex<_Tp> pow(const _Tp& __x, const complex<_Tp>& __y) { - return __x == _Tp() - ? _Tp() - : polar(pow(__x, __y.real()), __y.imag() * log(__x)); + return __x > _Tp() ? std::polar(pow(__x, __y.real()), + __y.imag() * log(__x)) + : std::pow(complex<_Tp>(__x, _Tp()), __y); } // 26.2.3 complex specializations @@ -599,14 +736,16 @@ namespace std typedef float value_type; complex(float = 0.0f, float = 0.0f); -#ifdef _GLIBCPP_BUGGY_COMPLEX +#ifdef _GLIBCXX_BUGGY_COMPLEX complex(const complex& __z) : _M_value(__z._M_value) { } #endif explicit complex(const complex<double>&); explicit complex(const complex<long double>&); - float real() const; - float imag() const; + float& real(); + const float& real() const; + float& imag(); + const float& imag() const; complex<float>& operator=(float); complex<float>& operator+=(float); @@ -638,11 +777,19 @@ namespace std friend class complex<long double>; }; - inline float + inline float& + complex<float>::real() + { return __real__ _M_value; } + + inline const float& complex<float>::real() const { return __real__ _M_value; } - inline float + inline float& + complex<float>::imag() + { return __imag__ _M_value; } + + inline const float& complex<float>::imag() const { return __imag__ _M_value; } @@ -746,14 +893,16 @@ namespace std typedef double value_type; complex(double =0.0, double =0.0); -#ifdef _GLIBCPP_BUGGY_COMPLEX +#ifdef _GLIBCXX_BUGGY_COMPLEX complex(const complex& __z) : _M_value(__z._M_value) { } #endif complex(const complex<float>&); explicit complex(const complex<long double>&); - - double real() const; - double imag() const; + + double& real(); + const double& real() const; + double& imag(); + const double& imag() const; complex<double>& operator=(double); complex<double>& operator+=(double); @@ -784,11 +933,19 @@ namespace std friend class complex<long double>; }; - inline double + inline double& + complex<double>::real() + { return __real__ _M_value; } + + inline const double& complex<double>::real() const { return __real__ _M_value; } - inline double + inline double& + complex<double>::imag() + { return __imag__ _M_value; } + + inline const double& complex<double>::imag() const { return __imag__ _M_value; } @@ -892,14 +1049,16 @@ namespace std typedef long double value_type; complex(long double = 0.0L, long double = 0.0L); -#ifdef _GLIBCPP_BUGGY_COMPLEX +#ifdef _GLIBCXX_BUGGY_COMPLEX complex(const complex& __z) : _M_value(__z._M_value) { } #endif complex(const complex<float>&); complex(const complex<double>&); - long double real() const; - long double imag() const; + long double& real(); + const long double& real() const; + long double& imag(); + const long double& imag() const; complex<long double>& operator= (long double); complex<long double>& operator+= (long double); @@ -937,11 +1096,19 @@ namespace std __imag__ _M_value = __i; } - inline long double + inline long double& + complex<long double>::real() + { return __real__ _M_value; } + + inline const long double& complex<long double>::real() const { return __real__ _M_value; } - inline long double + inline long double& + complex<long double>::imag() + { return __imag__ _M_value; } + + inline const long double& complex<long double>::imag() const { return __imag__ _M_value; } @@ -1062,4 +1229,4 @@ namespace std : _M_value(_ComplexT(__z._M_value)) { } } // namespace std -#endif /* _CPP_COMPLEX */ +#endif /* _GLIBCXX_COMPLEX */ diff --git a/contrib/libstdc++/include/std/std_deque.h b/contrib/libstdc++/include/std/std_deque.h index 921c25fa4931..80817f632aa5 100644 --- a/contrib/libstdc++/include/std/std_deque.h +++ b/contrib/libstdc++/include/std/std_deque.h @@ -1,6 +1,6 @@ // <deque> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -58,21 +58,24 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_DEQUE -#define _CPP_DEQUE 1 +#ifndef _GLIBCXX_DEQUE +#define _GLIBCXX_DEQUE 1 #pragma GCC system_header #include <bits/functexcept.h> #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> #include <bits/stl_deque.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# include <bits/deque.tcc> +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/deque.tcc> #endif -#endif /* _CPP_DEQUE */ +#ifdef _GLIBCXX_DEBUG +# include <debug/deque> +#endif +#endif /* _GLIBCXX_DEQUE */ diff --git a/contrib/libstdc++/include/std/std_fstream.h b/contrib/libstdc++/include/std/std_fstream.h index bcbbb971946a..040f5798b11a 100644 --- a/contrib/libstdc++/include/std/std_fstream.h +++ b/contrib/libstdc++/include/std/std_fstream.h @@ -37,14 +37,15 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_FSTREAM -#define _CPP_FSTREAM 1 +#ifndef _GLIBCXX_FSTREAM +#define _GLIBCXX_FSTREAM 1 #pragma GCC system_header #include <istream> #include <ostream> #include <locale> // For codecvt +#include <cstdio> // For SEEK_SET, SEEK_CUR, SEEK_END, BUFSIZ #include <bits/basic_file.h> #include <bits/gthr.h> @@ -59,6 +60,11 @@ namespace std * sequences. Many of its sematics are described in terms of similar * behavior in the Standard C Library's @c FILE streams. */ + // Requirements on traits_type, specific to this class: + // traits_type::pos_type must be fpos<traits_type::state_type> + // traits_type::off_type must be streamoff + // traits_type::state_type must be Assignable and DefaultConstructable, + // and traits_type::state_type() must be the initial state for codecvt. template<typename _CharT, typename _Traits> class basic_filebuf : public basic_streambuf<_CharT, _Traits> { @@ -81,7 +87,6 @@ namespace std typedef __basic_file<char> __file_type; typedef typename traits_type::state_type __state_type; typedef codecvt<char_type, char, __state_type> __codecvt_type; - typedef ctype<char_type> __ctype_type; //@} friend class ios_base; // For sync_with_stdio. @@ -104,15 +109,56 @@ namespace std */ __file_type _M_file; - // Current and beginning state type for codecvt. + /** + * @if maint + * Place to stash in || out || in | out settings for current filebuf. + * @endif + */ + ios_base::openmode _M_mode; + + // Beginning state type for codecvt. /** * @if maint * @doctodo * @endif */ - __state_type _M_state_cur; __state_type _M_state_beg; + // During output, the state that corresponds to pptr(), + // during input, the state that corresponds to egptr() and + // _M_ext_next. + /** + * @if maint + * @doctodo + * @endif + */ + __state_type _M_state_cur; + + // Not used for output. During input, the state that corresponds + // to eback() and _M_ext_buf. + /** + * @if maint + * @doctodo + * @endif + */ + __state_type _M_state_last; + + /** + * @if maint + * Pointer to the beginning of internal buffer. + * @endif + */ + char_type* _M_buf; + + /** + * @if maint + * Actual size of internal buffer. This number is equal to the size + * of the put area + 1 position, reserved for the overflow char of + * a full area. + * @endif + */ + size_t _M_buf_size; + // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. /** * @if maint @@ -120,18 +166,99 @@ namespace std * @endif */ bool _M_buf_allocated; - - // XXX Needed? - bool _M_last_overflowed; - // The position in the buffer corresponding to the external file - // pointer. /** * @if maint - * @doctodo + * _M_reading == false && _M_writing == false for 'uncommitted' mode; + * _M_reading == true for 'read' mode; + * _M_writing == true for 'write' mode; + * + * NB: _M_reading == true && _M_writing == true is unused. + * @endif + */ + bool _M_reading; + bool _M_writing; + + //@{ + /** + * @if maint + * Necessary bits for putback buffer management. + * + * @note pbacks of over one character are not currently supported. * @endif */ - char_type* _M_filepos; + char_type _M_pback; + char_type* _M_pback_cur_save; + char_type* _M_pback_end_save; + bool _M_pback_init; + //@} + + // Cached codecvt facet. + const __codecvt_type* _M_codecvt; + + /** + * @if maint + * Buffer for external characters. Used for input when + * codecvt::always_noconv() == false. When valid, this corresponds + * to eback(). + * @endif + */ + char* _M_ext_buf; + + /** + * @if maint + * Size of buffer held by _M_ext_buf. + * @endif + */ + streamsize _M_ext_buf_size; + + /** + * @if maint + * Pointers into the buffer held by _M_ext_buf that delimit a + * subsequence of bytes that have been read but not yet converted. + * When valid, _M_ext_next corresponds to egptr(). + * @endif + */ + const char* _M_ext_next; + char* _M_ext_end; + + /** + * @if maint + * Initializes pback buffers, and moves normal buffers to safety. + * Assumptions: + * _M_in_cur has already been moved back + * @endif + */ + void + _M_create_pback() + { + if (!_M_pback_init) + { + _M_pback_cur_save = this->gptr(); + _M_pback_end_save = this->egptr(); + this->setg(&_M_pback, &_M_pback, &_M_pback + 1); + _M_pback_init = true; + } + } + + /** + * @if maint + * Deactivates pback buffer contents, and restores normal buffer. + * Assumptions: + * The pback buffer has only moved forward. + * @endif + */ + void + _M_destroy_pback() throw() + { + if (_M_pback_init) + { + // Length _M_in_cur moved in the pback buffer. + _M_pback_cur_save += this->gptr() != this->eback(); + this->setg(this->_M_buf, _M_pback_cur_save, _M_pback_end_save); + _M_pback_init = false; + } + } public: // Constructors/destructor: @@ -148,10 +275,7 @@ namespace std */ virtual ~basic_filebuf() - { - this->close(); - _M_last_overflowed = false; - } + { this->close(); } // Members: /** @@ -217,45 +341,14 @@ namespace std // charater from the real input source when the buffer is empty. // Buffered input uses underflow() - // The only difference between underflow() and uflow() is that the - // latter bumps _M_in_cur after the read. In the sync_with_stdio - // case, this is important, as we need to unget the read character in - // the underflow() case in order to maintain synchronization. So - // instead of calling underflow() from uflow(), we create a common - // subroutine to do the real work. - /** - * @if maint - * @doctodo - * @endif - */ - int_type - _M_underflow_common(bool __bump); - // [documentation is inherited] virtual int_type underflow(); // [documentation is inherited] virtual int_type - uflow(); - - // [documentation is inherited] - virtual int_type pbackfail(int_type __c = _Traits::eof()); - // NB: For what the standard expects of the overflow function, - // see _M_really_overflow(), below. Because basic_streambuf's - // sputc/sputn call overflow directly, and the complications of - // this implementation's setting of the initial pointers all - // equal to _M_buf when initializing, it seems essential to have - // this in actuality be a helper function that checks for the - // eccentricities of this implementation, and then call - // overflow() if indeed the buffer is full. - - // [documentation is inherited] - virtual int_type - overflow(int_type __c = _Traits::eof()); - // Stroustrup, 1998, p 648 // The overflow() function is called to transfer characters to the // real output destination when the buffer is full. A call to @@ -268,8 +361,8 @@ namespace std * @doctodo * @endif */ - int_type - _M_really_overflow(int_type __c = _Traits::eof()); + virtual int_type + overflow(int_type __c = _Traits::eof()); // Convert internal byte sequence to external, char-based // sequence via codecvt. @@ -278,8 +371,8 @@ namespace std * @doctodo * @endif */ - void - _M_convert_to_external(char_type*, streamsize, streamsize&, streamsize&); + bool + _M_convert_to_external(char_type*, streamsize); /** * @brief Manipulates the buffer. @@ -306,33 +399,18 @@ namespace std seekpos(pos_type __pos, ios_base::openmode __mode = ios_base::in | ios_base::out); + // Common code for seekoff and seekpos + /** + * @if maint + * @doctodo + * @endif + */ + pos_type + _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); + // [documentation is inherited] virtual int - sync() - { - int __ret = 0; - bool __testput = _M_out_cur && _M_out_beg < _M_out_end; - - // Make sure that the internal buffer resyncs its idea of - // the file position with the external file. - if (__testput) - { - // Need to restore current position after the write. - off_type __off = _M_out_cur - _M_out_end; - - // _M_file.sync() will be called within - if (traits_type::eq_int_type(_M_really_overflow(), - traits_type::eof())) - __ret = -1; - else if (__off) - _M_file.seekoff(__off, ios_base::cur); - } - else - _M_file.sync(); - - _M_last_overflowed = false; - return __ret; - } + sync(); // [documentation is inherited] virtual void @@ -342,18 +420,17 @@ namespace std virtual streamsize xsgetn(char_type* __s, streamsize __n) { - streamsize __ret = 0; // Clear out pback buffer before going on to the real deal... - if (_M_pback_init) + streamsize __ret = 0; + if (this->_M_pback_init) { - while (__ret < __n && _M_in_cur < _M_in_end) + if (__n && this->gptr() == this->eback()) { - *__s = *_M_in_cur; - ++__ret; - ++__s; - ++_M_in_cur; + *__s++ = *this->gptr(); + this->gbump(1); + __ret = 1; } - _M_pback_destroy(); + _M_destroy_pback(); } if (__ret < __n) __ret += __streambuf_type::xsgetn(__s, __n - __ret); @@ -362,103 +439,49 @@ namespace std // [documentation is inherited] virtual streamsize - xsputn(const char_type* __s, streamsize __n) - { - _M_pback_destroy(); - return __streambuf_type::xsputn(__s, __n); - } + xsputn(const char_type* __s, streamsize __n); + // Flushes output buffer, then writes unshift sequence. /** * @if maint * @doctodo * @endif */ - void - _M_output_unshift(); - - // These three functions are used to clarify internal buffer - // maintenance. After an overflow, or after a seekoff call that - // started at beg or end, or possibly when the stream becomes - // unbuffered, and a myrid other obscure corner cases, the - // internal buffer does not truly reflect the contents of the - // external buffer. At this point, for whatever reason, it is in - // an indeterminate state. - /** - * @if maint - * @doctodo - * @endif - */ - void - _M_set_indeterminate(void) - { - if (_M_mode & ios_base::in) - this->setg(_M_buf, _M_buf, _M_buf); - if (_M_mode & ios_base::out) - this->setp(_M_buf, _M_buf); - _M_filepos = _M_buf; - } + bool + _M_terminate_output(); /** - * @if maint - * @doctodo + * @if maint + * This function sets the pointers of the internal buffer, both get + * and put areas. Typically: + * + * __off == egptr() - eback() upon underflow/uflow ('read' mode); + * __off == 0 upon overflow ('write' mode); + * __off == -1 upon open, setbuf, seekoff/pos ('uncommitted' mode). + * + * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size + * reflects the actual allocated memory and the last cell is reserved + * for the overflow char of a full put area. * @endif */ void - _M_set_determinate(off_type __off) + _M_set_buffer(streamsize __off) { - bool __testin = _M_mode & ios_base::in; - bool __testout = _M_mode & ios_base::out; - if (__testin) - this->setg(_M_buf, _M_buf, _M_buf + __off); - if (__testout) - this->setp(_M_buf, _M_buf + __off); - _M_filepos = _M_buf + __off; - } + const bool __testin = this->_M_mode & ios_base::in; + const bool __testout = this->_M_mode & ios_base::out; + + if (__testin && __off > 0) + this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off); + else + this->setg(this->_M_buf, this->_M_buf, this->_M_buf); - /** - * @if maint - * @doctodo - * @endif - */ - bool - _M_is_indeterminate(void) - { - bool __ret = false; - // Don't return true if unbuffered. - if (_M_buf) - { - if (_M_mode & ios_base::in) - __ret = _M_in_beg == _M_in_cur && _M_in_cur == _M_in_end; - if (_M_mode & ios_base::out) - __ret = _M_out_beg == _M_out_cur && _M_out_cur == _M_out_end; - } - return __ret; + if (__testout && __off == 0 && this->_M_buf_size > 1 ) + this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size - 1); + else + this->setp(NULL, NULL); } }; - // Explicit specialization declarations, defined in src/fstream.cc. - template<> - basic_filebuf<char>::int_type - basic_filebuf<char>::_M_underflow_common(bool __bump); - - #ifdef _GLIBCPP_USE_WCHAR_T - template<> - basic_filebuf<wchar_t>::int_type - basic_filebuf<wchar_t>::_M_underflow_common(bool __bump); - #endif - - // Generic definitions. - template <typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::int_type - basic_filebuf<_CharT, _Traits>::underflow() - { return _M_underflow_common(false); } - - template <typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::int_type - basic_filebuf<_CharT, _Traits>::uflow() - { return _M_underflow_common(true); } - - // [27.8.1.5] Template class basic_ifstream /** * @brief Controlling input for files. @@ -500,8 +523,7 @@ namespace std * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ - basic_ifstream() - : __istream_type(NULL), _M_filebuf() + basic_ifstream() : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** @@ -516,7 +538,7 @@ namespace std */ explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) - : __istream_type(NULL), _M_filebuf() + : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); @@ -623,8 +645,7 @@ namespace std * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ - basic_ofstream() - : __ostream_type(NULL), _M_filebuf() + basic_ofstream(): __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** @@ -641,7 +662,7 @@ namespace std explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out|ios_base::trunc) - : __ostream_type(NULL), _M_filebuf() + : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); @@ -751,7 +772,7 @@ namespace std * (you haven't given it a filename to open). */ basic_fstream() - : __iostream_type(NULL), _M_filebuf() + : __iostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** @@ -814,7 +835,7 @@ namespace std ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) - setstate(ios_base::failbit); + this->setstate(ios_base::failbit); } /** @@ -827,16 +848,13 @@ namespace std close() { if (!_M_filebuf.close()) - setstate(ios_base::failbit); + this->setstate(ios_base::failbit); } }; } // namespace std -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif -#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS +#ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/fstream.tcc> #endif -#endif +#endif /* _GLIBCXX_FSTREAM */ diff --git a/contrib/libstdc++/include/std/std_functional.h b/contrib/libstdc++/include/std/std_functional.h index 40080d95579d..6819f20b6f0f 100644 --- a/contrib/libstdc++/include/std/std_functional.h +++ b/contrib/libstdc++/include/std/std_functional.h @@ -46,17 +46,13 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_FUNCTIONAL -#define _CPP_FUNCTIONAL 1 +#ifndef _GLIBCXX_FUNCTIONAL +#define _GLIBCXX_FUNCTIONAL 1 #pragma GCC system_header + #include <bits/c++config.h> #include <cstddef> #include <bits/stl_function.h> -#endif /* _CPP_FUNCTIONAL */ - -// Local Variables: -// mode:C++ -// End: - +#endif /* _GLIBCXX_FUNCTIONAL */ diff --git a/contrib/libstdc++/include/std/std_iomanip.h b/contrib/libstdc++/include/std/std_iomanip.h index 490d5ac1cfba..0d965c28bf95 100644 --- a/contrib/libstdc++/include/std/std_iomanip.h +++ b/contrib/libstdc++/include/std/std_iomanip.h @@ -37,8 +37,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_IOMANIP -#define _CPP_IOMANIP 1 +#ifndef _GLIBCXX_IOMANIP +#define _GLIBCXX_IOMANIP 1 #pragma GCC system_header @@ -266,7 +266,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. -#if _GLIBCPP_EXTERN_TEMPLATE +#if _GLIBCXX_EXTERN_TEMPLATE extern template ostream& operator<<(ostream&, _Setfill<char>); extern template ostream& operator<<(ostream&, _Setiosflags); extern template ostream& operator<<(ostream&, _Resetiosflags); @@ -280,7 +280,7 @@ namespace std extern template istream& operator>>(istream&, _Setprecision); extern template istream& operator>>(istream&, _Setw); -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T extern template wostream& operator<<(wostream&, _Setfill<wchar_t>); extern template wostream& operator<<(wostream&, _Setiosflags); extern template wostream& operator<<(wostream&, _Resetiosflags); @@ -297,4 +297,4 @@ namespace std #endif } // namespace std -#endif +#endif /* _GLIBCXX_IOMANIP */ diff --git a/contrib/libstdc++/include/std/std_ios.h b/contrib/libstdc++/include/std/std_ios.h index a7764c89cdd0..596458f1ede4 100644 --- a/contrib/libstdc++/include/std/std_ios.h +++ b/contrib/libstdc++/include/std/std_ios.h @@ -36,8 +36,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_IOS -#define _CPP_IOS 1 +#ifndef _GLIBCXX_IOS +#define _GLIBCXX_IOS 1 #pragma GCC system_header @@ -50,5 +50,4 @@ #include <streambuf> #include <bits/basic_ios.h> -#endif /* _CPP_IOS */ - +#endif /* _GLIBCXX_IOS */ diff --git a/contrib/libstdc++/include/std/std_iosfwd.h b/contrib/libstdc++/include/std/std_iosfwd.h index 55b0e0b19fa7..050b9e8bab72 100644 --- a/contrib/libstdc++/include/std/std_iosfwd.h +++ b/contrib/libstdc++/include/std/std_iosfwd.h @@ -37,16 +37,17 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_IOSFWD -#define _CPP_IOSFWD 1 +#ifndef _GLIBCXX_IOSFWD +#define _GLIBCXX_IOSFWD 1 #pragma GCC system_header #include <bits/c++config.h> #include <bits/c++locale.h> +#include <bits/c++io.h> #include <cctype> // For isspace, etc. #include <bits/stringfwd.h> // For string forward declarations. -#include <bits/fpos.h> +#include <bits/postypes.h> #include <bits/functexcept.h> namespace std @@ -100,10 +101,9 @@ namespace std template<typename _CharT, typename _Traits = char_traits<_CharT> > class ostreambuf_iterator; -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS + // _GLIBCXX_RESOLVE_LIB_DEFECTS // Not included. (??? Apparently no LWG number?) class ios_base; -#endif /** * @defgroup s27_2_iosfwd I/O Forward Declarations @@ -147,7 +147,7 @@ namespace std typedef basic_ofstream<char> ofstream; ///< @isiosfwd typedef basic_fstream<char> fstream; ///< @isiosfwd -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T typedef basic_ios<wchar_t> wios; ///< @isiosfwd typedef basic_streambuf<wchar_t> wstreambuf; ///< @isiosfwd typedef basic_istream<wchar_t> wistream; ///< @isiosfwd @@ -165,4 +165,4 @@ namespace std /** @} */ } // namespace std -#endif +#endif /* _GLIBCXX_IOSFWD */ diff --git a/contrib/libstdc++/include/std/std_iostream.h b/contrib/libstdc++/include/std/std_iostream.h index d70949377df1..f5049db4a911 100644 --- a/contrib/libstdc++/include/std/std_iostream.h +++ b/contrib/libstdc++/include/std/std_iostream.h @@ -36,8 +36,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_IOSTREAM -#define _CPP_IOSTREAM 1 +#ifndef _GLIBCXX_IOSTREAM +#define _GLIBCXX_IOSTREAM 1 #pragma GCC system_header @@ -65,7 +65,7 @@ namespace std extern ostream cerr; ///< Linked to standard error (unbuffered) extern ostream clog; ///< Linked to standard error (buffered) -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T extern wistream wcin; ///< Linked to standard input extern wostream wcout; ///< Linked to standard output extern wostream wcerr; ///< Linked to standard error (unbuffered) @@ -77,4 +77,4 @@ namespace std static ios_base::Init __ioinit; } // namespace std -#endif +#endif /* _GLIBCXX_IOSTREAM */ diff --git a/contrib/libstdc++/include/std/std_istream.h b/contrib/libstdc++/include/std/std_istream.h index da9c7db18838..a3a53ba73f6e 100644 --- a/contrib/libstdc++/include/std/std_istream.h +++ b/contrib/libstdc++/include/std/std_istream.h @@ -1,6 +1,7 @@ // Input streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -36,8 +37,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_ISTREAM -#define _CPP_ISTREAM 1 +#ifndef _GLIBCXX_ISTREAM +#define _GLIBCXX_ISTREAM 1 #pragma GCC system_header @@ -69,8 +70,8 @@ namespace std typedef basic_streambuf<_CharT, _Traits> __streambuf_type; typedef basic_ios<_CharT, _Traits> __ios_type; typedef basic_istream<_CharT, _Traits> __istream_type; - typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter; - typedef num_get<_CharT, __istreambuf_iter> __numget_type; + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > + __num_get_type; typedef ctype<_CharT> __ctype_type; template<typename _CharT2, typename _Traits2> @@ -101,11 +102,8 @@ namespace std * their own stream buffer. */ explicit - basic_istream(__streambuf_type* __sb) - { - this->init(__sb); - _M_gcount = streamsize(0); - } + basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0)) + { this->init(__sb); } /** * @brief Base destructor. @@ -130,13 +128,13 @@ namespace std * functions in constructs like "std::cin >> std::ws". For more * information, see the iomanip header. */ - __istream_type& + inline __istream_type& operator>>(__istream_type& (*__pf)(__istream_type&)); - __istream_type& + inline __istream_type& operator>>(__ios_type& (*__pf)(__ios_type&)); - __istream_type& + inline __istream_type& operator>>(ios_base& (*__pf)(ios_base&)); //@} @@ -189,7 +187,7 @@ namespace std __istream_type& operator>>(unsigned long& __n); -#ifdef _GLIBCPP_USE_LONG_LONG +#ifdef _GLIBCXX_USE_LONG_LONG __istream_type& operator>>(long long& __n); @@ -214,7 +212,7 @@ namespace std * @param sb A pointer to a streambuf * * This function behaves like one of the basic arithmetic extractors, - * in that it also constructs a sentry onject and has the same error + * in that it also constructs a sentry object and has the same error * handling behavior. * * If @a sb is NULL, the stream will set failbit in its error state. @@ -560,6 +558,10 @@ namespace std __istream_type& seekg(off_type, ios_base::seekdir); //@} + + protected: + explicit + basic_istream(): _M_gcount(streamsize(0)) { } }; /** @@ -615,7 +617,7 @@ namespace std * For ease of use, sentries may be converted to booleans. The * return value is that of the sentry state (true == okay). */ - operator bool() { return _M_ok; } + operator bool() const { return _M_ok; } private: bool _M_ok; @@ -703,15 +705,14 @@ namespace std public basic_ostream<_CharT, _Traits> { public: -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 271. basic_iostream missing typedefs + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 271. basic_iostream missing typedefs // Types (inherited): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; -#endif // Non-standard Types: typedef basic_istream<_CharT, _Traits> __istream_type; @@ -725,14 +726,19 @@ namespace std */ explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) - : __istream_type(__sb), __ostream_type(__sb) - { } + : __istream_type(), __ostream_type() + { this->init(__sb); } /** * @brief Destructor does nothing. */ virtual ~basic_iostream() { } + + protected: + explicit + basic_iostream() : __istream_type(), __ostream_type() + { } }; // [27.6.1.4] standard basic_istream manipulators @@ -761,11 +767,8 @@ namespace std ws(basic_istream<_CharT, _Traits>& __is); } // namespace std -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif -#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS +#ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/istream.tcc> #endif -#endif /* _CPP_ISTREAM */ +#endif /* _GLIBCXX_ISTREAM */ diff --git a/contrib/libstdc++/include/std/std_iterator.h b/contrib/libstdc++/include/std/std_iterator.h index 7b1709409b15..6e3840b1e7e3 100644 --- a/contrib/libstdc++/include/std/std_iterator.h +++ b/contrib/libstdc++/include/std/std_iterator.h @@ -58,10 +58,11 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_ITERATOR -#define _CPP_ITERATOR 1 +#ifndef _GLIBCXX_ITERATOR +#define _GLIBCXX_ITERATOR 1 #pragma GCC system_header + #include <bits/c++config.h> #include <cstddef> #include <bits/stl_iterator_base_types.h> @@ -72,8 +73,4 @@ #include <bits/stream_iterator.h> #include <bits/streambuf_iterator.h> -#endif /* _CPP_ITERATOR */ - -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_ITERATOR */ diff --git a/contrib/libstdc++/include/std/std_limits.h b/contrib/libstdc++/include/std/std_limits.h index 9be69477958f..7f96647f95de 100644 --- a/contrib/libstdc++/include/std/std_limits.h +++ b/contrib/libstdc++/include/std/std_limits.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- numeric_limits classes. -// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -40,8 +40,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_NUMERIC_LIMITS -#define _CPP_NUMERIC_LIMITS 1 +#ifndef _GLIBCXX_NUMERIC_LIMITS +#define _GLIBCXX_NUMERIC_LIMITS 1 #pragma GCC system_header @@ -82,8 +82,8 @@ // GCC only intrinsicly supports modulo integral types. The only remaining // integral exceptional values is division by zero. Only targets that do not // signal division by zero in some "hard to ignore" way should use false. -#ifndef __glibcpp_integral_traps -# define __glibcpp_integral_traps true +#ifndef __glibcxx_integral_traps +# define __glibcxx_integral_traps true #endif // float @@ -91,124 +91,220 @@ // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_float_has_denorm_loss -# define __glibcpp_float_has_denorm_loss false +#ifndef __glibcxx_float_has_denorm_loss +# define __glibcxx_float_has_denorm_loss false #endif -#ifndef __glibcpp_float_traps -# define __glibcpp_float_traps false +#ifndef __glibcxx_float_traps +# define __glibcxx_float_traps false #endif -#ifndef __glibcpp_float_tinyness_before -# define __glibcpp_float_tinyness_before false +#ifndef __glibcxx_float_tinyness_before +# define __glibcxx_float_tinyness_before false #endif // double // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_double_has_denorm_loss -# define __glibcpp_double_has_denorm_loss false +#ifndef __glibcxx_double_has_denorm_loss +# define __glibcxx_double_has_denorm_loss false #endif -#ifndef __glibcpp_double_traps -# define __glibcpp_double_traps false +#ifndef __glibcxx_double_traps +# define __glibcxx_double_traps false #endif -#ifndef __glibcpp_double_tinyness_before -# define __glibcpp_double_tinyness_before false +#ifndef __glibcxx_double_tinyness_before +# define __glibcxx_double_tinyness_before false #endif // long double // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_long_double_has_denorm_loss -# define __glibcpp_long_double_has_denorm_loss false +#ifndef __glibcxx_long_double_has_denorm_loss +# define __glibcxx_long_double_has_denorm_loss false #endif -#ifndef __glibcpp_long_double_traps -# define __glibcpp_long_double_traps false +#ifndef __glibcxx_long_double_traps +# define __glibcxx_long_double_traps false #endif -#ifndef __glibcpp_long_double_tinyness_before -# define __glibcpp_long_double_tinyness_before false +#ifndef __glibcxx_long_double_tinyness_before +# define __glibcxx_long_double_tinyness_before false #endif // You should not need to define any macros below this point. -#define __glibcpp_signed(T) ((T)(-1) < 0) +#define __glibcxx_signed(T) ((T)(-1) < 0) -#define __glibcpp_min(T) \ - (__glibcpp_signed (T) ? (T)1 << __glibcpp_digits (T) : (T)0) +#define __glibcxx_min(T) \ + (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0) -#define __glibcpp_max(T) \ - (__glibcpp_signed (T) ? ((T)1 << __glibcpp_digits (T)) - 1 : ~(T)0) +#define __glibcxx_max(T) \ + (__glibcxx_signed (T) ? ((T)1 << __glibcxx_digits (T)) - 1 : ~(T)0) -#define __glibcpp_digits(T) \ - (sizeof(T) * __CHAR_BIT__ - __glibcpp_signed (T)) +#define __glibcxx_digits(T) \ + (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T)) // The fraction 643/2136 approximates log10(2) to 7 significant digits. -#define __glibcpp_digits10(T) \ - (__glibcpp_digits (T) * 643 / 2136) +#define __glibcxx_digits10(T) \ + (__glibcxx_digits (T) * 643 / 2136) namespace std { + /** + * @brief Describes the rounding style for floating-point types. + * + * This is used in the std::numeric_limits class. + */ enum float_round_style { - round_indeterminate = -1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, - round_toward_neg_infinity = 3 + round_indeterminate = -1, ///< Self-explanatory. + round_toward_zero = 0, ///< Self-explanatory. + round_to_nearest = 1, ///< To the nearest representable value. + round_toward_infinity = 2, ///< Self-explanatory. + round_toward_neg_infinity = 3 ///< Self-explanatory. }; + /** + * @brief Describes the denormalization for floating-point types. + * + * These values represent the presence or absence of a variable number + * of exponent bits. This type is used in the std::numeric_limits class. + */ enum float_denorm_style { + /// Indeterminate at compile time whether denormalized values are allowed. denorm_indeterminate = -1, + /// The type does not allow denormalized values. denorm_absent = 0, + /// The type allows denormalized values. denorm_present = 1 }; - // - // The primary class traits - // + /** + * @brief Part of std::numeric_limits. + * + * The @c static @c const members are usable as integral constant + * expressions. + * + * @note This is a seperate class for purposes of efficiency; you + * should only access these members as part of an instantiation + * of the std::numeric_limits class. + */ struct __numeric_limits_base { + /** This will be true for all fundamental types (which have + specializations), and false for everything else. */ static const bool is_specialized = false; + /** The number of @c radix digits that be represented without change: for + integer types, the number of non-sign bits in the mantissa; for + floating types, the number of @c radix digits in the mantissa. */ static const int digits = 0; + /** The number of base 10 digits that can be represented without change. */ static const int digits10 = 0; + /** True if the type is signed. */ static const bool is_signed = false; + /** True if the type is integer. + * @if maint + * Is this supposed to be "if the type is integral"? + * @endif + */ static const bool is_integer = false; + /** True if the type uses an exact representation. "All integer types are + exact, but not all exact types are integer. For example, rational and + fixed-exponent representations are exact but not integer." + [18.2.1.2]/15 */ static const bool is_exact = false; + /** For integer types, specifies the base of the representation. For + floating types, specifies the base of the exponent representation. */ static const int radix = 0; + /** The minimum negative integer such that @c radix raised to the power of + (one less than that integer) is a normalized floating point number. */ static const int min_exponent = 0; + /** The minimum negative integer such that 10 raised to that power is in + the range of normalized floating point numbers. */ static const int min_exponent10 = 0; + /** The maximum positive integer such that @c radix raised to the power of + (one less than that integer) is a representable finite floating point + number. */ static const int max_exponent = 0; + /** The maximum positive integer such that 10 raised to that power is in + the range of representable finite floating point numbers. */ static const int max_exponent10 = 0; + /** True if the type has a representation for positive infinity. */ static const bool has_infinity = false; + /** True if the type has a representation for a quiet (non-signaling) + "Not a Number." */ static const bool has_quiet_NaN = false; + /** True if the type has a representation for a signaling + "Not a Number." */ static const bool has_signaling_NaN = false; + /** See std::float_denorm_style for more information. */ static const float_denorm_style has_denorm = denorm_absent; + /** "True if loss of accuracy is detected as a denormalization loss, + rather than as an inexact result." [18.2.1.2]/42 */ static const bool has_denorm_loss = false; + /** True if-and-only-if the type adheres to the IEC 559 standard, also + known as IEEE 754. (Only makes sense for floating point types.) */ static const bool is_iec559 = false; + /** "True if the set of values representable by the type is finite. All + built-in types are bounded, this member would be false for arbitrary + precision types." [18.2.1.2]/54 */ static const bool is_bounded = false; + /** True if the type is @e modulo, that is, if it is possible to add two + positive numbers and have a result that wraps around to a third number + that is less. Typically false for floating types, true for unsigned + integers, and true for signed integers. */ static const bool is_modulo = false; + /** True if trapping is implemented for this type. */ static const bool traps = false; + /** True if tinyness is detected before rounding. (see IEC 559) */ static const bool tinyness_before = false; + /** See std::float_round_style for more information. This is only + meaningful for floating types; integer types will all be + round_toward_zero. */ static const float_round_style round_style = round_toward_zero; }; + /** + * @brief Properties of fundamental types. + * + * This class allows a program to obtain information about the + * representation of a fundamental type on a given platform. For + * non-fundamental types, the functions will return 0 and the data + * members will all be @c false. + * + * @if maint + * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are + * noted, but not incorporated in this documented (yet). + * @endif + */ template<typename _Tp> struct numeric_limits : public __numeric_limits_base { + /** The minimum finite value, or for floating types with + denormalization, the minimum positive normalized value. */ static _Tp min() throw() { return static_cast<_Tp>(0); } + /** The maximum finite value. */ static _Tp max() throw() { return static_cast<_Tp>(0); } + /** The @e machine @e epsilon: the difference between 1 and the least + value greater than 1 that is representable. */ static _Tp epsilon() throw() { return static_cast<_Tp>(0); } + /** The maximum rounding error measurement (see LIA-1). */ static _Tp round_error() throw() { return static_cast<_Tp>(0); } + /** The representation of positive infinity, if @c has_infinity. */ static _Tp infinity() throw() { return static_cast<_Tp>(0); } + /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */ static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); } + /** The representation of a signaling "Not a Number," if + @c has_signaling_NaN. */ static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); } + /** The minimum positive denormalized value. For types where + @c has_denorm is false, this is the minimum positive normalized + value. */ static _Tp denorm_min() throw() { return static_cast<_Tp>(0); } }; @@ -262,7 +358,7 @@ namespace std // It is not clear what it means for a boolean type to trap. // This is a DR on the LWG issue list. Here, I use integer // promotion semantics. - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -273,13 +369,13 @@ namespace std static const bool is_specialized = true; static char min() throw() - { return __glibcpp_min(char); } + { return __glibcxx_min(char); } static char max() throw() - { return __glibcpp_max(char); } + { return __glibcxx_max(char); } - static const int digits = __glibcpp_digits (char); - static const int digits10 = __glibcpp_digits10 (char); - static const bool is_signed = __glibcpp_signed (char); + static const int digits = __glibcxx_digits (char); + static const int digits10 = __glibcxx_digits10 (char); + static const bool is_signed = __glibcxx_signed (char); static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; @@ -312,7 +408,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -327,8 +423,8 @@ namespace std static signed char max() throw() { return __SCHAR_MAX__; } - static const int digits = __glibcpp_digits (signed char); - static const int digits10 = __glibcpp_digits10 (signed char); + static const int digits = __glibcxx_digits (signed char); + static const int digits10 = __glibcxx_digits10 (signed char); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -362,7 +458,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -377,8 +473,8 @@ namespace std static unsigned char max() throw() { return __SCHAR_MAX__ * 2U + 1; } - static const int digits = __glibcpp_digits (unsigned char); - static const int digits10 = __glibcpp_digits10 (unsigned char); + static const int digits = __glibcxx_digits (unsigned char); + static const int digits10 = __glibcxx_digits10 (unsigned char); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -412,7 +508,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -423,13 +519,13 @@ namespace std static const bool is_specialized = true; static wchar_t min() throw() - { return __glibcpp_min (wchar_t); } + { return __glibcxx_min (wchar_t); } static wchar_t max() throw() - { return __glibcpp_max (wchar_t); } + { return __glibcxx_max (wchar_t); } - static const int digits = __glibcpp_digits (wchar_t); - static const int digits10 = __glibcpp_digits10 (wchar_t); - static const bool is_signed = __glibcpp_signed (wchar_t); + static const int digits = __glibcxx_digits (wchar_t); + static const int digits10 = __glibcxx_digits10 (wchar_t); + static const bool is_signed = __glibcxx_signed (wchar_t); static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; @@ -462,7 +558,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -477,8 +573,8 @@ namespace std static short max() throw() { return __SHRT_MAX__; } - static const int digits = __glibcpp_digits (short); - static const int digits10 = __glibcpp_digits10 (short); + static const int digits = __glibcxx_digits (short); + static const int digits10 = __glibcxx_digits10 (short); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -512,7 +608,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -527,8 +623,8 @@ namespace std static unsigned short max() throw() { return __SHRT_MAX__ * 2U + 1; } - static const int digits = __glibcpp_digits (unsigned short); - static const int digits10 = __glibcpp_digits10 (unsigned short); + static const int digits = __glibcxx_digits (unsigned short); + static const int digits10 = __glibcxx_digits10 (unsigned short); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -562,7 +658,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -577,8 +673,8 @@ namespace std static int max() throw() { return __INT_MAX__; } - static const int digits = __glibcpp_digits (int); - static const int digits10 = __glibcpp_digits10 (int); + static const int digits = __glibcxx_digits (int); + static const int digits10 = __glibcxx_digits10 (int); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -612,7 +708,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -627,8 +723,8 @@ namespace std static unsigned int max() throw() { return __INT_MAX__ * 2U + 1; } - static const int digits = __glibcpp_digits (unsigned int); - static const int digits10 = __glibcpp_digits10 (unsigned int); + static const int digits = __glibcxx_digits (unsigned int); + static const int digits10 = __glibcxx_digits10 (unsigned int); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -662,7 +758,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -677,8 +773,8 @@ namespace std static long max() throw() { return __LONG_MAX__; } - static const int digits = __glibcpp_digits (long); - static const int digits10 = __glibcpp_digits10 (long); + static const int digits = __glibcxx_digits (long); + static const int digits10 = __glibcxx_digits10 (long); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -712,7 +808,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -727,8 +823,8 @@ namespace std static unsigned long max() throw() { return __LONG_MAX__ * 2UL + 1; } - static const int digits = __glibcpp_digits (unsigned long); - static const int digits10 = __glibcpp_digits10 (unsigned long); + static const int digits = __glibcxx_digits (unsigned long); + static const int digits10 = __glibcxx_digits10 (unsigned long); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -762,7 +858,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -777,8 +873,8 @@ namespace std static long long max() throw() { return __LONG_LONG_MAX__; } - static const int digits = __glibcpp_digits (long long); - static const int digits10 = __glibcpp_digits10 (long long); + static const int digits = __glibcxx_digits (long long); + static const int digits10 = __glibcxx_digits10 (long long); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -812,7 +908,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -827,8 +923,8 @@ namespace std static unsigned long long max() throw() { return __LONG_LONG_MAX__ * 2ULL + 1; } - static const int digits = __glibcpp_digits (unsigned long long); - static const int digits10 = __glibcpp_digits10 (unsigned long long); + static const int digits = __glibcxx_digits (unsigned long long); + static const int digits10 = __glibcxx_digits10 (unsigned long long); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -862,7 +958,7 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_integral_traps; + static const bool traps = __glibcxx_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; @@ -893,14 +989,12 @@ namespace std static const int max_exponent = __FLT_MAX_EXP__; static const int max_exponent10 = __FLT_MAX_10_EXP__; - static const bool has_infinity - = __builtin_huge_valf () / 2 == __builtin_huge_valf (); - static const bool has_quiet_NaN - = __builtin_nanf ("") != __builtin_nanf (""); + static const bool has_infinity = __FLT_HAS_INFINITY__; + static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent; - static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss; + static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss; static float infinity() throw() { return __builtin_huge_valf (); } @@ -916,14 +1010,14 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = false; - static const bool traps = __glibcpp_float_traps; - static const bool tinyness_before = __glibcpp_float_tinyness_before; + static const bool traps = __glibcxx_float_traps; + static const bool tinyness_before = __glibcxx_float_tinyness_before; static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_float_has_denorm_loss -#undef __glibcpp_float_traps -#undef __glibcpp_float_tinyness_before +#undef __glibcxx_float_has_denorm_loss +#undef __glibcxx_float_traps +#undef __glibcxx_float_tinyness_before template<> struct numeric_limits<double> @@ -951,14 +1045,12 @@ namespace std static const int max_exponent = __DBL_MAX_EXP__; static const int max_exponent10 = __DBL_MAX_10_EXP__; - static const bool has_infinity - = __builtin_huge_val () / 2 == __builtin_huge_val (); - static const bool has_quiet_NaN - = __builtin_nan ("") != __builtin_nan (""); + static const bool has_infinity = __DBL_HAS_INFINITY__; + static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent; - static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss; + static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss; static double infinity() throw() { return __builtin_huge_val(); } @@ -974,14 +1066,14 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = false; - static const bool traps = __glibcpp_double_traps; - static const bool tinyness_before = __glibcpp_double_tinyness_before; + static const bool traps = __glibcxx_double_traps; + static const bool tinyness_before = __glibcxx_double_tinyness_before; static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_double_has_denorm_loss -#undef __glibcpp_double_traps -#undef __glibcpp_double_tinyness_before +#undef __glibcxx_double_has_denorm_loss +#undef __glibcxx_double_traps +#undef __glibcxx_double_tinyness_before template<> struct numeric_limits<long double> @@ -1009,15 +1101,13 @@ namespace std static const int max_exponent = __LDBL_MAX_EXP__; static const int max_exponent10 = __LDBL_MAX_10_EXP__; - static const bool has_infinity - = __builtin_huge_vall () / 2 == __builtin_huge_vall (); - static const bool has_quiet_NaN - = __builtin_nanl ("") != __builtin_nanl (""); + static const bool has_infinity = __LDBL_HAS_INFINITY__; + static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss - = __glibcpp_long_double_has_denorm_loss; + = __glibcxx_long_double_has_denorm_loss; static long double infinity() throw() { return __builtin_huge_vall (); } @@ -1033,21 +1123,21 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = false; - static const bool traps = __glibcpp_long_double_traps; - static const bool tinyness_before = __glibcpp_long_double_tinyness_before; + static const bool traps = __glibcxx_long_double_traps; + static const bool tinyness_before = __glibcxx_long_double_tinyness_before; static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_long_double_has_denorm_loss -#undef __glibcpp_long_double_traps -#undef __glibcpp_long_double_tinyness_before +#undef __glibcxx_long_double_has_denorm_loss +#undef __glibcxx_long_double_traps +#undef __glibcxx_long_double_tinyness_before } // namespace std -#undef __glibcpp_signed -#undef __glibcpp_min -#undef __glibcpp_max -#undef __glibcpp_digits -#undef __glibcpp_digits10 +#undef __glibcxx_signed +#undef __glibcxx_min +#undef __glibcxx_max +#undef __glibcxx_digits +#undef __glibcxx_digits10 -#endif // _CPP_NUMERIC_LIMITS +#endif // _GLIBCXX_NUMERIC_LIMITS diff --git a/contrib/libstdc++/include/std/std_list.h b/contrib/libstdc++/include/std/std_list.h index 84523ad8e4fa..285a29d8131c 100644 --- a/contrib/libstdc++/include/std/std_list.h +++ b/contrib/libstdc++/include/std/std_list.h @@ -1,6 +1,6 @@ // <list> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -58,21 +58,25 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_LIST -#define _CPP_LIST 1 +#ifndef _GLIBCXX_LIST +#define _GLIBCXX_LIST 1 #pragma GCC system_header #include <bits/functexcept.h> #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> #include <bits/stl_list.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# include <bits/list.tcc> +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/list.tcc> #endif -#endif /* _CPP_LIST */ +#ifdef _GLIBCXX_DEBUG +# include <debug/list> +#endif + +#endif /* _GLIBCXX_LIST */ diff --git a/contrib/libstdc++/include/std/std_locale.h b/contrib/libstdc++/include/std/std_locale.h index 29602560766c..43417fbdddc7 100644 --- a/contrib/libstdc++/include/std/std_locale.h +++ b/contrib/libstdc++/include/std/std_locale.h @@ -36,8 +36,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_LOCALE -#define _CPP_LOCALE 1 +#ifndef _GLIBCXX_LOCALE +#define _GLIBCXX_LOCALE 1 #pragma GCC system_header @@ -46,4 +46,4 @@ #include <bits/locale_facets.h> #include <bits/locale_facets.tcc> -#endif +#endif /* _GLIBCXX_LOCALE */ diff --git a/contrib/libstdc++/include/std/std_map.h b/contrib/libstdc++/include/std/std_map.h index c04cbd542a67..4a88ae22ea33 100644 --- a/contrib/libstdc++/include/std/std_map.h +++ b/contrib/libstdc++/include/std/std_map.h @@ -58,8 +58,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_MAP -#define _CPP_MAP 1 +#ifndef _GLIBCXX_MAP +#define _GLIBCXX_MAP 1 #pragma GCC system_header @@ -67,8 +67,8 @@ #include <bits/stl_map.h> #include <bits/stl_multimap.h> -#endif /* _CPP_MAP */ +#ifdef _GLIBCXX_DEBUG +# include <debug/map> +#endif -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_MAP */ diff --git a/contrib/libstdc++/include/std/std_memory.h b/contrib/libstdc++/include/std/std_memory.h index 47c3ede8995d..4e6641ef6739 100644 --- a/contrib/libstdc++/include/std/std_memory.h +++ b/contrib/libstdc++/include/std/std_memory.h @@ -1,6 +1,6 @@ // <memory> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -46,17 +46,18 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_MEMORY -#define _CPP_MEMORY 1 +#ifndef _GLIBCXX_MEMORY +#define _GLIBCXX_MEMORY 1 #pragma GCC system_header #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_iterator_base_types.h> //for iterator_traits #include <bits/stl_uninitialized.h> #include <bits/stl_raw_storage_iter.h> +#include <debug/debug.h> namespace std { @@ -77,33 +78,36 @@ namespace std while (__len > 0) { - _Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp)); + _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), + nothrow)); if (__tmp != 0) return pair<_Tp*, ptrdiff_t>(__tmp, __len); __len /= 2; } - return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); + return pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); } /** - * @brief This is a mostly-useless wrapper around malloc(). + * @brief Allocates a temporary buffer. * @param len The number of objects of type Tp. - * @return See full description. + * @return See full description. * * Reinventing the wheel, but this time with prettier spokes! * - * This function tries to obtain storage for @c len adjacent Tp objects. - * The objects themselves are not constructed, of course. A pair<> is - * returned containing "the buffer s address and capacity (in the units of - * sizeof(Tp)), or a pair of 0 values if no storage can be obtained." - * Note that the capacity obtained may be less than that requested if the - * memory is unavailable; you should compare len with the .second return - * value. + * This function tries to obtain storage for @c len adjacent Tp + * objects. The objects themselves are not constructed, of course. + * A pair<> is returned containing "the buffer s address and + * capacity (in the units of sizeof(Tp)), or a pair of 0 values if + * no storage can be obtained." Note that the capacity obtained + * may be less than that requested if the memory is unavailable; + * you should compare len with the .second return value. + * + * Provides the nothrow exception guarantee. */ template<typename _Tp> inline pair<_Tp*,ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) - { return __get_temporary_buffer(__len, (_Tp*) 0); } + { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } /** * @brief The companion to get_temporary_buffer(). @@ -115,12 +119,12 @@ namespace std template<typename _Tp> void return_temporary_buffer(_Tp* __p) - { std::free(__p); } + { ::operator delete(__p, nothrow); } /** - * A wrapper class to provide auto_ptr with reference semantics. For - * example, an auto_ptr can be assigned (or constructed from) the result of - * a function which returns an auto_ptr by value. + * A wrapper class to provide auto_ptr with reference semantics. + * For example, an auto_ptr can be assigned (or constructed from) + * the result of a function which returns an auto_ptr by value. * * All the auto_ptr_ref stuff should happen behind the scenes. */ @@ -139,26 +143,28 @@ namespace std * * The Standard says: * <pre> - * An @c auto_ptr owns the object it holds a pointer to. Copying an - * @c auto_ptr copies the pointer and transfers ownership to the destination. - * If more than one @c auto_ptr owns the same object at the same time the - * behavior of the program is undefined. + * An @c auto_ptr owns the object it holds a pointer to. Copying + * an @c auto_ptr copies the pointer and transfers ownership to the + * destination. If more than one @c auto_ptr owns the same object + * at the same time the behavior of the program is undefined. * - * The uses of @c auto_ptr include providing temporary exception-safety for - * dynamically allocated memory, passing ownership of dynamically allocated - * memory to a function, and returning dynamically allocated memory from a - * function. @c auto_ptr does not meet the CopyConstructible and Assignable - * requirements for Standard Library <a href="tables.html#65">container</a> - * elements and thus instantiating a Standard Library container with an - * @c auto_ptr results in undefined behavior. + * The uses of @c auto_ptr include providing temporary + * exception-safety for dynamically allocated memory, passing + * ownership of dynamically allocated memory to a function, and + * returning dynamically allocated memory from a function. @c + * auto_ptr does not meet the CopyConstructible and Assignable + * requirements for Standard Library <a + * href="tables.html#65">container</a> elements and thus + * instantiating a Standard Library container with an @c auto_ptr + * results in undefined behavior. * </pre> * Quoted from [20.4.5]/3. * - * Good examples of what can and cannot be done with auto_ptr can be found - * in the libstdc++ testsuite. + * Good examples of what can and cannot be done with auto_ptr can + * be found in the libstdc++ testsuite. * * @if maint - * _GLIBCPP_RESOLVE_LIB_DEFECTS + * _GLIBCXX_RESOLVE_LIB_DEFECTS * 127. auto_ptr<> conversion issues * These resolutions have all been incorporated. * @endif @@ -195,7 +201,8 @@ namespace std * @brief An %auto_ptr can be constructed from another %auto_ptr. * @param a Another %auto_ptr of a different but related type. * - * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * A pointer-to-Tp1 must be convertible to a + * pointer-to-Tp/element_type. * * This object now @e owns the object previously owned by @a a, * which has given up ownsership. @@ -237,9 +244,9 @@ namespace std } /** - * When the %auto_ptr goes out of scope, the object it owns is deleted. - * If it no longer owns anything (i.e., @c get() is @c NULL), then this - * has no effect. + * When the %auto_ptr goes out of scope, the object it owns is + * deleted. If it no longer owns anything (i.e., @c get() is + * @c NULL), then this has no effect. * * @if maint * The C++ standard says there is supposed to be an empty throw @@ -259,7 +266,11 @@ namespace std * what happens when you dereference one of those...) */ element_type& - operator*() const throw() { return *_M_ptr; } + operator*() const throw() + { + _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); + return *_M_ptr; + } /** * @brief Smart pointer dereferencing. @@ -268,15 +279,19 @@ namespace std * automatically cause to be dereferenced. */ element_type* - operator->() const throw() { return _M_ptr; } + operator->() const throw() + { + _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); + return _M_ptr; + } /** * @brief Bypassing the smart pointer. * @return The raw pointer being managed. * * You can get a copy of the pointer that this object owns, for - * situations such as passing to a function which only accepts a raw - * pointer. + * situations such as passing to a function which only accepts + * a raw pointer. * * @note This %auto_ptr still owns the memory. */ @@ -288,8 +303,8 @@ namespace std * @return The raw pointer being managed. * * You can get a copy of the pointer that this object owns, for - * situations such as passing to a function which only accepts a raw - * pointer. + * situations such as passing to a function which only accepts + * a raw pointer. * * @note This %auto_ptr no longer owns the memory. When this object * goes out of scope, nothing will happen. @@ -306,8 +321,8 @@ namespace std * @brief Forcibly deletes the managed object. * @param p A pointer (defaults to NULL). * - * This object now @e owns the object pointed to by @a p. The previous - * object has been deleted. + * This object now @e owns the object pointed to by @a p. The + * previous object has been deleted. */ void reset(element_type* __p = 0) throw() @@ -355,4 +370,4 @@ namespace std }; } // namespace std -#endif +#endif /* _GLIBCXX_MEMORY */ diff --git a/contrib/libstdc++/include/std/std_numeric.h b/contrib/libstdc++/include/std/std_numeric.h index 936eaa78945e..88661e9f5a44 100644 --- a/contrib/libstdc++/include/std/std_numeric.h +++ b/contrib/libstdc++/include/std/std_numeric.h @@ -58,18 +58,15 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_NUMERIC -#define _CPP_NUMERIC 1 +#ifndef _GLIBCXX_NUMERIC +#define _GLIBCXX_NUMERIC 1 #pragma GCC system_header + #include <bits/c++config.h> #include <cstddef> #include <iterator> #include <bits/stl_function.h> #include <bits/stl_numeric.h> -#endif /* _CPP_NUMERIC */ - -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_NUMERIC */ diff --git a/contrib/libstdc++/include/std/std_ostream.h b/contrib/libstdc++/include/std/std_ostream.h index 82f8a2864bc6..e3590f23515c 100644 --- a/contrib/libstdc++/include/std/std_ostream.h +++ b/contrib/libstdc++/include/std/std_ostream.h @@ -1,6 +1,6 @@ // Output streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -37,8 +37,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_OSTREAM -#define _CPP_OSTREAM 1 +#ifndef _GLIBCXX_OSTREAM +#define _GLIBCXX_OSTREAM 1 #pragma GCC system_header @@ -69,8 +69,8 @@ namespace std typedef basic_streambuf<_CharT, _Traits> __streambuf_type; typedef basic_ios<_CharT, _Traits> __ios_type; typedef basic_ostream<_CharT, _Traits> __ostream_type; - typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter; - typedef num_put<_CharT, __ostreambuf_iter> __numput_type; + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > + __num_put_type; typedef ctype<_CharT> __ctype_type; template<typename _CharT2, typename _Traits2> @@ -127,13 +127,13 @@ namespace std * functions in constructs like "std::cout << std::endl". For more * information, see the iomanip header. */ - __ostream_type& + inline __ostream_type& operator<<(__ostream_type& (*__pf)(__ostream_type&)); - __ostream_type& + inline __ostream_type& operator<<(__ios_type& (*__pf)(__ios_type&)); - __ostream_type& + inline __ostream_type& operator<<(ios_base& (*__pf) (ios_base&)); //@} @@ -203,7 +203,7 @@ namespace std operator<<(unsigned int __n) { return this->operator<<(static_cast<unsigned long>(__n)); } -#ifdef _GLIBCPP_USE_LONG_LONG +#ifdef _GLIBCXX_USE_LONG_LONG __ostream_type& operator<<(long long __n); @@ -229,7 +229,7 @@ namespace std * @param sb A pointer to a streambuf * * This function behaves like one of the basic arithmetic extractors, - * in that it also constructs a sentry onject and has the same error + * in that it also constructs a sentry object and has the same error * handling behavior. * * If @a sb is NULL, the stream will set failbit in its error state. @@ -281,6 +281,15 @@ namespace std __ostream_type& put(char_type __c); + // Core write functionality, without sentry. + void + _M_write(const char_type* __s, streamsize __n) + { + streamsize __put = this->rdbuf()->sputn(__s, __n); + if (__put != __n) + this->setstate(ios_base::badbit); + } + /** * @brief Character string insertion. * @param s The array to insert. @@ -346,6 +355,10 @@ namespace std */ __ostream_type& seekp(off_type, ios_base::seekdir); + + protected: + explicit + basic_ostream() { } }; /** @@ -405,7 +418,7 @@ namespace std * For ease of use, sentries may be converted to booleans. The * return value is that of the sentry state (true == okay). */ - operator bool() + operator bool() const { return _M_ok; } }; @@ -528,11 +541,8 @@ namespace std } // namespace std -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif -#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS +#ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/ostream.tcc> #endif -#endif /* _CPP_OSTREAM */ +#endif /* _GLIBCXX_OSTREAM */ diff --git a/contrib/libstdc++/include/std/std_queue.h b/contrib/libstdc++/include/std/std_queue.h index 60636e6f0dd8..9a6523bef87b 100644 --- a/contrib/libstdc++/include/std/std_queue.h +++ b/contrib/libstdc++/include/std/std_queue.h @@ -1,6 +1,6 @@ // <queue> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -58,25 +58,21 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_QUEUE -#define _CPP_QUEUE 1 +#ifndef _GLIBCXX_QUEUE +#define _GLIBCXX_QUEUE 1 #pragma GCC system_header + #include <bits/c++config.h> #include <bits/functexcept.h> #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> -#include <bits/stl_vector.h> #include <bits/stl_heap.h> -#include <bits/stl_deque.h> #include <bits/stl_function.h> +#include <deque> +#include <vector> #include <bits/stl_queue.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# include <bits/deque.tcc> -# include <bits/vector.tcc> -#endif - -#endif /* _CPP_QUEUE */ +#endif /* _GLIBCXX_QUEUE */ diff --git a/contrib/libstdc++/include/std/std_set.h b/contrib/libstdc++/include/std/std_set.h index 249f396f1af8..7ef8c9fef3bd 100644 --- a/contrib/libstdc++/include/std/std_set.h +++ b/contrib/libstdc++/include/std/std_set.h @@ -58,8 +58,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_SET -#define _CPP_SET 1 +#ifndef _GLIBCXX_SET +#define _GLIBCXX_SET 1 #pragma GCC system_header @@ -67,8 +67,8 @@ #include <bits/stl_set.h> #include <bits/stl_multiset.h> -#endif /* _CPP_SET */ +#ifdef _GLIBCXX_DEBUG +# include <debug/set> +#endif -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_SET */ diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h index 0940e60f52e7..6b5728b94ced 100644 --- a/contrib/libstdc++/include/std/std_sstream.h +++ b/contrib/libstdc++/include/std/std_sstream.h @@ -1,6 +1,7 @@ // String based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -36,8 +37,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_SSTREAM -#define _CPP_SSTREAM 1 +#ifndef _GLIBCXX_SSTREAM +#define _GLIBCXX_SSTREAM 1 #pragma GCC system_header @@ -65,10 +66,9 @@ namespace std // Types: typedef _CharT char_type; typedef _Traits traits_type; -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 251. basic_stringbuf missing allocator_type + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; -#endif typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; @@ -85,6 +85,13 @@ namespace std //@} protected: + /** + * @if maint + * Place to stash in || out || in | out settings for current stringbuf. + * @endif + */ + ios_base::openmode _M_mode; + // Data Members: /** * @if maint @@ -104,7 +111,7 @@ namespace std */ explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) - : __streambuf_type(), _M_string() + : __streambuf_type(), _M_mode(), _M_string() { _M_stringbuf_init(__mode); } /** @@ -118,7 +125,7 @@ namespace std explicit basic_stringbuf(const __string_type& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) - : __streambuf_type(), _M_string(__str.data(), __str.size()) + : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size()) { _M_stringbuf_init(__mode); } // Get and set: @@ -133,16 +140,14 @@ namespace std __string_type str() const { - if (_M_mode & ios_base::out) + const bool __testout = this->_M_mode & ios_base::out; + if (__testout) { - // This is the deal: _M_string.size() is a value that - // represents the size of the initial string that makes - // _M_string, and may not be the correct size of the - // current stringbuf internal buffer. - __size_type __len = _M_string.size(); - if (_M_out_end > _M_out_beg) - __len = max(__size_type(_M_out_end - _M_out_beg), __len); - return __string_type(_M_out_beg, _M_out_beg + __len); + // The current egptr() may not be the actual string end. + if (this->pptr() > this->egptr()) + return __string_type(this->pbase(), this->pptr()); + else + return __string_type(this->pbase(), this->egptr()); } else return _M_string; @@ -160,7 +165,7 @@ namespace std { // Cannot use _M_string = __s, since v3 strings are COW. _M_string.assign(__s.data(), __s.size()); - _M_stringbuf_init(_M_mode); + _M_stringbuf_init(this->_M_mode); } protected: @@ -173,35 +178,17 @@ namespace std void _M_stringbuf_init(ios_base::openmode __mode) { - // _M_buf_size is a convenient alias for "what the streambuf - // thinks the allocated size of the string really is." This is - // necessary as ostringstreams are implemented with the - // streambufs having control of the allocation and - // re-allocation of the internal string object, _M_string. - _M_buf_size = _M_string.size(); + this->_M_mode = __mode; - // NB: Start ostringstream buffers at 512 bytes. This is an - // experimental value (pronounced "arbitrary" in some of the - // hipper english-speaking countries), and can be changed to - // suit particular needs. - _M_buf_size_opt = 512; - _M_mode = __mode; - if (_M_mode & (ios_base::ate | ios_base::app)) - _M_really_sync(0, _M_buf_size); - else - _M_really_sync(0, 0); + __size_type __len = 0; + if (this->_M_mode & (ios_base::ate | ios_base::app)) + __len = _M_string.size(); + _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len); } - // Overridden virtual functions: // [documentation is inherited] virtual int_type - underflow() - { - if (_M_in_cur && _M_in_cur < _M_in_end) - return traits_type::to_int_type(*gptr()); - else - return traits_type::eof(); - } + underflow(); // [documentation is inherited] virtual int_type @@ -225,10 +212,18 @@ namespace std virtual __streambuf_type* setbuf(char_type* __s, streamsize __n) { - if (__s && __n) + if (__s && __n >= 0) { + // This is implementation-defined behavior, and assumes + // that an external char_type array of length __n exists + // and has been pre-allocated. If this is not the case, + // things will quickly blow up. + + // Step 1: Destroy the current internal array. _M_string = __string_type(__s, __n); - _M_really_sync(0, 0); + + // Step 2: Use the external array. + _M_sync(__s, 0, 0); } return this; } @@ -254,23 +249,41 @@ namespace std * @doctodo * @endif */ - virtual int - _M_really_sync(__size_type __i, __size_type __o) + void + _M_sync(char_type* __base, __size_type __i, __size_type __o) { - char_type* __base = const_cast<char_type*>(_M_string.data()); - bool __testin = _M_mode & ios_base::in; - bool __testout = _M_mode & ios_base::out; - __size_type __len = _M_string.size(); + const bool __testin = this->_M_mode & ios_base::in; + const bool __testout = this->_M_mode & ios_base::out; + const __size_type __len = _M_string.size(); - _M_buf = __base; if (__testin) - this->setg(__base, __base + __i, __base + __len); + this->setg(__base, __base + __i, __base + __len); if (__testout) { - this->setp(__base, __base + __len); - _M_out_cur += __o; + this->setp(__base, __base + _M_string.capacity()); + this->pbump(__o); + // We need a pointer to the string end anyway, even when + // !__testin: in that case, however, for the correct + // functioning of the streambuf inlines all the get area + // pointers must be identical. + if (!__testin) + this->setg(__base + __len, __base + __len, __base + __len); } - return 0; + } + + // Internal function for correctly updating egptr() to the actual + // string end. + void + _M_update_egptr() + { + const bool __testin = this->_M_mode & ios_base::in; + const bool __testout = this->_M_mode & ios_base::out; + + if (__testout && this->pptr() > this->egptr()) + if (__testin) + this->setg(this->eback(), this->gptr(), this->pptr()); + else + this->setg(this->pptr(), this->pptr(), this->pptr()); } }; @@ -291,10 +304,9 @@ namespace std // Types: typedef _CharT char_type; typedef _Traits traits_type; -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 251. basic_stringbuf missing allocator_type + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; -#endif typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; @@ -330,7 +342,7 @@ namespace std */ explicit basic_istringstream(ios_base::openmode __mode = ios_base::in) - : __istream_type(NULL), _M_stringbuf(__mode | ios_base::in) + : __istream_type(), _M_stringbuf(__mode | ios_base::in) { this->init(&_M_stringbuf); } /** @@ -351,7 +363,7 @@ namespace std explicit basic_istringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::in) - : __istream_type(NULL), _M_stringbuf(__str, __mode | ios_base::in) + : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in) { this->init(&_M_stringbuf); } /** @@ -410,10 +422,9 @@ namespace std // Types: typedef _CharT char_type; typedef _Traits traits_type; -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 251. basic_stringbuf missing allocator_type + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; -#endif typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; @@ -449,7 +460,7 @@ namespace std */ explicit basic_ostringstream(ios_base::openmode __mode = ios_base::out) - : __ostream_type(NULL), _M_stringbuf(__mode | ios_base::out) + : __ostream_type(), _M_stringbuf(__mode | ios_base::out) { this->init(&_M_stringbuf); } /** @@ -470,7 +481,7 @@ namespace std explicit basic_ostringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::out) - : __ostream_type(NULL), _M_stringbuf(__str, __mode | ios_base::out) + : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out) { this->init(&_M_stringbuf); } /** @@ -529,10 +540,9 @@ namespace std // Types: typedef _CharT char_type; typedef _Traits traits_type; -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 251. basic_stringbuf missing allocator_type + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; -#endif typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; @@ -566,7 +576,7 @@ namespace std */ explicit basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in) - : __iostream_type(NULL), _M_stringbuf(__m) + : __iostream_type(), _M_stringbuf(__m) { this->init(&_M_stringbuf); } /** @@ -585,7 +595,7 @@ namespace std explicit basic_stringstream(const __string_type& __str, ios_base::openmode __m = ios_base::out | ios_base::in) - : __iostream_type(NULL), _M_stringbuf(__str, __m) + : __iostream_type(), _M_stringbuf(__str, __m) { this->init(&_M_stringbuf); } /** @@ -628,11 +638,8 @@ namespace std }; } // namespace std -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif -#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS +#ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/sstream.tcc> #endif -#endif +#endif /* _GLIBCXX_SSTREAM */ diff --git a/contrib/libstdc++/include/std/std_stack.h b/contrib/libstdc++/include/std/std_stack.h index ddae7e78fc68..70f045684e0e 100644 --- a/contrib/libstdc++/include/std/std_stack.h +++ b/contrib/libstdc++/include/std/std_stack.h @@ -1,6 +1,6 @@ // <stack> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -58,20 +58,16 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_STACK -#define _CPP_STACK 1 +#ifndef _GLIBCXX_STACK +#define _GLIBCXX_STACK 1 #pragma GCC system_header #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> -#include <bits/stl_deque.h> +#include <deque> #include <bits/stl_stack.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# include <bits/deque.tcc> -#endif - -#endif /* _CPP_STACK */ +#endif /* _GLIBCXX_STACK */ diff --git a/contrib/libstdc++/include/std/std_stdexcept.h b/contrib/libstdc++/include/std/std_stdexcept.h index 07a15e466ce5..ebd97f50f887 100644 --- a/contrib/libstdc++/include/std/std_stdexcept.h +++ b/contrib/libstdc++/include/std/std_stdexcept.h @@ -36,8 +36,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_STDEXCEPT -#define _CPP_STDEXCEPT 1 +#ifndef _GLIBCXX_STDEXCEPT +#define _GLIBCXX_STDEXCEPT 1 #pragma GCC system_header @@ -145,4 +145,4 @@ namespace std }; } // namespace std -#endif // _CPP_STDEXCEPT +#endif /* _GLIBCXX_STDEXCEPT */ diff --git a/contrib/libstdc++/include/std/std_streambuf.h b/contrib/libstdc++/include/std/std_streambuf.h index a1958c1a8e7c..42b3d782b0f1 100644 --- a/contrib/libstdc++/include/std/std_streambuf.h +++ b/contrib/libstdc++/include/std/std_streambuf.h @@ -1,6 +1,6 @@ // Stream buffer classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -37,14 +37,13 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_STREAMBUF -#define _CPP_STREAMBUF 1 +#ifndef _CLIBXX_STREAMBUF +#define _CLIBXX_STREAMBUF 1 #pragma GCC system_header #include <bits/c++config.h> #include <iosfwd> -#include <cstdio> // For SEEK_SET, SEEK_CUR, SEEK_END #include <bits/localefwd.h> #include <bits/ios_base.h> @@ -57,8 +56,7 @@ namespace std */ template<typename _CharT, typename _Traits> streamsize - __copy_streambufs(basic_ios<_CharT, _Traits>& _ios, - basic_streambuf<_CharT, _Traits>* __sbin, + __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin, basic_streambuf<_CharT, _Traits>* __sbout); /** @@ -141,12 +139,10 @@ namespace std //@{ /** * @if maint - * These are non-standard types. + * This is a non-standard type. * @endif */ - typedef ctype<char_type> __ctype_type; typedef basic_streambuf<char_type, traits_type> __streambuf_type; - typedef typename traits_type::state_type __state_type; //@} friend class basic_ios<char_type, traits_type>; @@ -156,42 +152,10 @@ namespace std friend class ostreambuf_iterator<char_type, traits_type>; friend streamsize - __copy_streambufs<>(basic_ios<char_type, traits_type>& __ios, - __streambuf_type* __sbin,__streambuf_type* __sbout); + __copy_streambufs<>(__streambuf_type* __sbin, + __streambuf_type* __sbout); protected: - /** - * @if maint - * Pointer to the beginning of internally-allocated space. Filebuf - * manually allocates/deallocates this, whereas stringstreams attempt - * to use the built-in intelligence of the string class. If you are - * managing memory, set this. If not, leave it NULL. - * @endif - */ - char_type* _M_buf; - - /** - * @if maint - * Actual size of allocated internal buffer, in bytes. - * @endif - */ - size_t _M_buf_size; - - /** - * @if maint - * Optimal or preferred size of internal buffer, in bytes. - * @endif - */ - size_t _M_buf_size_opt; - - /** - * @if maint - * True iff _M_in_* and _M_out_* buffers should always point to - * the same place. True for fstreams, false for sstreams. - * @endif - */ - bool _M_buf_unified; - //@{ /** * @if maint @@ -202,20 +166,12 @@ namespace std * - put == output == write * @endif */ - char_type* _M_in_beg; // Start of get area. - char_type* _M_in_cur; // Current read area. - char_type* _M_in_end; // End of get area. - char_type* _M_out_beg; // Start of put area. - char_type* _M_out_cur; // Current put area. - char_type* _M_out_end; // End of put area. - //@} - - /** - * @if maint - * Place to stash in || out || in | out settings for current streambuf. - * @endif - */ - ios_base::openmode _M_mode; + char_type* _M_in_beg; // Start of get area. + char_type* _M_in_cur; // Current read area. + char_type* _M_in_end; // End of get area. + char_type* _M_out_beg; // Start of put area. + char_type* _M_out_cur; // Current put area. + char_type* _M_out_end; // End of put area. /** * @if maint @@ -224,147 +180,11 @@ namespace std */ locale _M_buf_locale; - /** - * @if maint - * True iff locale is initialized. - * @endif - */ - bool _M_buf_locale_init; - - //@{ - /** - * @if maint - * Necessary bits for putback buffer management. Only used in - * the basic_filebuf class, as necessary for the standard - * requirements. The only basic_streambuf member function that - * needs access to these data members is in_avail... - * - * @note pbacks of over one character are not currently supported. - * @endif - */ - static const size_t _S_pback_size = 1; - char_type _M_pback[_S_pback_size]; - char_type* _M_pback_cur_save; - char_type* _M_pback_end_save; - bool _M_pback_init; - //@} - - /** - * @if maint - * Yet unused. - * @endif - */ - fpos<__state_type> _M_pos; - - // Initializes pback buffers, and moves normal buffers to safety. - // Assumptions: - // _M_in_cur has already been moved back - void - _M_pback_create() - { - if (!_M_pback_init) - { - size_t __dist = _M_in_end - _M_in_cur; - size_t __len = min(_S_pback_size, __dist); - traits_type::copy(_M_pback, _M_in_cur, __len); - _M_pback_cur_save = _M_in_cur; - _M_pback_end_save = _M_in_end; - this->setg(_M_pback, _M_pback, _M_pback + __len); - _M_pback_init = true; - } - } - - // Deactivates pback buffer contents, and restores normal buffer. - // Assumptions: - // The pback buffer has only moved forward. - void - _M_pback_destroy() throw() - { - if (_M_pback_init) - { - // Length _M_in_cur moved in the pback buffer. - size_t __off_cur = _M_in_cur - _M_pback; - - // For in | out buffers, the end can be pushed back... - size_t __off_end = 0; - size_t __pback_len = _M_in_end - _M_pback; - size_t __save_len = _M_pback_end_save - _M_buf; - if (__pback_len > __save_len) - __off_end = __pback_len - __save_len; - - this->setg(_M_buf, _M_pback_cur_save + __off_cur, - _M_pback_end_save + __off_end); - _M_pback_cur_save = NULL; - _M_pback_end_save = NULL; - _M_pback_init = false; - } - } - - // Correctly sets the _M_in_cur pointer, and bumps the - // _M_out_cur pointer as well if necessary. - void - _M_in_cur_move(off_type __n) // argument needs to be +- - { - bool __testout = _M_out_cur; - _M_in_cur += __n; - if (__testout && _M_buf_unified) - _M_out_cur += __n; - } - - // Correctly sets the _M_out_cur pointer, and bumps the - // appropriate _M_*_end pointers as well. Necessary for the - // un-tied stringbufs, in in|out mode. - // Invariant: - // __n + _M_out_[cur, end] <= _M_buf + _M_buf_size - // Assuming all _M_*_[beg, cur, end] pointers are operating on - // the same range: - // _M_buf <= _M_*_ <= _M_buf + _M_buf_size - void - _M_out_cur_move(off_type __n) // argument needs to be +- - { - bool __testin = _M_in_cur; - - _M_out_cur += __n; - if (__testin && _M_buf_unified) - _M_in_cur += __n; - if (_M_out_cur > _M_out_end) - { - _M_out_end = _M_out_cur; - // NB: in | out buffers drag the _M_in_end pointer along... - if (__testin) - _M_in_end += __n; - } - } - - // Return the size of the output buffer. This depends on the - // buffer in use: allocated buffers have a stored size in - // _M_buf_size and setbuf() buffers don't. - off_type - _M_out_buf_size() - { - off_type __ret = 0; - if (_M_out_cur) - { - // Using allocated buffer. - if (_M_out_beg == _M_buf) - __ret = _M_out_beg + _M_buf_size - _M_out_cur; - // Using non-allocated buffer. - else - __ret = _M_out_end - _M_out_cur; - } - return __ret; - } - public: /// Destructor deallocates no buffer space. virtual ~basic_streambuf() - { - _M_buf_unified = false; - _M_buf_size = 0; - _M_buf_size_opt = 0; - _M_mode = ios_base::openmode(0); - } + { } // [27.5.2.2.1] locales /** @@ -379,6 +199,7 @@ namespace std { locale __tmp(this->getloc()); this->imbue(__loc); + _M_buf_locale = __loc; return __tmp; } @@ -433,21 +254,8 @@ namespace std streamsize in_avail() { - streamsize __ret; - if (_M_in_cur && _M_in_cur < _M_in_end) - { - if (_M_pback_init) - { - size_t __save_len = _M_pback_end_save - _M_pback_cur_save; - size_t __pback_len = _M_in_cur - _M_pback; - __ret = __save_len - __pback_len; - } - else - __ret = this->egptr() - this->gptr(); - } - else - __ret = this->showmanyc(); - return __ret; + const streamsize __ret = this->egptr() - this->gptr(); + return __ret ? __ret : this->showmanyc(); } /** @@ -460,9 +268,11 @@ namespace std int_type snextc() { - int_type __eof = traits_type::eof(); - return (traits_type::eq_int_type(this->sbumpc(), __eof) - ? __eof : this->sgetc()); + int_type __ret = traits_type::eof(); + if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(), + __ret), true)) + __ret = this->sgetc(); + return __ret; } /** @@ -474,7 +284,18 @@ namespace std * @c uflow(). */ int_type - sbumpc(); + sbumpc() + { + int_type __ret; + if (__builtin_expect(this->gptr() < this->egptr(), true)) + { + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); + } + else + __ret = this->uflow(); + return __ret; + } /** * @brief Getting the next character. @@ -488,8 +309,8 @@ namespace std sgetc() { int_type __ret; - if (_M_in_cur && _M_in_cur < _M_in_end) - __ret = traits_type::to_int_type(*(this->gptr())); + if (__builtin_expect(this->gptr() < this->egptr(), true)) + __ret = traits_type::to_int_type(*this->gptr()); else __ret = this->underflow(); return __ret; @@ -518,7 +339,20 @@ namespace std * fetched from the input stream will be @a c. */ int_type - sputbackc(char_type __c); + sputbackc(char_type __c) + { + int_type __ret; + const bool __testpos = this->eback() < this->gptr(); + if (__builtin_expect(!__testpos || + !traits_type::eq(__c, this->gptr()[-1]), false)) + __ret = this->pbackfail(traits_type::to_int_type(__c)); + else + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + return __ret; + } /** * @brief Moving backwards in the input stream. @@ -530,7 +364,18 @@ namespace std * "gotten". */ int_type - sungetc(); + sungetc() + { + int_type __ret; + if (__builtin_expect(this->eback() < this->gptr(), true)) + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + else + __ret = this->pbackfail(); + return __ret; + } // [27.5.2.2.5] put area /** @@ -546,7 +391,19 @@ namespace std * position is not available, returns @c overflow(c). */ int_type - sputc(char_type __c); + sputc(char_type __c) + { + int_type __ret; + if (__builtin_expect(this->pptr() < this->epptr(), true)) + { + *this->pptr() = __c; + this->pbump(1); + __ret = traits_type::to_int_type(__c); + } + else + __ret = this->overflow(traits_type::to_int_type(__c)); + return __ret; + } /** * @brief Entry point for all single-character output functions. @@ -574,12 +431,9 @@ namespace std * - this is not an error */ basic_streambuf() - : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ), - _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0), - _M_out_beg(0), _M_out_cur(0), _M_out_end(0), - _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), - _M_pback_cur_save(0), _M_pback_end_save(0), - _M_pback_init(false) + : _M_in_beg(0), _M_in_cur(0), _M_in_end(0), + _M_out_beg(0), _M_out_cur(0), _M_out_end(0), + _M_buf_locale(locale()) { } // [27.5.2.3.1] get area access @@ -627,8 +481,6 @@ namespace std _M_in_beg = __gbeg; _M_in_cur = __gnext; _M_in_end = __gend; - if (!(_M_mode & ios_base::in) && __gbeg && __gnext && __gend) - _M_mode = _M_mode | ios_base::in; } // [27.5.2.3.2] put area access @@ -673,9 +525,7 @@ namespace std setp(char_type* __pbeg, char_type* __pend) { _M_out_beg = _M_out_cur = __pbeg; - _M_out_end = __pend; - if (!(_M_mode & ios_base::out) && __pbeg && __pend) - _M_mode = _M_mode | ios_base::out; + _M_out_end = __pend; } // [27.5.2.4] virtual functions @@ -688,15 +538,13 @@ namespace std * are changed by this call. The standard adds, "Between invocations * of this function a class derived from streambuf can safely cache * results of calls to locale functions and to members of facets - * so obtained." This function simply stores the new locale for use - * by derived classes. + * so obtained." + * + * @note Base class version does nothing. */ virtual void - imbue(const locale& __loc) - { - if (_M_buf_locale != __loc) - _M_buf_locale = __loc; - } + imbue(const locale&) + { } // [27.5.2.4.2] buffer management and positioning /** @@ -822,14 +670,12 @@ namespace std uflow() { int_type __ret = traits_type::eof(); - bool __testeof = traits_type::eq_int_type(this->underflow(), __ret); - bool __testpending = _M_in_cur && _M_in_cur < _M_in_end; - if (!__testeof && __testpending) + const bool __testeof = traits_type::eq_int_type(this->underflow(), + __ret); + if (!__testeof) { - __ret = traits_type::to_int_type(*_M_in_cur); - ++_M_in_cur; - if (_M_buf_unified && _M_mode & ios_base::out) - ++_M_out_cur; + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); } return __ret; } @@ -891,7 +737,7 @@ namespace std overflow(int_type /* __c */ = traits_type::eof()) { return traits_type::eof(); } -#ifdef _GLIBCPP_DEPRECATED +#ifdef _GLIBCXX_DEPRECATED // Annex D.6 public: /** @@ -903,35 +749,36 @@ namespace std * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html * * @note This function has been deprecated by the standard. You - * must define @c _GLIBCPP_DEPRECATED to make this visible; see + * must define @c _GLIBCXX_DEPRECATED to make this visible; see * c++config.h. */ void stossc() { - if (_M_in_cur < _M_in_end) - ++_M_in_cur; + if (this->gptr() < this->egptr()) + this->gbump(1); else this->uflow(); } #endif -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS - // Side effect of DR 50. private: - basic_streambuf(const __streambuf_type&) { }; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // Side effect of DR 50. + basic_streambuf(const __streambuf_type& __sb) + : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur), + _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg), + _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_cur), + _M_buf_locale(__sb._M_buf_locale) + { } __streambuf_type& operator=(const __streambuf_type&) { return *this; }; -#endif }; } // namespace std -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif -#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS -#include <bits/streambuf.tcc> +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/streambuf.tcc> #endif -#endif +#endif /* _GLIBCXX_STREAMBUF */ diff --git a/contrib/libstdc++/include/std/std_string.h b/contrib/libstdc++/include/std/std_string.h index 6b82f8ecb0cc..2b15658c7684 100644 --- a/contrib/libstdc++/include/std/std_string.h +++ b/contrib/libstdc++/include/std/std_string.h @@ -1,6 +1,6 @@ // Components for manipulating sequences of characters -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -37,8 +37,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_STRING -#define _CPP_STRING 1 +#ifndef _GLIBCXX_STRING +#define _GLIBCXX_STRING 1 #pragma GCC system_header @@ -52,10 +52,9 @@ #include <bits/stl_function.h> // For less #include <bits/basic_string.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +#ifndef _GLIBCXX_EXPORT_TEMPLATE # include <algorithm> // for find_if # include <bits/basic_string.tcc> #endif -#endif /* _CPP_STRING */ - +#endif /* _GLIBCXX_STRING */ diff --git a/contrib/libstdc++/include/std/std_utility.h b/contrib/libstdc++/include/std/std_utility.h index b9c6c09ff648..fe93090f9399 100644 --- a/contrib/libstdc++/include/std/std_utility.h +++ b/contrib/libstdc++/include/std/std_utility.h @@ -58,16 +58,13 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_UTILITY -#define _CPP_UTILITY 1 +#ifndef _GLIBCXX_UTILITY +#define _GLIBCXX_UTILITY 1 #pragma GCC system_header + #include <bits/c++config.h> #include <bits/stl_relops.h> #include <bits/stl_pair.h> -#endif /* _CPP_UTILITY */ - -// Local Variables: -// mode:C++ -// End: +#endif /* _GLIBCXX_UTILITY */ diff --git a/contrib/libstdc++/include/std/std_valarray.h b/contrib/libstdc++/include/std/std_valarray.h index b4de5dfec370..b893b3354159 100644 --- a/contrib/libstdc++/include/std/std_valarray.h +++ b/contrib/libstdc++/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 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -35,8 +35,8 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_VALARRAY -#define _CPP_VALARRAY 1 +#ifndef _GLIBCXX_VALARRAY +#define _GLIBCXX_VALARRAY 1 #pragma GCC system_header @@ -46,6 +46,7 @@ #include <cstdlib> #include <numeric> #include <algorithm> +#include <debug/debug.h> namespace std { @@ -90,10 +91,21 @@ namespace std } // namespace std #include <bits/valarray_array.h> -#include <bits/valarray_meta.h> +#include <bits/valarray_before.h> namespace std { + /** + * @brief Smart array designed to support numeric processing. + * + * A valarray is an array that provides constraints intended to allow for + * effective optimization of numeric array processing by reducing the + * aliasing that can result from pointer representations. It represents a + * one-dimensional array from which different multidimensional subsets can + * be accessed and modified. + * + * @param Tp Type of object in the array. + */ template<class _Tp> class valarray { @@ -107,71 +119,289 @@ namespace std typedef _Tp value_type; // _lib.valarray.cons_ construct/destroy: + /// Construct an empty array. valarray(); + + /// Construct an array with @a n elements. explicit valarray(size_t); + + /// Construct an array with @a n elements initialized to @a t. valarray(const _Tp&, size_t); + + /// Construct an array initialized to the first @a n elements of @a t. valarray(const _Tp* __restrict__, size_t); + + /// Copy constructor. valarray(const valarray&); + + /// Construct an array with the same size and values in @a sa. valarray(const slice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ga. valarray(const gslice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ma. valarray(const mask_array<_Tp>&); + + /// Construct an array with the same size and values in @a ia. valarray(const indirect_array<_Tp>&); + template<class _Dom> valarray(const _Expr<_Dom,_Tp>& __e); ~valarray(); // _lib.valarray.assign_ assignment: + /** + * @brief Assign elements to an array. + * + * Assign elements of array to values in @a v. Results are undefined + * if @a v is not the same size as this array. + * + * @param v Valarray to get values from. + */ valarray<_Tp>& operator=(const valarray<_Tp>&); + + /** + * @brief Assign elements to a value. + * + * Assign all elements of array to @a t. + * + * @param t Value for elements. + */ valarray<_Tp>& operator=(const _Tp&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a sa. Results are undefined + * if @a sa is not the same size as this array. + * + * @param sa Array slice to get values from. + */ valarray<_Tp>& operator=(const slice_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ga. Results are undefined + * if @a ga is not the same size as this array. + * + * @param ga Array slice to get values from. + */ valarray<_Tp>& operator=(const gslice_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ma. Results are undefined + * if @a ma is not the same size as this array. + * + * @param ma Array slice to get values from. + */ valarray<_Tp>& operator=(const mask_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ia. Results are undefined + * if @a ia is not the same size as this array. + * + * @param ia Array slice to get values from. + */ valarray<_Tp>& operator=(const indirect_array<_Tp>&); template<class _Dom> valarray<_Tp>& operator= (const _Expr<_Dom,_Tp>&); // _lib.valarray.access_ element access: - // XXX: LWG to be resolved. - const _Tp& operator[](size_t) const; - _Tp& operator[](size_t); + /** + * Return a reference to the i'th array element. + * + * @param i Index of element to return. + * @return Reference to the i'th element. + */ + _Tp& operator[](size_t); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 389. Const overload of valarray::operator[] returns by value. + const _Tp& operator[](size_t) const; + // _lib.valarray.sub_ subset operations: + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the slice argument. The new valarray is the size of + * the input slice. @see slice. + * + * @param s The source slice. + * @return New valarray containing elements in @a s. + */ _Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the slice argument. The new valarray is the size of + * the input slice. @see slice. + * + * @param s The source slice. + * @return New valarray containing elements in @a s. + */ slice_array<_Tp> operator[](slice); + + /** + * @brief Return an array subset. + * + * Returns a slice_array referencing the elements of the array + * indicated by the slice argument. @see gslice. + * + * @param s The source slice. + * @return Slice_array referencing elements indicated by @a s. + */ _Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the gslice argument. The new valarray is + * the size of the input gslice. @see gslice. + * + * @param s The source gslice. + * @return New valarray containing elements in @a s. + */ gslice_array<_Tp> operator[](const gslice&); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements should be copied into + * the new valarray. Each element of the array is added to the return + * valarray if the corresponding element of the argument is true. + * + * @param m The valarray bitmask. + * @return New valarray containing elements indicated by @a m. + */ valarray<_Tp> operator[](const valarray<bool>&) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new mask_array referencing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements are part of the + * subset. Elements of the array are part of the subset if the + * corresponding element of the argument is true. + * + * @param m The valarray bitmask. + * @return New valarray containing elements indicated by @a m. + */ mask_array<_Tp> operator[](const valarray<bool>&); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to copy to + * the return valarray. + * + * @param i The valarray element index list. + * @return New valarray containing elements in @a s. + */ _Expr<_IClos<_ValArray, _Tp>, _Tp> operator[](const valarray<size_t>&) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns an indirect_array referencing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to include + * in the subset. The returned indirect_array refers to these + * elements. + * + * @param i The valarray element index list. + * @return Indirect_array referencing elements in @a i. + */ indirect_array<_Tp> operator[](const valarray<size_t>&); // _lib.valarray.unary_ unary operators: + /// Return a new valarray by applying unary + to each element. typename _UnaryOp<__unary_plus>::_Rt operator+() const; + + /// Return a new valarray by applying unary - to each element. typename _UnaryOp<__negate>::_Rt operator-() const; + + /// Return a new valarray by applying unary ~ to each element. typename _UnaryOp<__bitwise_not>::_Rt operator~() const; + + /// Return a new valarray by applying unary ! to each element. typename _UnaryOp<__logical_not>::_Rt operator!() const; // _lib.valarray.cassign_ computed assignment: + /// Multiply each element of array by @a t. valarray<_Tp>& operator*=(const _Tp&); + + /// Divide each element of array by @a t. valarray<_Tp>& operator/=(const _Tp&); + + /// Set each element e of array to e % @a t. valarray<_Tp>& operator%=(const _Tp&); + + /// Add @a t to each element of array. valarray<_Tp>& operator+=(const _Tp&); + + /// Subtract @a t to each element of array. valarray<_Tp>& operator-=(const _Tp&); + + /// Set each element e of array to e ^ @a t. valarray<_Tp>& operator^=(const _Tp&); + + /// Set each element e of array to e & @a t. valarray<_Tp>& operator&=(const _Tp&); + + /// Set each element e of array to e | @a t. valarray<_Tp>& operator|=(const _Tp&); + + /// Left shift each element e of array by @a t bits. valarray<_Tp>& operator<<=(const _Tp&); + + /// Right shift each element e of array by @a t bits. valarray<_Tp>& operator>>=(const _Tp&); + + /// Multiply elements of array by corresponding elements of @a v. valarray<_Tp>& operator*=(const valarray<_Tp>&); + + /// Divide elements of array by corresponding elements of @a v. valarray<_Tp>& operator/=(const valarray<_Tp>&); + + /// Modulo elements of array by corresponding elements of @a v. valarray<_Tp>& operator%=(const valarray<_Tp>&); + + /// Add corresponding elements of @a v to elements of array. valarray<_Tp>& operator+=(const valarray<_Tp>&); + + /// Subtract corresponding elements of @a v from elements of array. valarray<_Tp>& operator-=(const valarray<_Tp>&); + + /// Logical xor corresponding elements of @a v with elements of array. valarray<_Tp>& operator^=(const valarray<_Tp>&); + + /// Logical or corresponding elements of @a v with elements of array. valarray<_Tp>& operator|=(const valarray<_Tp>&); + + /// Logical and corresponding elements of @a v with elements of array. valarray<_Tp>& operator&=(const valarray<_Tp>&); + + /// Left shift elements of array by corresponding elements of @a v. valarray<_Tp>& operator<<=(const valarray<_Tp>&); + + /// Right shift elements of array by corresponding elements of @a v. valarray<_Tp>& operator>>=(const valarray<_Tp>&); template<class _Dom> @@ -197,18 +427,93 @@ namespace std // _lib.valarray.members_ member functions: + /// Return the number of elements in array. size_t size() const; - _Tp sum() const; + + /** + * @brief Return the sum of all elements in the array. + * + * Accumulates the sum of all elements into a Tp using +=. The order + * of adding the elements is unspecified. + */ + _Tp sum() const; + + /// Return the minimum element using operator<(). _Tp min() const; + + /// Return the maximum element using operator<(). _Tp max() const; // // FIXME: Extension // _Tp product () const; + /** + * @brief Return a shifted array. + * + * A new valarray is constructed as a copy of this array with elements + * in shifted positions. For an element with index i, the new position + * is i - n. The new valarray is the same size as the current one. + * New elements without a value are set to 0. Elements whos new + * position is outside the bounds of the array are discarded. + * + * Positive arguments shift toward index 0, discarding elements [0, n). + * Negative arguments discard elements from the top of the array. + * + * @param n Number of element positions to shift. + * @return New valarray with elements in shifted positions. + */ valarray<_Tp> shift (int) const; + + /** + * @brief Return a rotated array. + * + * A new valarray is constructed as a copy of this array with elements + * in shifted positions. For an element with index i, the new position + * is (i - n) % size(). The new valarray is the same size as the + * current one. Elements that are shifted beyond the array bounds are + * shifted into the other end of the array. No elements are lost. + * + * Positive arguments shift toward index 0, wrapping around the top. + * Negative arguments shift towards the top, wrapping around to 0. + * + * @param n Number of element positions to rotate. + * @return New valarray with elements in shifted positions. + */ valarray<_Tp> cshift(int) const; + + /** + * @brief Apply a function to the array. + * + * Returns a new valarray with elements assigned to the result of + * applying func to the corresponding element of this array. The new + * array is the same size as this one. + * + * @param func Function of Tp returning Tp to apply. + * @return New valarray with transformed elements. + */ _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const; + + /** + * @brief Apply a function to the array. + * + * Returns a new valarray with elements assigned to the result of + * applying func to the corresponding element of this array. The new + * array is the same size as this one. + * + * @param func Function of const Tp& returning Tp to apply. + * @return New valarray with transformed elements. + */ _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const; + + /** + * @brief Resize array. + * + * Resize this array to be @a size and set all elements to @a c. All + * references and iterators are invalidated. + * + * @param size New array size. + * @param c New value for all elements. + */ void resize(size_t __size, _Tp __c = _Tp()); private: @@ -221,15 +526,23 @@ namespace std template<typename _Tp> inline const _Tp& valarray<_Tp>::operator[](size_t __i) const - { return _M_data[__i]; } + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } template<typename _Tp> inline _Tp& valarray<_Tp>::operator[](size_t __i) - { return _M_data[__i]; } + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } } // std:: - + +#include <bits/valarray_after.h> + #include <bits/slice_array.h> #include <bits/gslice.h> #include <bits/gslice_array.h> @@ -246,32 +559,35 @@ namespace std inline valarray<_Tp>::valarray(size_t __n) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_default_construct(_M_data, _M_data + __n); } + { std::__valarray_default_construct(_M_data, _M_data + __n); } template<typename _Tp> inline valarray<_Tp>::valarray(const _Tp& __t, size_t __n) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_fill_construct(_M_data, _M_data + __n, __t); } + { std::__valarray_fill_construct(_M_data, _M_data + __n, __t); } template<typename _Tp> inline valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_copy_construct(__p, __p + __n, _M_data); } + { + _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0); + std::__valarray_copy_construct(__p, __p + __n, _M_data); + } template<typename _Tp> inline valarray<_Tp>::valarray(const valarray<_Tp>& __v) : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) - { __valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); } + { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); } template<typename _Tp> inline valarray<_Tp>::valarray(const slice_array<_Tp>& __sa) : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz)) { - __valarray_copy + std::__valarray_copy (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); } @@ -281,7 +597,7 @@ namespace std : _M_size(__ga._M_index.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) { - __valarray_copy + std::__valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index), _Array<_Tp>(_M_data), _M_size); } @@ -291,7 +607,7 @@ namespace std valarray<_Tp>::valarray(const mask_array<_Tp>& __ma) : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) { - __valarray_copy + std::__valarray_copy (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); } @@ -300,7 +616,7 @@ namespace std valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia) : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz)) { - __valarray_copy + std::__valarray_copy (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); } @@ -308,21 +624,22 @@ namespace std inline valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e) : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) - { __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); } + { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); } template<typename _Tp> inline valarray<_Tp>::~valarray() { - __valarray_destroy_elements(_M_data, _M_data + _M_size); - __valarray_release_memory(_M_data); + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); } template<typename _Tp> inline valarray<_Tp>& valarray<_Tp>::operator=(const valarray<_Tp>& __v) { - __valarray_copy(__v._M_data, _M_size, _M_data); + _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); + std::__valarray_copy(__v._M_data, _M_size, _M_data); return *this; } @@ -330,7 +647,7 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const _Tp& __t) { - __valarray_fill(_M_data, _M_size, __t); + std::__valarray_fill(_M_data, _M_size, __t); return *this; } @@ -338,8 +655,9 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<_Tp>& __sa) { - __valarray_copy(__sa._M_array, __sa._M_sz, - __sa._M_stride, _Array<_Tp>(_M_data)); + _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz); + std::__valarray_copy(__sa._M_array, __sa._M_sz, + __sa._M_stride, _Array<_Tp>(_M_data)); return *this; } @@ -347,8 +665,9 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga) { - __valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index), - _Array<_Tp>(_M_data), _M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size()); + std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); return *this; } @@ -356,8 +675,9 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __ma) { - __valarray_copy(__ma._M_array, __ma._M_mask, - _Array<_Tp>(_M_data), _M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz); + std::__valarray_copy(__ma._M_array, __ma._M_mask, + _Array<_Tp>(_M_data), _M_size); return *this; } @@ -365,8 +685,9 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia) { - __valarray_copy(__ia._M_array, __ia._M_index, - _Array<_Tp>(_M_data), _M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz); + std::__valarray_copy(__ia._M_array, __ia._M_index, + _Array<_Tp>(_M_data), _M_size); return *this; } @@ -374,8 +695,9 @@ namespace std inline valarray<_Tp>& valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) { - __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); - return *this; + _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size()); + std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + return *this; } template<typename _Tp> @@ -458,7 +780,8 @@ namespace std inline _Tp valarray<_Tp>::sum() const { - return __valarray_sum(_M_data, _M_data + _M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return std::__valarray_sum(_M_data, _M_data + _M_size); } // template<typename _Tp> @@ -475,21 +798,21 @@ namespace std _Tp* const __a = static_cast<_Tp*> (__builtin_alloca(sizeof(_Tp) * _M_size)); if (__n == 0) // no shift - __valarray_copy_construct(_M_data, _M_data + _M_size, __a); + std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a); else if (__n > 0) // __n > 0: shift left { if (size_t(__n) > _M_size) - __valarray_default_construct(__a, __a + __n); + std::__valarray_default_construct(__a, __a + __n); else { - __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); - __valarray_default_construct(__a+_M_size-__n, __a + _M_size); + std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); + std::__valarray_default_construct(__a+_M_size-__n, __a + _M_size); } } else // __n < 0: shift right { - __valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n); - __valarray_default_construct(__a, __a - __n); + std::__valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n); + std::__valarray_default_construct(__a, __a - __n); } return valarray<_Tp> (__a, _M_size); } @@ -501,17 +824,17 @@ namespace std _Tp* const __a = static_cast<_Tp*> (__builtin_alloca (sizeof(_Tp) * _M_size)); if (__n == 0) // no cshift - __valarray_copy_construct(_M_data, _M_data + _M_size, __a); + std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a); else if (__n > 0) // cshift left { - __valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n); - __valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); + std::__valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n); + std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); } else // cshift right { - __valarray_copy_construct + std::__valarray_copy_construct (_M_data + _M_size+__n, _M_data + _M_size, __a); - __valarray_copy_construct + std::__valarray_copy_construct (_M_data, _M_data + _M_size+__n, __a - __n); } return valarray<_Tp>(__a, _M_size); @@ -524,28 +847,30 @@ namespace std // This complication is so to make valarray<valarray<T> > work // even though it is not required by the standard. Nobody should // be saying valarray<valarray<T> > anyway. See the specs. - __valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); if (_M_size != __n) { - __valarray_release_memory(_M_data); + std::__valarray_release_memory(_M_data); _M_size = __n; _M_data = __valarray_get_storage<_Tp>(__n); } - __valarray_fill_construct(_M_data, _M_data + __n, __c); + std::__valarray_fill_construct(_M_data, _M_data + __n, __c); } template<typename _Tp> inline _Tp valarray<_Tp>::min() const { - return *min_element (_M_data, _M_data+_M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return *std::min_element (_M_data, _M_data+_M_size); } template<typename _Tp> inline _Tp valarray<_Tp>::max() const { - return *max_element (_M_data, _M_data+_M_size); + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return *std::max_element (_M_data, _M_data+_M_size); } template<class _Tp> @@ -594,6 +919,7 @@ namespace std inline valarray<_Tp>& \ valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \ { \ + _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \ _Array<_Tp>(__v._M_data)); \ return *this; \ @@ -641,6 +967,7 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) typename __fun<_Name, _Tp>::result_type> \ operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ { \ + _GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \ typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \ return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \ @@ -687,8 +1014,4 @@ _DEFINE_BINARY_OPERATOR(>=, __greater_equal) } // namespace std -#endif // _CPP_VALARRAY - -// Local Variables: -// mode:c++ -// End: +#endif /* _GLIBCXX_VALARRAY */ diff --git a/contrib/libstdc++/include/std/std_vector.h b/contrib/libstdc++/include/std/std_vector.h index 5738ef7ade89..16e50a99ec8c 100644 --- a/contrib/libstdc++/include/std/std_vector.h +++ b/contrib/libstdc++/include/std/std_vector.h @@ -1,6 +1,6 @@ // <vector> -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -58,22 +58,26 @@ * in your programs, rather than any of the "st[dl]_*.h" implementation files. */ -#ifndef _CPP_VECTOR -#define _CPP_VECTOR 1 +#ifndef _GLIBCXX_VECTOR +#define _GLIBCXX_VECTOR 1 #pragma GCC system_header #include <bits/functexcept.h> #include <bits/stl_algobase.h> -#include <bits/stl_alloc.h> +#include <bits/allocator.h> #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> #include <bits/stl_vector.h> #include <bits/stl_bvector.h> -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# include <bits/vector.tcc> +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/vector.tcc> #endif -#endif /* _CPP_VECTOR */ +#ifdef _GLIBCXX_DEBUG +# include <debug/vector> +#endif + +#endif /* _GLIBCXX_VECTOR */ |
