diff options
Diffstat (limited to 'gcc-4.6/libstdc++-v3/include')
46 files changed, 571 insertions, 279 deletions
diff --git a/gcc-4.6/libstdc++-v3/include/backward/hashtable.h b/gcc-4.6/libstdc++-v3/include/backward/hashtable.h index c3eefcc..e04d8fa 100644 --- a/gcc-4.6/libstdc++-v3/include/backward/hashtable.h +++ b/gcc-4.6/libstdc++-v3/include/backward/hashtable.h @@ -210,7 +210,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Note: assumes long is at least 32 bits. enum { _S_num_primes = 29 }; - static const unsigned long __stl_prime_list[_S_num_primes] = + template<typename _PrimeType> + struct _Hashtable_prime_list + { + static const _PrimeType __stl_prime_list[_S_num_primes]; + + static const _PrimeType* + _S_get_prime_list(); + }; + + template<typename _PrimeType> const _PrimeType + _Hashtable_prime_list<_PrimeType>::__stl_prime_list[_S_num_primes] = { 5ul, 53ul, 97ul, 193ul, 389ul, 769ul, 1543ul, 3079ul, 6151ul, 12289ul, @@ -220,11 +230,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION 805306457ul, 1610612741ul, 3221225473ul, 4294967291ul }; + template<class _PrimeType> inline const _PrimeType* + _Hashtable_prime_list<_PrimeType>::_S_get_prime_list() + { + return __stl_prime_list; + } + inline unsigned long __stl_next_prime(unsigned long __n) { - const unsigned long* __first = __stl_prime_list; - const unsigned long* __last = __stl_prime_list + (int)_S_num_primes; + const unsigned long* __first = _Hashtable_prime_list<unsigned long>::_S_get_prime_list(); + const unsigned long* __last = __first + (int)_S_num_primes; const unsigned long* pos = std::lower_bound(__first, __last, __n); return pos == __last ? *(__last - 1) : *pos; } @@ -418,7 +434,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_type max_bucket_count() const - { return __stl_prime_list[(int)_S_num_primes - 1]; } + { return _Hashtable_prime_list<unsigned long>:: + _S_get_prime_list()[(int)_S_num_primes - 1]; + } size_type elems_in_bucket(size_type __bucket) const diff --git a/gcc-4.6/libstdc++-v3/include/bits/basic_string.h b/gcc-4.6/libstdc++-v3/include/bits/basic_string.h index 102ef77..2f708b7 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/basic_string.h +++ b/gcc-4.6/libstdc++-v3/include/bits/basic_string.h @@ -2986,7 +2986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, string> { size_t - operator()(const string& __s) const + operator()(const string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length()); } }; @@ -2997,7 +2997,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, wstring> { size_t - operator()(const wstring& __s) const + operator()(const wstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } }; @@ -3011,7 +3011,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, u16string> { size_t - operator()(const u16string& __s) const + operator()(const u16string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char16_t)); } }; @@ -3022,7 +3022,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, u32string> { size_t - operator()(const u32string& __s) const + operator()(const u32string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; diff --git a/gcc-4.6/libstdc++-v3/include/bits/c++0x_warning.h b/gcc-4.6/libstdc++-v3/include/bits/c++0x_warning.h index 0685a50..eb072d0 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/c++0x_warning.h +++ b/gcc-4.6/libstdc++-v3/include/bits/c++0x_warning.h @@ -29,9 +29,9 @@ #define _CXX0X_WARNING_H 1 #ifndef __GXX_EXPERIMENTAL_CXX0X__ -#error This file requires compiler and library support for the upcoming \ -ISO C++ standard, C++0x. This support is currently experimental, and must be \ -enabled with the -std=c++0x or -std=gnu++0x compiler options. +#error This file requires compiler and library support for the \ +ISO C++ 2011 standard. This support is currently experimental, and must be \ +enabled with the -std=c++11 or -std=gnu++11 compiler options. #endif #endif diff --git a/gcc-4.6/libstdc++-v3/include/bits/c++config b/gcc-4.6/libstdc++-v3/include/bits/c++config index 8ac3c15..fce5247 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/c++config +++ b/gcc-4.6/libstdc++-v3/include/bits/c++config @@ -162,41 +162,42 @@ namespace std // Defined if inline namespaces are used for versioning. -#define _GLIBCXX_INLINE_VERSION +#define _GLIBCXX_INLINE_VERSION // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION + namespace std { - inline namespace _6 { } + inline namespace __7 { } - namespace rel_ops { inline namespace _6 { } } + namespace rel_ops { inline namespace __7 { } } namespace tr1 { - inline namespace _6 { } - namespace placeholders { inline namespace _6 { } } - namespace regex_constants { inline namespace _6 { } } - namespace __detail { inline namespace _6 { } } + inline namespace __7 { } + namespace placeholders { inline namespace __7 { } } + namespace regex_constants { inline namespace __7 { } } + namespace __detail { inline namespace __7 { } } } - namespace decimal { inline namespace _6 { } } + namespace decimal { inline namespace __7 { } } - namespace chrono { inline namespace _6 { } } - namespace placeholders { inline namespace _6 { } } - namespace regex_constants { inline namespace _6 { } } - namespace this_thread { inline namespace _6 { } } + namespace chrono { inline namespace __7 { } } + namespace placeholders { inline namespace __7 { } } + namespace regex_constants { inline namespace __7 { } } + namespace this_thread { inline namespace __7 { } } - namespace __detail { inline namespace _6 { } } - namespace __regex { inline namespace _6 { } } + namespace __detail { inline namespace __7 { } } + namespace __regex { inline namespace __7 { } } } namespace __gnu_cxx { - inline namespace _6 { } - namespace __detail { inline namespace _6 { } } + inline namespace __7 { } + namespace __detail { inline namespace __7 { } } } -# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace _6 { +# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 { # define _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -213,7 +214,7 @@ namespace std namespace __cxx1998 { #if _GLIBCXX_INLINE_VERSION - inline namespace _6 { } + inline namespace __7 { } #endif } diff --git a/gcc-4.6/libstdc++-v3/include/bits/deque.tcc b/gcc-4.6/libstdc++-v3/include/bits/deque.tcc index 389fc80..6381022 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/deque.tcc +++ b/gcc-4.6/libstdc++-v3/include/bits/deque.tcc @@ -218,7 +218,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER deque<_Tp, _Alloc>:: erase(iterator __first, iterator __last) { - if (__first == begin() && __last == end()) + if (__first == __last) + return __first; + else if (__first == begin() && __last == end()) { clear(); return end(); diff --git a/gcc-4.6/libstdc++-v3/include/bits/functional_hash.h b/gcc-4.6/libstdc++-v3/include/bits/functional_hash.h index e77cb4e..e892159 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/functional_hash.h +++ b/gcc-4.6/libstdc++-v3/include/bits/functional_hash.h @@ -57,8 +57,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct hash : public __hash_base<size_t, _Tp> { - size_t - operator()(_Tp __val) const; + static_assert(sizeof(_Tp) < 0, + "std::hash is not specialized for this type"); + size_t operator()(const _Tp&) const noexcept; }; /// Partial specializations for pointer types. @@ -66,61 +67,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash<_Tp*> : public __hash_base<size_t, _Tp*> { size_t - operator()(_Tp* __p) const + operator()(_Tp* __p) const noexcept { return reinterpret_cast<size_t>(__p); } }; // Explicit specializations for integer types. #define _Cxx_hashtable_define_trivial_hash(_Tp) \ template<> \ - inline size_t \ - hash<_Tp>::operator()(_Tp __val) const \ - { return static_cast<size_t>(__val); } + struct hash<_Tp> : public __hash_base<size_t, _Tp> \ + { \ + size_t \ + operator()(_Tp __val) const noexcept \ + { return static_cast<size_t>(__val); } \ + }; /// Explicit specialization for bool. - _Cxx_hashtable_define_trivial_hash(bool); + _Cxx_hashtable_define_trivial_hash(bool) /// Explicit specialization for char. - _Cxx_hashtable_define_trivial_hash(char); + _Cxx_hashtable_define_trivial_hash(char) /// Explicit specialization for signed char. - _Cxx_hashtable_define_trivial_hash(signed char); + _Cxx_hashtable_define_trivial_hash(signed char) /// Explicit specialization for unsigned char. - _Cxx_hashtable_define_trivial_hash(unsigned char); + _Cxx_hashtable_define_trivial_hash(unsigned char) /// Explicit specialization for wchar_t. - _Cxx_hashtable_define_trivial_hash(wchar_t); + _Cxx_hashtable_define_trivial_hash(wchar_t) /// Explicit specialization for char16_t. - _Cxx_hashtable_define_trivial_hash(char16_t); + _Cxx_hashtable_define_trivial_hash(char16_t) /// Explicit specialization for char32_t. - _Cxx_hashtable_define_trivial_hash(char32_t); + _Cxx_hashtable_define_trivial_hash(char32_t) /// Explicit specialization for short. - _Cxx_hashtable_define_trivial_hash(short); + _Cxx_hashtable_define_trivial_hash(short) /// Explicit specialization for int. - _Cxx_hashtable_define_trivial_hash(int); + _Cxx_hashtable_define_trivial_hash(int) /// Explicit specialization for long. - _Cxx_hashtable_define_trivial_hash(long); + _Cxx_hashtable_define_trivial_hash(long) /// Explicit specialization for long long. - _Cxx_hashtable_define_trivial_hash(long long); + _Cxx_hashtable_define_trivial_hash(long long) /// Explicit specialization for unsigned short. - _Cxx_hashtable_define_trivial_hash(unsigned short); + _Cxx_hashtable_define_trivial_hash(unsigned short) /// Explicit specialization for unsigned int. - _Cxx_hashtable_define_trivial_hash(unsigned int); + _Cxx_hashtable_define_trivial_hash(unsigned int) /// Explicit specialization for unsigned long. - _Cxx_hashtable_define_trivial_hash(unsigned long); + _Cxx_hashtable_define_trivial_hash(unsigned long) /// Explicit specialization for unsigned long long. - _Cxx_hashtable_define_trivial_hash(unsigned long long); + _Cxx_hashtable_define_trivial_hash(unsigned long long) #undef _Cxx_hashtable_define_trivial_hash @@ -162,26 +166,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Specialization for float. template<> - inline size_t - hash<float>::operator()(float __val) const + struct hash<float> : public __hash_base<size_t, float> { - // 0 and -0 both hash to zero. - return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0; - } + size_t + operator()(float __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0; + } + }; /// Specialization for double. template<> - inline size_t - hash<double>::operator()(double __val) const + struct hash<double> : public __hash_base<size_t, double> { - // 0 and -0 both hash to zero. - return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0; - } + size_t + operator()(double __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0; + } + }; /// Specialization for long double. template<> - _GLIBCXX_PURE size_t - hash<long double>::operator()(long double __val) const; + struct hash<long double> + : public __hash_base<size_t, long double> + { + _GLIBCXX_PURE size_t + operator()(long double __val) const noexcept; + }; // @} group hashes diff --git a/gcc-4.6/libstdc++-v3/include/bits/hashtable.h b/gcc-4.6/libstdc++-v3/include/bits/hashtable.h index f284126..8fdcfbf 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/hashtable.h +++ b/gcc-4.6/libstdc++-v3/include/bits/hashtable.h @@ -440,6 +440,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION iterator erase(const_iterator); + // LWG 2059. + iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + size_type erase(const key_type&); @@ -683,12 +688,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_element_count(__ht._M_element_count), _M_rehash_policy(__ht._M_rehash_policy) { - size_type __n_bkt = __ht._M_rehash_policy._M_next_bkt(0); - __ht._M_buckets = __ht._M_allocate_buckets(__n_bkt); - __ht._M_bucket_count = __n_bkt; + __ht._M_rehash_policy = _RehashPolicy(); + __ht._M_bucket_count = __ht._M_rehash_policy._M_next_bkt(0); + __ht._M_buckets = __ht._M_allocate_buckets(__ht._M_bucket_count); __ht._M_begin_bucket_index = __ht._M_bucket_count; __ht._M_element_count = 0; - __ht._M_rehash_policy = _RehashPolicy(); } template<typename _Key, typename _Value, diff --git a/gcc-4.6/libstdc++-v3/include/bits/random.tcc b/gcc-4.6/libstdc++-v3/include/bits/random.tcc index e81392f..b9f6af6 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/random.tcc +++ b/gcc-4.6/libstdc++-v3/include/bits/random.tcc @@ -2768,7 +2768,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Type __arg = (__begin[__k % __n] ^ __begin[(__k + __p) % __n] ^ __begin[(__k - 1) % __n]); - _Type __r1 = __arg ^ (__arg << 27); + _Type __r1 = __arg ^ (__arg >> 27); __r1 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, 1664525u, 0u>(__r1); _Type __r2 = __r1; @@ -2790,14 +2790,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Type __arg = (__begin[__k % __n] + __begin[(__k + __p) % __n] + __begin[(__k - 1) % __n]); - _Type __r3 = __arg ^ (__arg << 27); + _Type __r3 = __arg ^ (__arg >> 27); __r3 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, 1566083941u, 0u>(__r3); _Type __r4 = __r3 - __k % __n; __r4 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value>(__r4); - __begin[(__k + __p) % __n] ^= __r4; - __begin[(__k + __q) % __n] ^= __r3; + __begin[(__k + __p) % __n] ^= __r3; + __begin[(__k + __q) % __n] ^= __r4; __begin[__k % __n] = __r4; } } diff --git a/gcc-4.6/libstdc++-v3/include/bits/regex.h b/gcc-4.6/libstdc++-v3/include/bits/regex.h index f29ee91..2bea0c3 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/regex.h +++ b/gcc-4.6/libstdc++-v3/include/bits/regex.h @@ -2219,7 +2219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION regex_constants::match_flag_type __flags = regex_constants::match_default) { - std::string __result; + basic_string<_Ch_type> __result; regex_replace(std::back_inserter(__result), __s.begin(), __s.end(), __e, __fmt, __flags); return __result; diff --git a/gcc-4.6/libstdc++-v3/include/bits/shared_ptr.h b/gcc-4.6/libstdc++-v3/include/bits/shared_ptr.h index 97d123f..81ac382 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/shared_ptr.h +++ b/gcc-4.6/libstdc++-v3/include/bits/shared_ptr.h @@ -100,6 +100,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr shared_ptr() : __shared_ptr<_Tp>() { } + shared_ptr(const shared_ptr&) = default; // never throws + /** * @brief Construct a %shared_ptr that owns the pointer @a __p. * @param __p A pointer that is convertible to element_type*. @@ -264,6 +266,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr shared_ptr(nullptr_t __p) : __shared_ptr<_Tp>(__p) { } + shared_ptr& operator=(const shared_ptr&) = default; + template<typename _Tp1> shared_ptr& operator=(const shared_ptr<_Tp1>& __r) // never throws @@ -543,8 +547,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION make_shared(_Args&&... __args) { typedef typename std::remove_const<_Tp>::type _Tp_nc; - return allocate_shared<_Tp>(std::allocator<_Tp_nc>(), - std::forward<_Args>(__args)...); + return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); } /// std::hash specialization for shared_ptr. @@ -553,7 +557,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public std::unary_function<shared_ptr<_Tp>, size_t> { size_t - operator()(const shared_ptr<_Tp>& __s) const + operator()(const shared_ptr<_Tp>& __s) const noexcept { return std::hash<_Tp*>()(__s.get()); } }; diff --git a/gcc-4.6/libstdc++-v3/include/bits/shared_ptr_base.h b/gcc-4.6/libstdc++-v3/include/bits/shared_ptr_base.h index 72bc4f0..7badc39 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/gcc-4.6/libstdc++-v3/include/bits/shared_ptr_base.h @@ -799,7 +799,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws { } - // generated copy constructor, assignment, destructor are fine. + __shared_ptr(const __shared_ptr&) = default; // never throws + __shared_ptr& operator=(const __shared_ptr&) = default; // never throws template<typename _Tp1, typename = typename std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> @@ -1365,8 +1366,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __make_shared(_Args&&... __args) { typedef typename std::remove_const<_Tp>::type _Tp_nc; - return __allocate_shared<_Tp, _Lp>(std::allocator<_Tp_nc>(), - std::forward<_Args>(__args)...); + return std::__allocate_shared<_Tp, _Lp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); } /// std::hash specialization for __shared_ptr. @@ -1375,7 +1376,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public std::unary_function<__shared_ptr<_Tp, _Lp>, size_t> { size_t - operator()(const __shared_ptr<_Tp, _Lp>& __s) const + operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept { return std::hash<_Tp*>()(__s.get()); } }; diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_algo.h b/gcc-4.6/libstdc++-v3/include/bits/stl_algo.h index 6c2be06..1d6026a 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_algo.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_algo.h @@ -2751,20 +2751,76 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // merge - /// This is a helper function for the merge routines. + /// This is a helper function for the __merge_adaptive routines. + template<typename _InputIterator1, typename _InputIterator2, + typename _OutputIterator> + void + __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (*__first2 < *__first1) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + if (__first1 != __last1) + _GLIBCXX_MOVE3(__first1, __last1, __result); + } + + /// This is a helper function for the __merge_adaptive routines. + template<typename _InputIterator1, typename _InputIterator2, + typename _OutputIterator, typename _Compare> + void + __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(*__first2, *__first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + if (__first1 != __last1) + _GLIBCXX_MOVE3(__first1, __last1, __result); + } + + /// This is a helper function for the __merge_adaptive routines. template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BidirectionalIterator3> - _BidirectionalIterator3 - __move_merge_backward(_BidirectionalIterator1 __first1, - _BidirectionalIterator1 __last1, - _BidirectionalIterator2 __first2, - _BidirectionalIterator2 __last2, - _BidirectionalIterator3 __result) + void + __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + _BidirectionalIterator3 __result) { if (__first1 == __last1) - return _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); - if (__first2 == __last2) - return _GLIBCXX_MOVE_BACKWARD3(__first1, __last1, __result); + { + _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); + return; + } + else if (__first2 == __last2) + return; + --__last1; --__last2; while (true) @@ -2773,34 +2829,41 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { *--__result = _GLIBCXX_MOVE(*__last1); if (__first1 == __last1) - return _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + { + _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + return; + } --__last1; } else { *--__result = _GLIBCXX_MOVE(*__last2); if (__first2 == __last2) - return _GLIBCXX_MOVE_BACKWARD3(__first1, ++__last1, __result); + return; --__last2; } } } - /// This is a helper function for the merge routines. + /// This is a helper function for the __merge_adaptive routines. template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BidirectionalIterator3, typename _Compare> - _BidirectionalIterator3 - __move_merge_backward(_BidirectionalIterator1 __first1, - _BidirectionalIterator1 __last1, - _BidirectionalIterator2 __first2, - _BidirectionalIterator2 __last2, - _BidirectionalIterator3 __result, - _Compare __comp) + void + __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + _BidirectionalIterator3 __result, + _Compare __comp) { if (__first1 == __last1) - return _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); - if (__first2 == __last2) - return _GLIBCXX_MOVE_BACKWARD3(__first1, __last1, __result); + { + _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); + return; + } + else if (__first2 == __last2) + return; + --__last1; --__last2; while (true) @@ -2809,75 +2872,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { *--__result = _GLIBCXX_MOVE(*__last1); if (__first1 == __last1) - return _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + { + _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + return; + } --__last1; } else { *--__result = _GLIBCXX_MOVE(*__last2); if (__first2 == __last2) - return _GLIBCXX_MOVE_BACKWARD3(__first1, ++__last1, __result); + return; --__last2; } } } /// This is a helper function for the merge routines. - template<typename _InputIterator1, typename _InputIterator2, - typename _OutputIterator> - _OutputIterator - __move_merge(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _InputIterator2 __last2, - _OutputIterator __result) - { - while (__first1 != __last1 && __first2 != __last2) - { - if (*__first2 < *__first1) - { - *__result = _GLIBCXX_MOVE(*__first2); - ++__first2; - } - else - { - *__result = _GLIBCXX_MOVE(*__first1); - ++__first1; - } - ++__result; - } - return _GLIBCXX_MOVE3(__first2, __last2, - _GLIBCXX_MOVE3(__first1, __last1, - __result)); - } - - /// This is a helper function for the merge routines. - template<typename _InputIterator1, typename _InputIterator2, - typename _OutputIterator, typename _Compare> - _OutputIterator - __move_merge(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _InputIterator2 __last2, - _OutputIterator __result, _Compare __comp) - { - while (__first1 != __last1 && __first2 != __last2) - { - if (__comp(*__first2, *__first1)) - { - *__result = _GLIBCXX_MOVE(*__first2); - ++__first2; - } - else - { - *__result = _GLIBCXX_MOVE(*__first1); - ++__first1; - } - ++__result; - } - return _GLIBCXX_MOVE3(__first2, __last2, - _GLIBCXX_MOVE3(__first1, __last1, - __result)); - } - - - /// This is a helper function for the merge routines. template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _Distance> _BidirectionalIterator1 @@ -2891,15 +2902,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _BidirectionalIterator2 __buffer_end; if (__len1 > __len2 && __len2 <= __buffer_size) { - __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); - _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last); - return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first); + if (__len2) + { + __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); + _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last); + return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first); + } + else + return __first; } else if (__len1 <= __buffer_size) { - __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); - _GLIBCXX_MOVE3(__middle, __last, __first); - return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last); + if (__len1) + { + __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); + _GLIBCXX_MOVE3(__middle, __last, __first); + return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last); + } + else + return __last; } else { @@ -2922,13 +2943,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__len1 <= __len2 && __len1 <= __buffer_size) { _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); - std::__move_merge(__buffer, __buffer_end, __middle, __last, __first); + std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last, + __first); } else if (__len2 <= __buffer_size) { _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); - std::__move_merge_backward(__first, __middle, __buffer, - __buffer_end, __last); + std::__move_merge_adaptive_backward(__first, __middle, __buffer, + __buffer_end, __last); } else { @@ -2978,14 +3000,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__len1 <= __len2 && __len1 <= __buffer_size) { _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); - std::__move_merge(__buffer, __buffer_end, __middle, __last, - __first, __comp); + std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last, + __first, __comp); } else if (__len2 <= __buffer_size) { _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); - std::__move_merge_backward(__first, __middle, __buffer, __buffer_end, - __last, __comp); + std::__move_merge_adaptive_backward(__first, __middle, __buffer, + __buffer_end, __last, __comp); } else { @@ -3222,6 +3244,61 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __CheckedCompare(__comp)); } + + /// This is a helper function for the __merge_sort_loop routines. + template<typename _InputIterator1, typename _InputIterator2, + typename _OutputIterator> + _OutputIterator + __move_merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (*__first2 < *__first1) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + return _GLIBCXX_MOVE3(__first2, __last2, + _GLIBCXX_MOVE3(__first1, __last1, + __result)); + } + + /// This is a helper function for the __merge_sort_loop routines. + template<typename _InputIterator1, typename _InputIterator2, + typename _OutputIterator, typename _Compare> + _OutputIterator + __move_merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(*__first2, *__first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + return _GLIBCXX_MOVE3(__first2, __last2, + _GLIBCXX_MOVE3(__first1, __last1, + __result)); + } + template<typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _Distance> void diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_algobase.h b/gcc-4.6/libstdc++-v3/include/bits/stl_algobase.h index 626d5bf..aecdcb9 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_algobase.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_algobase.h @@ -641,7 +641,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * loop count will be known (and therefore a candidate for compiler * optimizations such as unrolling). * - * Result may not be in the range [first,last). Use move instead. Note + * Result may not be in the range (first,last]. Use move instead. Note * that the start of the output range may overlap [first,last). */ template<typename _BI1, typename _BI2> diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_bvector.h b/gcc-4.6/libstdc++-v3/include/bits/stl_bvector.h index 3cd53e7..5bf10d9 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_bvector.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_bvector.h @@ -821,7 +821,8 @@ template<typename _Alloc> iterator erase(iterator __first, iterator __last) { - _M_erase_at_end(std::copy(__last, end(), __first)); + if (__first != __last) + _M_erase_at_end(std::copy(__last, end(), __first)); return __first; } @@ -1049,7 +1050,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>> { size_t - operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const; + operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>&) const noexcept; }; _GLIBCXX_END_NAMESPACE_VERSION diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_map.h b/gcc-4.6/libstdc++-v3/include/bits/stl_map.h index a84b4b6..a1bef8b 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_map.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_map.h @@ -612,6 +612,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator erase(const_iterator __position) { return _M_t.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_t.erase(__position); } #else /** * @brief Erases an element from a %map. diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_multimap.h b/gcc-4.6/libstdc++-v3/include/bits/stl_multimap.h index ca37f35..02e8f58 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_multimap.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_multimap.h @@ -533,6 +533,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator erase(const_iterator __position) { return _M_t.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_t.erase(__position); } #else /** * @brief Erases an element from a %multimap. diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_numeric.h b/gcc-4.6/libstdc++-v3/include/bits/stl_numeric.h index 1b6998d..6cbc6d2 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_numeric.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_numeric.h @@ -222,10 +222,10 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO /** * @brief Return list of partial sums * - * Accumulates the values in the range [first,last) using operator+(). + * Accumulates the values in the range [first,last) using the @c + operator. * As each successive input value is added into the total, that partial sum - * is written to @a result. Therefore, the first value in result is the - * first value of the input, the second value in result is the sum of the + * is written to @p result. Therefore, the first value in @p result is the + * first value of the input, the second value in @p result is the sum of the * first and second input values, and so on. * * @param first Start of input range. @@ -261,15 +261,16 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO /** * @brief Return list of partial sums * - * Accumulates the values in the range [first,last) using operator+(). + * Accumulates the values in the range [first,last) using @p binary_op. * As each successive input value is added into the total, that partial sum - * is written to @a result. Therefore, the first value in result is the - * first value of the input, the second value in result is the sum of the + * is written to @a result. Therefore, the first value in @p result is the + * first value of the input, the second value in @p result is the sum of the * first and second input values, and so on. * * @param first Start of input range. * @param last End of input range. * @param result Output to write sums to. + * @param binary_op Function object. * @return Iterator pointing just beyond the values written to result. */ template<typename _InputIterator, typename _OutputIterator, diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_tree.h b/gcc-4.6/libstdc++-v3/include/bits/stl_tree.h index 7567e20..a7e9564 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_tree.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_tree.h @@ -800,6 +800,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_erase_aux(__position); return __result._M_const_cast(); } + + // LWG 2059. + iterator + erase(iterator __position) + { + iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result; + } #else void erase(iterator __position) diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_uninitialized.h b/gcc-4.6/libstdc++-v3/include/bits/stl_uninitialized.h index f15be3a..70ce545 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_uninitialized.h @@ -1,7 +1,7 @@ // Raw memory manipulators -*- C++ -*- // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, -// 2009, 2010 +// 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -530,6 +530,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __uninit_default_n(__first, __n); } + template<typename _Tp, typename _Allocator> + inline auto + _Construct_default_a_impl(_Tp* __ptr, _Allocator& __alloc, void*) + -> decltype(__alloc.construct(__ptr)) + { return __alloc.construct(__ptr); } + + template<typename _Tp, typename _Allocator> + inline void + _Construct_default_a_impl(_Tp* __ptr, _Allocator& __alloc, ...) + { _Construct(__ptr); } + + template<typename _Tp, typename _Allocator> + inline void + _Construct_default_a(_Tp* __ptr, _Allocator& __alloc) + { _Construct_default_a_impl(__ptr, __alloc, nullptr); } // __uninitialized_default_a // Fills [first, last) with std::distance(first, last) default @@ -544,7 +559,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __try { for (; __cur != __last; ++__cur) - __alloc.construct(std::__addressof(*__cur)); + _Construct_default_a(std::__addressof(*__cur), __alloc); } __catch(...) { @@ -573,7 +588,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __try { for (; __n > 0; --__n, ++__cur) - __alloc.construct(std::__addressof(*__cur)); + _Construct_default_a(std::__addressof(*__cur), __alloc); } __catch(...) { diff --git a/gcc-4.6/libstdc++-v3/include/bits/stl_vector.h b/gcc-4.6/libstdc++-v3/include/bits/stl_vector.h index 92137b6..8b7fdb1 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/stl_vector.h +++ b/gcc-4.6/libstdc++-v3/include/bits/stl_vector.h @@ -208,6 +208,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER using _Base::_M_impl; using _Base::_M_get_Tp_allocator; + bool _M_is_valid() const + { + return (this->_M_impl._M_end_of_storage == 0 + && this->_M_impl._M_start == 0 + && this->_M_impl._M_finish == 0) + || (this->_M_impl._M_start <= this->_M_impl._M_finish + && this->_M_impl._M_finish <= this->_M_impl._M_end_of_storage + && this->_M_impl._M_start < this->_M_impl._M_end_of_storage); + } + public: // [23.2.4.1] construct/copy/destroy // (assign() and get_allocator() are also listed in this section) @@ -461,7 +471,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator begin() - { return iterator(this->_M_impl._M_start); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("begin() on corrupt (dangling?) vector"); +#endif + return iterator(this->_M_impl._M_start); + } /** * Returns a read-only (constant) iterator that points to the @@ -470,7 +486,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_iterator begin() const - { return const_iterator(this->_M_impl._M_start); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("begin() on corrupt (dangling?) vector"); +#endif + return const_iterator(this->_M_impl._M_start); + } /** * Returns a read/write iterator that points one past the last @@ -479,7 +501,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator end() - { return iterator(this->_M_impl._M_finish); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("end() on corrupt (dangling?) vector"); +#endif + return iterator(this->_M_impl._M_finish); + } /** * Returns a read-only (constant) iterator that points one past @@ -488,7 +516,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_iterator end() const - { return const_iterator(this->_M_impl._M_finish); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("end() on corrupt (dangling?) vector"); +#endif + return const_iterator(this->_M_impl._M_finish); + } /** * Returns a read/write reverse iterator that points to the @@ -568,7 +602,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** Returns the number of elements in the %vector. */ size_type size() const - { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("size() on corrupt (dangling?) vector"); +#endif + return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); + } /** Returns the size() of the largest possible %vector. */ size_type @@ -648,7 +688,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ size_type capacity() const - { return size_type(this->_M_impl._M_end_of_storage + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("capacity() on corrupt (dangling?) vector"); +#endif + return size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_start); } /** @@ -1034,6 +1079,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void swap(vector& __x) { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid() || !__x._M_is_valid()) + __throw_logic_error("swap() on corrupt (dangling?) vector"); +#endif std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_end_of_storage, @@ -1053,7 +1102,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void clear() - { _M_erase_at_end(this->_M_impl._M_start); } + { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid()) + __throw_logic_error("clear() on corrupt (dangling?) vector"); +#endif + _M_erase_at_end(this->_M_impl._M_start); + } protected: /** diff --git a/gcc-4.6/libstdc++-v3/include/bits/unique_ptr.h b/gcc-4.6/libstdc++-v3/include/bits/unique_ptr.h index 9d5d206..cb2d860 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/unique_ptr.h +++ b/gcc-4.6/libstdc++-v3/include/bits/unique_ptr.h @@ -496,7 +496,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public std::unary_function<unique_ptr<_Tp, _Dp>, size_t> { size_t - operator()(const unique_ptr<_Tp, _Dp>& __u) const + operator()(const unique_ptr<_Tp, _Dp>& __u) const noexcept { typedef unique_ptr<_Tp, _Dp> _UP; return std::hash<typename _UP::pointer>()(__u.get()); diff --git a/gcc-4.6/libstdc++-v3/include/bits/vector.tcc b/gcc-4.6/libstdc++-v3/include/bits/vector.tcc index 3aaee39..cd23f76 100644 --- a/gcc-4.6/libstdc++-v3/include/bits/vector.tcc +++ b/gcc-4.6/libstdc++-v3/include/bits/vector.tcc @@ -147,9 +147,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector<_Tp, _Alloc>:: erase(iterator __first, iterator __last) { - if (__last != end()) - _GLIBCXX_MOVE3(__last, end(), __first); - _M_erase_at_end(__first.base() + (end() - __last)); + if (__first != __last) + { + if (__last != end()) + _GLIBCXX_MOVE3(__last, end(), __first); + _M_erase_at_end(__first.base() + (end() - __last)); + } return __first; } @@ -158,6 +161,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector<_Tp, _Alloc>:: operator=(const vector<_Tp, _Alloc>& __x) { +#if __google_stl_debug_dangling_vector + if (!this->_M_is_valid() || !__x._M_is_valid()) + __throw_logic_error("operator=() on corrupt (dangling?) vector"); +#endif if (&__x != this) { const size_type __xlen = __x.size(); @@ -743,7 +750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Alloc> size_t hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>:: - operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const + operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept { size_t __hash = 0; using _GLIBCXX_STD_C::_S_word_bit; diff --git a/gcc-4.6/libstdc++-v3/include/c_global/cmath b/gcc-4.6/libstdc++-v3/include/c_global/cmath index e38ab9d..6e8cd13 100644 --- a/gcc-4.6/libstdc++-v3/include/c_global/cmath +++ b/gcc-4.6/libstdc++-v3/include/c_global/cmath @@ -156,10 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Up> inline - typename __gnu_cxx::__promote_2< - typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value - && __is_arithmetic<_Up>::__value, - _Tp>::__type, _Up>::__type + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type atan2(_Tp __y, _Up __x) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -374,10 +371,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Up> inline - typename __gnu_cxx::__promote_2< - typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value - && __is_arithmetic<_Up>::__value, - _Tp>::__type, _Up>::__type + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type pow(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; diff --git a/gcc-4.6/libstdc++-v3/include/c_global/cwchar b/gcc-4.6/libstdc++-v3/include/c_global/cwchar index 5a33965..a2b1168 100644 --- a/gcc-4.6/libstdc++-v3/include/c_global/cwchar +++ b/gcc-4.6/libstdc++-v3/include/c_global/cwchar @@ -136,6 +136,8 @@ namespace std namespace std _GLIBCXX_VISIBILITY(default) { +_GLIBCXX_BEGIN_NAMESPACE_VERSION + using ::wint_t; using ::btowc; @@ -207,8 +209,6 @@ namespace std _GLIBCXX_VISIBILITY(default) using ::wcsstr; using ::wmemchr; -_GLIBCXX_BEGIN_NAMESPACE_VERSION - #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO inline wchar_t* wcschr(wchar_t* __p, wchar_t __c) diff --git a/gcc-4.6/libstdc++-v3/include/debug/bitset b/gcc-4.6/libstdc++-v3/include/debug/bitset index c187545..09929e7 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/bitset +++ b/gcc-4.6/libstdc++-v3/include/debug/bitset @@ -409,7 +409,7 @@ namespace __debug : public __hash_base<size_t, __debug::bitset<_Nb>> { size_t - operator()(const __debug::bitset<_Nb>& __b) const + operator()(const __debug::bitset<_Nb>& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); } }; #endif diff --git a/gcc-4.6/libstdc++-v3/include/debug/deque b/gcc-4.6/libstdc++-v3/include/debug/deque index ee17f20..fc4d8cb 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/deque +++ b/gcc-4.6/libstdc++-v3/include/debug/deque @@ -460,7 +460,11 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container __glibcxx_check_erase_range(__first, __last); - if (__first.base() == _Base::begin() || __last.base() == _Base::end()) + + if (__first.base() == __last.base()) + return __first; + else if (__first.base() == _Base::begin() + || __last.base() == _Base::end()) { this->_M_detach_singular(); for (_Base_iterator __position = __first.base(); diff --git a/gcc-4.6/libstdc++-v3/include/debug/map.h b/gcc-4.6/libstdc++-v3/include/debug/map.h index 3108519..177797d 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/map.h +++ b/gcc-4.6/libstdc++-v3/include/debug/map.h @@ -273,6 +273,10 @@ namespace __debug this->_M_invalidate_if(_Equal(__position.base())); return iterator(_Base::erase(__position.base()), this); } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/gcc-4.6/libstdc++-v3/include/debug/multimap.h b/gcc-4.6/libstdc++-v3/include/debug/multimap.h index 3c22517..d2e1976 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/multimap.h +++ b/gcc-4.6/libstdc++-v3/include/debug/multimap.h @@ -254,6 +254,10 @@ namespace __debug this->_M_invalidate_if(_Equal(__position.base())); return iterator(_Base::erase(__position.base()), this); } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/gcc-4.6/libstdc++-v3/include/debug/unordered_map b/gcc-4.6/libstdc++-v3/include/debug/unordered_map index 2d7e100..43b1e9c 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/unordered_map +++ b/gcc-4.6/libstdc++-v3/include/debug/unordered_map @@ -276,6 +276,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); @@ -558,6 +562,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); diff --git a/gcc-4.6/libstdc++-v3/include/debug/unordered_set b/gcc-4.6/libstdc++-v3/include/debug/unordered_set index e30f976..cf21a3c 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/unordered_set +++ b/gcc-4.6/libstdc++-v3/include/debug/unordered_set @@ -269,6 +269,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); @@ -539,6 +543,10 @@ namespace __debug } iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + iterator erase(const_iterator __first, const_iterator __last) { __glibcxx_check_erase_range(__first, __last); diff --git a/gcc-4.6/libstdc++-v3/include/debug/vector b/gcc-4.6/libstdc++-v3/include/debug/vector index e2dd71a..edb1f88 100644 --- a/gcc-4.6/libstdc++-v3/include/debug/vector +++ b/gcc-4.6/libstdc++-v3/include/debug/vector @@ -492,11 +492,16 @@ namespace __debug // 151. can't currently clear() empty container __glibcxx_check_erase_range(__first, __last); - difference_type __offset = __first.base() - _Base::begin(); - _Base_iterator __res = _Base::erase(__first.base(), - __last.base()); - this->_M_invalidate_after_nth(__offset); - return iterator(__res, this); + if (__first.base() != __last.base()) + { + difference_type __offset = __first.base() - _Base::begin(); + _Base_iterator __res = _Base::erase(__first.base(), + __last.base()); + this->_M_invalidate_after_nth(__offset); + return iterator(__res, this); + } + else + return __first; } void @@ -594,7 +599,7 @@ namespace __debug : public __hash_base<size_t, __debug::vector<bool, _Alloc>> { size_t - operator()(const __debug::vector<bool, _Alloc>& __b) const + operator()(const __debug::vector<bool, _Alloc>& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>() (__b._M_base()); } }; diff --git a/gcc-4.6/libstdc++-v3/include/ext/type_traits.h b/gcc-4.6/libstdc++-v3/include/ext/type_traits.h index 9274726..51db03e 100644 --- a/gcc-4.6/libstdc++-v3/include/ext/type_traits.h +++ b/gcc-4.6/libstdc++-v3/include/ext/type_traits.h @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 +// 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 terms @@ -161,44 +162,50 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __promote { typedef double __type; }; + // No nested __type member for non-integer non-floating point types, + // allows this type to be used for SFINAE to constrain overloads in + // <cmath> and <complex> to only the intended types. template<typename _Tp> struct __promote<_Tp, false> - { typedef _Tp __type; }; + { }; + + template<> + struct __promote<long double> + { typedef long double __type; }; + + template<> + struct __promote<double> + { typedef double __type; }; + + template<> + struct __promote<float> + { typedef float __type; }; - template<typename _Tp, typename _Up> + template<typename _Tp, typename _Up, + typename _Tp2 = typename __promote<_Tp>::__type, + typename _Up2 = typename __promote<_Up>::__type> struct __promote_2 { - private: - typedef typename __promote<_Tp>::__type __type1; - typedef typename __promote<_Up>::__type __type2; - - public: - typedef __typeof__(__type1() + __type2()) __type; + typedef __typeof__(_Tp2() + _Up2()) __type; }; - template<typename _Tp, typename _Up, typename _Vp> + template<typename _Tp, typename _Up, typename _Vp, + typename _Tp2 = typename __promote<_Tp>::__type, + typename _Up2 = typename __promote<_Up>::__type, + typename _Vp2 = typename __promote<_Vp>::__type> struct __promote_3 { - private: - typedef typename __promote<_Tp>::__type __type1; - typedef typename __promote<_Up>::__type __type2; - typedef typename __promote<_Vp>::__type __type3; - - public: - typedef __typeof__(__type1() + __type2() + __type3()) __type; + typedef __typeof__(_Tp2() + _Up2() + _Vp2()) __type; }; - template<typename _Tp, typename _Up, typename _Vp, typename _Wp> + template<typename _Tp, typename _Up, typename _Vp, typename _Wp, + typename _Tp2 = typename __promote<_Tp>::__type, + typename _Up2 = typename __promote<_Up>::__type, + typename _Vp2 = typename __promote<_Vp>::__type, + typename _Wp2 = typename __promote<_Wp>::__type> struct __promote_4 { - private: - typedef typename __promote<_Tp>::__type __type1; - typedef typename __promote<_Up>::__type __type2; - typedef typename __promote<_Vp>::__type __type3; - typedef typename __promote<_Wp>::__type __type4; - - public: - typedef __typeof__(__type1() + __type2() + __type3() + __type4()) __type; + typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type; }; _GLIBCXX_END_NAMESPACE_VERSION diff --git a/gcc-4.6/libstdc++-v3/include/ext/vstring.h b/gcc-4.6/libstdc++-v3/include/ext/vstring.h index 57f36a6..19df375 100644 --- a/gcc-4.6/libstdc++-v3/include/ext/vstring.h +++ b/gcc-4.6/libstdc++-v3/include/ext/vstring.h @@ -2760,7 +2760,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, __gnu_cxx::__vstring> { size_t - operator()(const __gnu_cxx::__vstring& __s) const + operator()(const __gnu_cxx::__vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length()); } }; @@ -2771,7 +2771,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, __gnu_cxx::__wvstring> { size_t - operator()(const __gnu_cxx::__wvstring& __s) const + operator()(const __gnu_cxx::__wvstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } }; @@ -2784,7 +2784,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, __gnu_cxx::__u16vstring> { size_t - operator()(const __gnu_cxx::__u16vstring& __s) const + operator()(const __gnu_cxx::__u16vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char16_t)); } }; @@ -2795,7 +2795,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, __gnu_cxx::__u32vstring> { size_t - operator()(const __gnu_cxx::__u32vstring& __s) const + operator()(const __gnu_cxx::__u32vstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; diff --git a/gcc-4.6/libstdc++-v3/include/parallel/algo.h b/gcc-4.6/libstdc++-v3/include/parallel/algo.h index 89b7f6d..b27de9b 100644 --- a/gcc-4.6/libstdc++-v3/include/parallel/algo.h +++ b/gcc-4.6/libstdc++-v3/include/parallel/algo.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010, 2011 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 terms @@ -273,12 +273,12 @@ namespace __parallel _BinaryPredicate __comp) { typedef std::iterator_traits<_IIter> _IIterTraits; - typedef std::iterator_traits<_FIterator> iteratorf_traits; + typedef std::iterator_traits<_FIterator> _FIterTraits; typedef typename _IIterTraits::iterator_category _IIteratorCategory; - typedef typename iteratorf_traits::iterator_category iteratorf_category; + typedef typename _FIterTraits::iterator_category _FIteratorCategory; return __find_first_of_switch(__begin1, __end1, __begin2, __end2, __comp, - _IIteratorCategory(), iteratorf_category()); + _IIteratorCategory(), _FIteratorCategory()); } // Public interface, insert default comparator @@ -288,9 +288,9 @@ namespace __parallel _FIterator __begin2, _FIterator __end2) { typedef std::iterator_traits<_IIter> _IIterTraits; - typedef std::iterator_traits<_FIterator> iteratorf_traits; + typedef std::iterator_traits<_FIterator> _FIterTraits; typedef typename _IIterTraits::value_type _IValueType; - typedef typename iteratorf_traits::value_type _FValueType; + typedef typename _FIterTraits::value_type _FValueType; return __gnu_parallel::find_first_of(__begin1, __end1, __begin2, __end2, __gnu_parallel::_EqualTo<_IValueType, _FValueType>()); diff --git a/gcc-4.6/libstdc++-v3/include/profile/bitset b/gcc-4.6/libstdc++-v3/include/profile/bitset index a995afa..381f1ea 100644 --- a/gcc-4.6/libstdc++-v3/include/profile/bitset +++ b/gcc-4.6/libstdc++-v3/include/profile/bitset @@ -367,7 +367,7 @@ namespace __profile : public __hash_base<size_t, __profile::bitset<_Nb>> { size_t - operator()(const __profile::bitset<_Nb>& __b) const + operator()(const __profile::bitset<_Nb>& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); } }; #endif diff --git a/gcc-4.6/libstdc++-v3/include/profile/map.h b/gcc-4.6/libstdc++-v3/include/profile/map.h index 1edc16c..a58a2b0 100644 --- a/gcc-4.6/libstdc++-v3/include/profile/map.h +++ b/gcc-4.6/libstdc++-v3/include/profile/map.h @@ -326,6 +326,10 @@ namespace __profile __profcxx_map_to_unordered_map_erase(this, size(), 1); return __i; } + + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } #else void erase(iterator __position) diff --git a/gcc-4.6/libstdc++-v3/include/profile/multimap.h b/gcc-4.6/libstdc++-v3/include/profile/multimap.h index 76ce805..3ee169b 100644 --- a/gcc-4.6/libstdc++-v3/include/profile/multimap.h +++ b/gcc-4.6/libstdc++-v3/include/profile/multimap.h @@ -225,6 +225,10 @@ namespace __profile iterator erase(const_iterator __position) { return iterator(_Base::erase(__position)); } + + iterator + erase(iterator __position) + { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) diff --git a/gcc-4.6/libstdc++-v3/include/profile/vector b/gcc-4.6/libstdc++-v3/include/profile/vector index f8a9622..3e81c0f 100644 --- a/gcc-4.6/libstdc++-v3/include/profile/vector +++ b/gcc-4.6/libstdc++-v3/include/profile/vector @@ -508,7 +508,7 @@ namespace __profile : public __hash_base<size_t, __profile::vector<bool, _Alloc>> { size_t - operator()(const __profile::vector<bool, _Alloc>& __b) const + operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>() (__b._M_base()); } }; diff --git a/gcc-4.6/libstdc++-v3/include/std/bitset b/gcc-4.6/libstdc++-v3/include/std/bitset index e0e8f13..ee771be 100644 --- a/gcc-4.6/libstdc++-v3/include/std/bitset +++ b/gcc-4.6/libstdc++-v3/include/std/bitset @@ -52,11 +52,13 @@ #include <iosfwd> #include <bits/cxxabi_forced.h> -#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long)) +#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__) #define _GLIBCXX_BITSET_WORDS(__n) \ ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \ ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1)) +#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_CONTAINER @@ -654,6 +656,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _S_do_sanitize(_WordT) { } }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<size_t _Nb, bool = _Nb < _GLIBCXX_BITSET_BITS_PER_ULL> + struct _Sanitize_val + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val; } + }; + + template<size_t _Nb> + struct _Sanitize_val<_Nb, true> + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val & ~((~static_cast<unsigned long long>(0)) << _Nb); } + }; +#endif + /** * @brief The %bitset class represents a @e fixed-size sequence of bits. * @@ -819,7 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /// Initial bits bitwise-copied from a single word (others set to zero). #ifdef __GXX_EXPERIMENTAL_CXX0X__ constexpr bitset(unsigned long long __val) - : _Base(__val) { } + : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { } #else bitset(unsigned long __val) : _Base(__val) @@ -1509,6 +1529,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER #undef _GLIBCXX_BITSET_WORDS #undef _GLIBCXX_BITSET_BITS_PER_WORD +#undef _GLIBCXX_BITSET_BITS_PER_ULL #ifdef __GXX_EXPERIMENTAL_CXX0X__ @@ -1525,7 +1546,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>> { size_t - operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const + operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept { const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__; return std::_Hash_impl::hash(__b._M_getdata(), __clength); @@ -1537,7 +1558,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>> { size_t - operator()(const _GLIBCXX_STD_C::bitset<0>&) const + operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept { return 0; } }; diff --git a/gcc-4.6/libstdc++-v3/include/std/complex b/gcc-4.6/libstdc++-v3/include/std/complex index aa6e81d..da3c469 100644 --- a/gcc-4.6/libstdc++-v3/include/std/complex +++ b/gcc-4.6/libstdc++-v3/include/std/complex @@ -1,7 +1,7 @@ // The template and inlines for the -*- C++ -*- complex number classes. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008, 2009, 2010 +// 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1695,12 +1695,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::complex<_Tp> __complex_acosh(const std::complex<_Tp>& __z) { - std::complex<_Tp> __t((__z.real() - __z.imag()) - * (__z.real() + __z.imag()) - _Tp(1.0), - _Tp(2.0) * __z.real() * __z.imag()); - __t = std::sqrt(__t); - - return std::log(__t + __z); + // Kahan's formula. + return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0))) + + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); } #if _GLIBCXX_USE_C99_COMPLEX_TR1 diff --git a/gcc-4.6/libstdc++-v3/include/std/condition_variable b/gcc-4.6/libstdc++-v3/include/std/condition_variable index a0a3c08..ff65dc4 100644 --- a/gcc-4.6/libstdc++-v3/include/std/condition_variable +++ b/gcc-4.6/libstdc++-v3/include/std/condition_variable @@ -198,10 +198,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void wait(_Lock& __lock) { - unique_lock<mutex> __my_lock(_M_mutex); - __lock.unlock(); - _M_cond.wait(__my_lock); - __lock.lock(); + // scoped unlock - unlocks in ctor, re-locks in dtor + struct _Unlock { + explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); } + ~_Unlock() noexcept(false) + { + if (uncaught_exception()) + __try { _M_lock.lock(); } __catch(...) { } + else + _M_lock.lock(); + } + _Lock& _M_lock; + }; + + unique_lock<mutex> __my_lock(_M_mutex); + _Unlock __unlock(__lock); + // _M_mutex must be unlocked before re-locking __lock so move + // ownership of _M_mutex lock to an object with shorter lifetime. + unique_lock<mutex> __my_lock2(std::move(__my_lock)); + _M_cond.wait(__my_lock2); } diff --git a/gcc-4.6/libstdc++-v3/include/std/system_error b/gcc-4.6/libstdc++-v3/include/std/system_error index da09a75..6ef070a 100644 --- a/gcc-4.6/libstdc++-v3/include/std/system_error +++ b/gcc-4.6/libstdc++-v3/include/std/system_error @@ -359,7 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, error_code> { size_t - operator()(const error_code& __e) const + operator()(const error_code& __e) const noexcept { const size_t __tmp = std::_Hash_impl::hash(__e._M_value); return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp); diff --git a/gcc-4.6/libstdc++-v3/include/std/thread b/gcc-4.6/libstdc++-v3/include/std/thread index de58e81..bd102fc 100644 --- a/gcc-4.6/libstdc++-v3/include/std/thread +++ b/gcc-4.6/libstdc++-v3/include/std/thread @@ -224,7 +224,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __hash_base<size_t, thread::id> { size_t - operator()(const thread::id& __id) const + operator()(const thread::id& __id) const noexcept { return std::_Hash_impl::hash(__id._M_thread); } }; diff --git a/gcc-4.6/libstdc++-v3/include/std/typeindex b/gcc-4.6/libstdc++-v3/include/std/typeindex index 79b3ead..78aeeb1 100644 --- a/gcc-4.6/libstdc++-v3/include/std/typeindex +++ b/gcc-4.6/libstdc++-v3/include/std/typeindex @@ -76,7 +76,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !_M_target->before(*__rhs._M_target); } size_t - hash_code() const + hash_code() const noexcept { return _M_target->hash_code(); } const char* @@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef type_index argument_type; size_t - operator()(const type_index& __ti) const + operator()(const type_index& __ti) const noexcept { return __ti.hash_code(); } }; diff --git a/gcc-4.6/libstdc++-v3/include/tr1/complex b/gcc-4.6/libstdc++-v3/include/tr1/complex index fc213b8..689ea16 100644 --- a/gcc-4.6/libstdc++-v3/include/tr1/complex +++ b/gcc-4.6/libstdc++-v3/include/tr1/complex @@ -185,12 +185,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::complex<_Tp> __complex_acosh(const std::complex<_Tp>& __z) { - std::complex<_Tp> __t((__z.real() - __z.imag()) - * (__z.real() + __z.imag()) - _Tp(1.0), - _Tp(2.0) * __z.real() * __z.imag()); - __t = std::sqrt(__t); - - return std::log(__t + __z); + // Kahan's formula. + return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0))) + + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); } #if _GLIBCXX_USE_C99_COMPLEX_TR1 diff --git a/gcc-4.6/libstdc++-v3/include/tr1/poly_hermite.tcc b/gcc-4.6/libstdc++-v3/include/tr1/poly_hermite.tcc index e86b377..95e8079 100644 --- a/gcc-4.6/libstdc++-v3/include/tr1/poly_hermite.tcc +++ b/gcc-4.6/libstdc++-v3/include/tr1/poly_hermite.tcc @@ -1,6 +1,6 @@ // Special functions -*- C++ -*- -// Copyright (C) 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -84,7 +84,7 @@ namespace tr1 unsigned int __i; for (__H_nm2 = __H_0, __H_nm1 = __H_1, __i = 2; __i <= __n; ++__i) { - __H_n = 2 * (__x * __H_nm1 + (__i - 1) * __H_nm2); + __H_n = 2 * (__x * __H_nm1 - (__i - 1) * __H_nm2); __H_nm2 = __H_nm1; __H_nm1 = __H_n; } |