Commit 4f39bf5c by Paolo Carlini Committed by Paolo Carlini

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
parent cb8e078d
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> 2007-11-14 Johannes Singler <singler@ira.uka.de>
* include/parallel/multiway_merge.h: More robust finding of an * include/parallel/multiway_merge.h: More robust finding of an
...@@ -5,7 +24,6 @@ ...@@ -5,7 +24,6 @@
* include/bits/stl_algo.h: Fix typo to actually call appropriate * include/bits/stl_algo.h: Fix typo to actually call appropriate
sequential version. sequential version.
2007-11-13 Benjamin Kosnik <bkoz@redhat.com> 2007-11-13 Benjamin Kosnik <bkoz@redhat.com>
* docs/html/documentation.html: First pass at unified table of contents. * docs/html/documentation.html: First pass at unified table of contents.
......
...@@ -223,14 +223,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -223,14 +223,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
iter_swap(_FIter1, _FIter2); 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> template<typename _FIter, typename _Tp>
_FIter _FIter
lower_bound(_FIter, _FIter, const _Tp&); lower_bound(_FIter, _FIter, const _Tp&);
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#pragma GCC system_header #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 <bits/postypes.h> // For streampos
#include <cstdio> // For EOF #include <cstdio> // For EOF
#include <cwchar> // For WEOF, wmemmove, wmemset, etc. #include <cwchar> // For WEOF, wmemmove, wmemset, etc.
......
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
#define _STL_ALGO_H 1 #define _STL_ALGO_H 1
#include <cstdlib> // for rand #include <cstdlib> // for rand
#include <bits/algorithmfwd.h>
#include <bits/stl_heap.h> #include <bits/stl_heap.h>
#include <bits/stl_tempbuf.h> // for _Temporary_buffer #include <bits/stl_tempbuf.h> // for _Temporary_buffer
#include <bits/algorithmfwd.h>
#include <debug/debug.h> #include <debug/debug.h>
// See concept_check.h for the __glibcxx_*_requires macros. // See concept_check.h for the __glibcxx_*_requires macros.
......
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
#include <bits/cpp_type_traits.h> #include <bits/cpp_type_traits.h>
#include <ext/type_traits.h> #include <ext/type_traits.h>
#include <ext/numeric_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_base_funcs.h>
#include <bits/stl_iterator.h> #include <bits/stl_iterator.h>
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -814,50 +815,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -814,50 +815,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return true; } { 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_END_NAMESPACE
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
...@@ -941,7 +898,7 @@ _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<_II1>::iterator_category _Category1;
typedef typename iterator_traits<_II2>::iterator_category _Category2; 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 // concept requirements
typedef typename iterator_traits<_II1>::value_type _ValueType1; typedef typename iterator_traits<_II1>::value_type _ValueType1;
...@@ -965,6 +922,50 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) ...@@ -965,6 +922,50 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
return __first1 == __last1 && __first2 != __last2; 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. * @brief Performs "dictionary" comparison on ranges.
* @param first1 An input iterator. * @param first1 An input iterator.
...@@ -984,7 +985,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) ...@@ -984,7 +985,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
{ {
typedef typename iterator_traits<_II1>::iterator_category _Category1; typedef typename iterator_traits<_II1>::iterator_category _Category1;
typedef typename iterator_traits<_II2>::iterator_category _Category2; 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 // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_II1>) __glibcxx_function_requires(_InputIteratorConcept<_II1>)
......
...@@ -488,32 +488,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -488,32 +488,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #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. * @brief Search the end of a heap.
* @param first Start of range. * @param first Start of range.
* @param last End of range. * @param last End of range.
...@@ -563,6 +537,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -563,6 +537,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__last), __last),
__comp); __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 #endif
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
......
...@@ -42,48 +42,18 @@ ...@@ -42,48 +42,18 @@
#ifndef _GLIBCXX_PARALLEL_ALGOBASE_H #ifndef _GLIBCXX_PARALLEL_ALGOBASE_H
#define _GLIBCXX_PARALLEL_ALGOBASE_H 1 #define _GLIBCXX_PARALLEL_ALGOBASE_H 1
#include <parallel/algorithmfwd.h>
#include <bits/stl_algobase.h> #include <bits/stl_algobase.h>
#include <parallel/base.h> #include <parallel/base.h>
#include <parallel/tags.h> #include <parallel/tags.h>
#include <parallel/settings.h> #include <parallel/settings.h>
#include <parallel/find.h> #include <parallel/find.h>
#include <parallel/find_selectors.h> #include <parallel/find_selectors.h>
#include <parallel/for_each.h>
#include <parallel/for_each_selectors.h>
namespace std namespace std
{ {
namespace __parallel namespace __parallel
{ {
// Sequential fallback // NB: equal and lexicographical_compare require mismatch.
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.
// Sequential fallback // Sequential fallback
template<typename InputIterator1, typename InputIterator2> template<typename InputIterator1, typename InputIterator2>
...@@ -159,6 +129,33 @@ namespace __parallel ...@@ -159,6 +129,33 @@ namespace __parallel
// Sequential fallback // Sequential fallback
template<typename InputIterator1, typename InputIterator2> template<typename InputIterator1, typename InputIterator2>
inline bool 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, lexicographical_compare(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
__gnu_parallel::sequential_tag) __gnu_parallel::sequential_tag)
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <parallel/basic_iterator.h> #include <parallel/basic_iterator.h>
#include <parallel/sort.h> #include <parallel/sort.h>
#include <parallel/random_number.h>
#include <bits/stl_algo.h> #include <bits/stl_algo.h>
#include <parallel/parallel.h> #include <parallel/parallel.h>
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <algorithm>
using namespace std; using namespace std;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment