diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-11-15 19:05:17 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-11-15 19:05:17 +0000 |
commit | 4f39bf5c6baa0279e1c763b6a9e30fb0bb4ef2a7 (patch) | |
tree | 892e71e4a0cbd22ffa49a034f35871838d86a536 /libstdc++-v3 | |
parent | cb8e078d3f0aa2a99eb9d14ba0f38354ffc181a6 (diff) | |
download | gcc-4f39bf5c6baa0279e1c763b6a9e30fb0bb4ef2a7.zip gcc-4f39bf5c6baa0279e1c763b6a9e30fb0bb4ef2a7.tar.gz gcc-4f39bf5c6baa0279e1c763b6a9e30fb0bb4ef2a7.tar.bz2 |
re PR libstdc++/34105 (Confusing error message with missing #include <algorithm>)
2007-11-15 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/34105
* include/bits/stl_algobase.h: Do not include <bits/algorithmfwd.h>.
(lexicographical_compare(const unsigned char*, const unsigned char*,
const unsigned char*, const unsigned char*),
lexicographical_compare(const char*, const char*, const char*,
const char*)): Move to namespace (std, _GLIBCXX_STD_P).
* include/parallel/algobase.h: Do not include <bits/algorithmfwd.h>.
(equal): Move after mismatch.
* include/bits/stl_heap.h (is_heap, is_heap_until): Reorder.
* include/bits/char_traits.h: Include <bits/stl_algobase.h> instead
of <bits/algorithmfwd.h>.
* include/bits/stl_algo.h: Include first <bits/algorithmfwd.h>.
* include/bits/algorithmfwd.h (lexicographical_compare): Do not
declare overloads.
* include/parallel/partition.h: Include <parallel/random_number.h>.
* testsuite/util/testsuite_abi.cc: Include <algorithm>.
From-SVN: r130207
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 20 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/algorithmfwd.h | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/char_traits.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algobase.h | 95 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_heap.h | 52 | ||||
-rw-r--r-- | libstdc++-v3/include/parallel/algobase.h | 59 | ||||
-rw-r--r-- | libstdc++-v3/include/parallel/partition.h | 1 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/testsuite_abi.cc | 1 |
9 files changed, 125 insertions, 115 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 466c8f1..3165b3e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2007-11-15 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/34105 + * include/bits/stl_algobase.h: Do not include <bits/algorithmfwd.h>. + (lexicographical_compare(const unsigned char*, const unsigned char*, + const unsigned char*, const unsigned char*), + lexicographical_compare(const char*, const char*, const char*, + const char*)): Move to namespace (std, _GLIBCXX_STD_P). + * include/parallel/algobase.h: Do not include <bits/algorithmfwd.h>. + (equal): Move after mismatch. + * include/bits/stl_heap.h (is_heap, is_heap_until): Reorder. + * include/bits/char_traits.h: Include <bits/stl_algobase.h> instead + of <bits/algorithmfwd.h>. + * include/bits/stl_algo.h: Include first <bits/algorithmfwd.h>. + * include/bits/algorithmfwd.h (lexicographical_compare): Do not + declare overloads. + * include/parallel/partition.h: Include <parallel/random_number.h>. + * testsuite/util/testsuite_abi.cc: Include <algorithm>. + 2007-11-14 Johannes Singler <singler@ira.uka.de> * include/parallel/multiway_merge.h: More robust finding of an @@ -5,7 +24,6 @@ * include/bits/stl_algo.h: Fix typo to actually call appropriate sequential version. - 2007-11-13 Benjamin Kosnik <bkoz@redhat.com> * docs/html/documentation.html: First pass at unified table of contents. diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 2e87404..cd9250e 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -223,14 +223,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void iter_swap(_FIter1, _FIter2); - // Specializations for char and unsigned char. - inline bool - lexicographical_compare(const unsigned char*, const unsigned char*, - const unsigned char*, const unsigned char*); - - inline bool - lexicographical_compare(const char*, const char*, const char*, const char*); - template<typename _FIter, typename _Tp> _FIter lower_bound(_FIter, _FIter, const _Tp&); diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index daa13b7..86277a0 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -43,7 +43,7 @@ #pragma GCC system_header -#include <bits/algorithmfwd.h> // std::copy, std::fill_n +#include <bits/stl_algobase.h> // std::copy, std::fill_n #include <bits/postypes.h> // For streampos #include <cstdio> // For EOF #include <cwchar> // For WEOF, wmemmove, wmemset, etc. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 3765dc0..b81a4a3 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -63,9 +63,9 @@ #define _STL_ALGO_H 1 #include <cstdlib> // for rand +#include <bits/algorithmfwd.h> #include <bits/stl_heap.h> #include <bits/stl_tempbuf.h> // for _Temporary_buffer -#include <bits/algorithmfwd.h> #include <debug/debug.h> // See concept_check.h for the __glibcxx_*_requires macros. diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 3589835..0c3f1b2 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -68,7 +68,8 @@ #include <bits/cpp_type_traits.h> #include <ext/type_traits.h> #include <ext/numeric_traits.h> -#include <bits/algorithmfwd.h> +#include <bits/stl_pair.h> +#include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator.h> #include <bits/concept_check.h> @@ -814,50 +815,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return true; } }; - // XXX should these be enabled-if'd for signed/unsigned types instead? - inline bool - lexicographical_compare(const unsigned char* __first1, - const unsigned char* __last1, - const unsigned char* __first2, - const unsigned char* __last2) - { - __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_valid_range(__first2, __last2); - - const size_t __len1 = __last1 - __first1; - const size_t __len2 = __last2 - __first2; - const int __result = __builtin_memcmp(__first1, __first2, - std::min(__len1, __len2)); - return __result != 0 ? __result < 0 : __len1 < __len2; - } - - inline bool - lexicographical_compare(const char* __first1, const char* __last1, - const char* __first2, const char* __last2) - { - __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_valid_range(__first2, __last2); - - if (__gnu_cxx::__numeric_traits<char>::__is_signed) - { - typedef const signed char* value_type; - value_type __f1 = reinterpret_cast<value_type>(__first1); - value_type __l1 = reinterpret_cast<value_type>(__last1); - value_type __f2 = reinterpret_cast<value_type>(__first2); - value_type __l2 = reinterpret_cast<value_type>(__last2); - return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); - } - else - { - typedef const unsigned char* value_type; - value_type __f1 = reinterpret_cast<value_type>(__first1); - value_type __l1 = reinterpret_cast<value_type>(__last1); - value_type __f2 = reinterpret_cast<value_type>(__first2); - value_type __l2 = reinterpret_cast<value_type>(__last2); - return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); - } - } - _GLIBCXX_END_NAMESPACE _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) @@ -941,7 +898,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) { typedef typename iterator_traits<_II1>::iterator_category _Category1; typedef typename iterator_traits<_II2>::iterator_category _Category2; - typedef __lc_rai<_Category1, _Category2> __rai_type; + typedef std::__lc_rai<_Category1, _Category2> __rai_type; // concept requirements typedef typename iterator_traits<_II1>::value_type _ValueType1; @@ -965,6 +922,50 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) return __first1 == __last1 && __first2 != __last2; } + // XXX should these be enabled-if'd for signed/unsigned types instead? + inline bool + lexicographical_compare(const unsigned char* __first1, + const unsigned char* __last1, + const unsigned char* __first2, + const unsigned char* __last2) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + const int __result = __builtin_memcmp(__first1, __first2, + std::min(__len1, __len2)); + return __result != 0 ? __result < 0 : __len1 < __len2; + } + + inline bool + lexicographical_compare(const char* __first1, const char* __last1, + const char* __first2, const char* __last2) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + if (__gnu_cxx::__numeric_traits<char>::__is_signed) + { + typedef const signed char* value_type; + value_type __f1 = reinterpret_cast<value_type>(__first1); + value_type __l1 = reinterpret_cast<value_type>(__last1); + value_type __f2 = reinterpret_cast<value_type>(__first2); + value_type __l2 = reinterpret_cast<value_type>(__last2); + return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); + } + else + { + typedef const unsigned char* value_type; + value_type __f1 = reinterpret_cast<value_type>(__first1); + value_type __l1 = reinterpret_cast<value_type>(__last1); + value_type __f2 = reinterpret_cast<value_type>(__first2); + value_type __l2 = reinterpret_cast<value_type>(__last2); + return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); + } + } + /** * @brief Performs "dictionary" comparison on ranges. * @param first1 An input iterator. @@ -984,7 +985,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) { typedef typename iterator_traits<_II1>::iterator_category _Category1; typedef typename iterator_traits<_II2>::iterator_category _Category2; - typedef __lc_rai<_Category1, _Category2> __rai_type; + typedef std::__lc_rai<_Category1, _Category2> __rai_type; // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_II1>) diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h index e800f65..bbe76e7 100644 --- a/libstdc++-v3/include/bits/stl_heap.h +++ b/libstdc++-v3/include/bits/stl_heap.h @@ -488,32 +488,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #ifdef __GXX_EXPERIMENTAL_CXX0X__ /** - * @brief Determines whether a range is a heap. - * @param first Start of range. - * @param last End of range. - * @return True if range is a heap, false otherwise. - * @ingroup heap - */ - template<typename _RandomAccessIterator> - inline bool - is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) - { return std::is_heap_until(__first, __last) == __last; } - - /** - * @brief Determines whether a range is a heap using comparison functor. - * @param first Start of range. - * @param last End of range. - * @param comp Comparison functor to use. - * @return True if range is a heap, false otherwise. - * @ingroup heap - */ - template<typename _RandomAccessIterator, typename _Compare> - inline bool - is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) - { return std::is_heap_until(__first, __last, __comp) == __last; } - - /** * @brief Search the end of a heap. * @param first Start of range. * @param last End of range. @@ -563,6 +537,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __last), __comp); } + + /** + * @brief Determines whether a range is a heap. + * @param first Start of range. + * @param last End of range. + * @return True if range is a heap, false otherwise. + * @ingroup heap + */ + template<typename _RandomAccessIterator> + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::is_heap_until(__first, __last) == __last; } + + /** + * @brief Determines whether a range is a heap using comparison functor. + * @param first Start of range. + * @param last End of range. + * @param comp Comparison functor to use. + * @return True if range is a heap, false otherwise. + * @ingroup heap + */ + template<typename _RandomAccessIterator, typename _Compare> + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { return std::is_heap_until(__first, __last, __comp) == __last; } #endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/parallel/algobase.h b/libstdc++-v3/include/parallel/algobase.h index a345b0f..8e9438d 100644 --- a/libstdc++-v3/include/parallel/algobase.h +++ b/libstdc++-v3/include/parallel/algobase.h @@ -42,48 +42,18 @@ #ifndef _GLIBCXX_PARALLEL_ALGOBASE_H #define _GLIBCXX_PARALLEL_ALGOBASE_H 1 -#include <parallel/algorithmfwd.h> #include <bits/stl_algobase.h> #include <parallel/base.h> #include <parallel/tags.h> #include <parallel/settings.h> #include <parallel/find.h> #include <parallel/find_selectors.h> -#include <parallel/for_each.h> -#include <parallel/for_each_selectors.h> namespace std { namespace __parallel { - // Sequential fallback - template<typename InputIterator1, typename InputIterator2> - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, - __gnu_parallel::sequential_tag) - { return _GLIBCXX_STD_P::equal(begin1, end1, begin2); } - - // Sequential fallback - template<typename InputIterator1, typename InputIterator2, typename Predicate> - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, - Predicate pred, __gnu_parallel::sequential_tag) - { return _GLIBCXX_STD_P::equal(begin1, end1, begin2, pred); } - - // Public interface - template<typename InputIterator1, typename InputIterator2> - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) - { return mismatch(begin1, end1, begin2).first == end1; } - - // Public interface - template<typename InputIterator1, typename InputIterator2, typename Predicate> - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, - Predicate pred) - { return mismatch(begin1, end1, begin2, pred).first == end1; } - - // NB: lexicographical_compare equires mismatch. + // NB: equal and lexicographical_compare require mismatch. // Sequential fallback template<typename InputIterator1, typename InputIterator2> @@ -159,6 +129,33 @@ namespace __parallel // Sequential fallback template<typename InputIterator1, typename InputIterator2> inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, + __gnu_parallel::sequential_tag) + { return _GLIBCXX_STD_P::equal(begin1, end1, begin2); } + + // Sequential fallback + template<typename InputIterator1, typename InputIterator2, typename Predicate> + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, + Predicate pred, __gnu_parallel::sequential_tag) + { return _GLIBCXX_STD_P::equal(begin1, end1, begin2, pred); } + + // Public interface + template<typename InputIterator1, typename InputIterator2> + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) + { return mismatch(begin1, end1, begin2).first == end1; } + + // Public interface + template<typename InputIterator1, typename InputIterator2, typename Predicate> + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, + Predicate pred) + { return mismatch(begin1, end1, begin2, pred).first == end1; } + + // Sequential fallback + template<typename InputIterator1, typename InputIterator2> + inline bool lexicographical_compare(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, InputIterator2 end2, __gnu_parallel::sequential_tag) diff --git a/libstdc++-v3/include/parallel/partition.h b/libstdc++-v3/include/parallel/partition.h index d21a615..2b8631d 100644 --- a/libstdc++-v3/include/parallel/partition.h +++ b/libstdc++-v3/include/parallel/partition.h @@ -41,6 +41,7 @@ #include <parallel/basic_iterator.h> #include <parallel/sort.h> +#include <parallel/random_number.h> #include <bits/stl_algo.h> #include <parallel/parallel.h> diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc index 6efabec..cec3ae2 100644 --- a/libstdc++-v3/testsuite/util/testsuite_abi.cc +++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc @@ -35,6 +35,7 @@ #include <fstream> #include <iostream> #include <vector> +#include <algorithm> using namespace std; |