From: Paolo Carlini Date: Thu, 15 Nov 2007 19:05:17 +0000 (+0000) Subject: re PR libstdc++/34105 (Confusing error message with missing #include ) X-Git-Tag: releases/gcc-4.3.0~1498 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f39bf5c6baa0279e1c763b6a9e30fb0bb4ef2a7;p=thirdparty%2Fgcc.git re PR libstdc++/34105 (Confusing error message with missing #include ) 2007-11-15 Paolo Carlini PR libstdc++/34105 * include/bits/stl_algobase.h: Do not include . (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 . (equal): Move after mismatch. * include/bits/stl_heap.h (is_heap, is_heap_until): Reorder. * include/bits/char_traits.h: Include instead of . * include/bits/stl_algo.h: Include first . * include/bits/algorithmfwd.h (lexicographical_compare): Do not declare overloads. * include/parallel/partition.h: Include . * testsuite/util/testsuite_abi.cc: Include . From-SVN: r130207 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 466c8f169de3..3165b3ea651f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2007-11-15 Paolo Carlini + + PR libstdc++/34105 + * include/bits/stl_algobase.h: Do not include . + (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 . + (equal): Move after mismatch. + * include/bits/stl_heap.h (is_heap, is_heap_until): Reorder. + * include/bits/char_traits.h: Include instead + of . + * include/bits/stl_algo.h: Include first . + * include/bits/algorithmfwd.h (lexicographical_compare): Do not + declare overloads. + * include/parallel/partition.h: Include . + * testsuite/util/testsuite_abi.cc: Include . + 2007-11-14 Johannes Singler * 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 * 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 2e874040b880..cd9250e50aaf 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 _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 daa13b7558cc..86277a0940a4 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 // std::copy, std::fill_n +#include // std::copy, std::fill_n #include // For streampos #include // For EOF #include // For WEOF, wmemmove, wmemset, etc. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 3765dc0be39b..b81a4a354cbd 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 // for rand +#include #include #include // for _Temporary_buffer -#include #include // 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 358983566c30..0c3f1b21c23d 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -68,7 +68,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -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::__is_signed) - { - typedef const signed char* value_type; - value_type __f1 = reinterpret_cast(__first1); - value_type __l1 = reinterpret_cast(__last1); - value_type __f2 = reinterpret_cast(__first2); - value_type __l2 = reinterpret_cast(__last2); - return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); - } - else - { - typedef const unsigned char* value_type; - value_type __f1 = reinterpret_cast(__first1); - value_type __l1 = reinterpret_cast(__last1); - value_type __f2 = reinterpret_cast(__first2); - value_type __l2 = reinterpret_cast(__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::__is_signed) + { + typedef const signed char* value_type; + value_type __f1 = reinterpret_cast(__first1); + value_type __l1 = reinterpret_cast(__last1); + value_type __f2 = reinterpret_cast(__first2); + value_type __l2 = reinterpret_cast(__last2); + return _GLIBCXX_STD_P::lexicographical_compare(__f1, __l1, __f2, __l2); + } + else + { + typedef const unsigned char* value_type; + value_type __f1 = reinterpret_cast(__first1); + value_type __l1 = reinterpret_cast(__last1); + value_type __f2 = reinterpret_cast(__first2); + value_type __l2 = reinterpret_cast(__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 e800f65c2896..bbe76e796348 100644 --- a/libstdc++-v3/include/bits/stl_heap.h +++ b/libstdc++-v3/include/bits/stl_heap.h @@ -487,32 +487,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 - 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 - 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. @@ -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 + 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 + 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 a345b0f695a5..8e9438d8a8d1 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 #include #include #include #include #include #include -#include -#include namespace std { namespace __parallel { - // Sequential fallback - template - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, - __gnu_parallel::sequential_tag) - { return _GLIBCXX_STD_P::equal(begin1, end1, begin2); } - - // Sequential fallback - template - 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 - inline bool - equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) - { return mismatch(begin1, end1, begin2).first == end1; } - - // Public interface - template - 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 @@ -156,6 +126,33 @@ namespace __parallel iterator2_category()); } + // Sequential fallback + template + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, + __gnu_parallel::sequential_tag) + { return _GLIBCXX_STD_P::equal(begin1, end1, begin2); } + + // Sequential fallback + template + 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 + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) + { return mismatch(begin1, end1, begin2).first == end1; } + + // Public interface + template + inline bool + equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, + Predicate pred) + { return mismatch(begin1, end1, begin2, pred).first == end1; } + // Sequential fallback template inline bool diff --git a/libstdc++-v3/include/parallel/partition.h b/libstdc++-v3/include/parallel/partition.h index d21a615960e1..2b8631db73e7 100644 --- a/libstdc++-v3/include/parallel/partition.h +++ b/libstdc++-v3/include/parallel/partition.h @@ -41,6 +41,7 @@ #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc index 6efabecbe23c..cec3ae2f3f9c 100644 --- a/libstdc++-v3/testsuite/util/testsuite_abi.cc +++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc @@ -35,6 +35,7 @@ #include #include #include +#include using namespace std;