diff options
Diffstat (limited to 'gcc-4.6/libstdc++-v3/include/bits')
21 files changed, 394 insertions, 192 deletions
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; |