diff options
author | Phil Edwards <pme@gcc.gnu.org> | 2002-01-03 04:44:07 +0000 |
---|---|---|
committer | Phil Edwards <pme@gcc.gnu.org> | 2002-01-03 04:44:07 +0000 |
commit | bf7edb60c8fb5aada12dd870c029aaac488a042b (patch) | |
tree | da9057dde231eaa595ac3365351b362c50471279 | |
parent | 0a379b7a079daa280d6f03d839ce636758055a29 (diff) | |
download | gcc-bf7edb60c8fb5aada12dd870c029aaac488a042b.zip gcc-bf7edb60c8fb5aada12dd870c029aaac488a042b.tar.gz gcc-bf7edb60c8fb5aada12dd870c029aaac488a042b.tar.bz2 |
re PR libstdc++/2054 (g++-3 rejects legal code, accepted by g++-2.95.2 (functors))
2002-01-02 Phil Edwards <pme@gcc.gnu.org>
* include/bits/stl_algo.h (upper_bound, equal_range, binary_search):
Change concept checks, as with lower_bound and PR 2054.
* testsuite/ext/concept_checks.cc: Expand test to include those.
From-SVN: r48492
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 21 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/ext/concept_checks.cc | 12 |
3 files changed, 30 insertions, 9 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d05e959..cf7f6bd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2002-01-02 Phil Edwards <pme@gcc.gnu.org> + * include/bits/stl_algo.h (upper_bound, equal_range, binary_search): + Change concept checks, as with lower_bound and PR 2054. + * testsuite/ext/concept_checks.cc: Expand test to include those. + +2002-01-02 Phil Edwards <pme@gcc.gnu.org> + * include/bits/boost_concept_check.h: Import some changes from upsteam (Boost) version. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index d5694b2..e8e9845 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1,6 +1,6 @@ // Algorithm implimentation -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002 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 @@ -1949,6 +1949,10 @@ __result, __binary_pred, _IterType()); typedef typename iterator_traits<_ForwardIter>::difference_type _DistanceType; // concept requirements + // Note that these are slightly stricter than those of the 4-argument + // version, defined next. The difference is in the strictness of the + // comparison operations... so for looser checking, define your own + // comparison function, as was intended. __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) __glibcpp_function_requires(_SameTypeConcept<_Tp, _ValueType>) __glibcpp_function_requires(_LessThanComparableConcept<_Tp>) @@ -2011,6 +2015,7 @@ __result, __binary_pred, _IterType()); typedef typename iterator_traits<_ForwardIter>::difference_type _DistanceType; // concept requirements + // See comments on lower_bound. __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) __glibcpp_function_requires(_SameTypeConcept<_Tp, _ValueType>) __glibcpp_function_requires(_LessThanComparableConcept<_Tp>) @@ -2044,8 +2049,7 @@ __result, __binary_pred, _IterType()); // concept requirements __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) - __glibcpp_function_requires(_SameTypeConcept<_Tp, _ValueType>) - __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, _Tp>) + __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, _ValueType>) _DistanceType __len = distance(__first, __last); _DistanceType __half; @@ -2074,6 +2078,7 @@ __result, __binary_pred, _IterType()); typedef typename iterator_traits<_ForwardIter>::difference_type _DistanceType; // concept requirements + // See comments on lower_bound. __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) __glibcpp_function_requires(_SameTypeConcept<_Tp, _ValueType>) __glibcpp_function_requires(_LessThanComparableConcept<_Tp>) @@ -2113,8 +2118,8 @@ __result, __binary_pred, _IterType()); // concept requirements __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) - __glibcpp_function_requires(_SameTypeConcept<_Tp, _ValueType>) - __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, _Tp>) + __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _ValueType, _Tp>) + __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, _ValueType>) _DistanceType __len = distance(__first, __last); _DistanceType __half; @@ -2147,6 +2152,7 @@ __result, __binary_pred, _IterType()); const _Tp& __val) { // concept requirements + // See comments on lower_bound. __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) __glibcpp_function_requires(_SameTypeConcept<_Tp, typename iterator_traits<_ForwardIter>::value_type>) @@ -2163,9 +2169,10 @@ __result, __binary_pred, _IterType()); { // concept requirements __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>) - __glibcpp_function_requires(_SameTypeConcept<_Tp, + __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIter>::value_type, _Tp>) + __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, typename iterator_traits<_ForwardIter>::value_type>) - __glibcpp_function_requires(_BinaryPredicateConcept<_Compare, _Tp, _Tp>) _ForwardIter __i = lower_bound(__first, __last, __val, __comp); return __i != __last && !__comp(__val, *__i); diff --git a/libstdc++-v3/testsuite/ext/concept_checks.cc b/libstdc++-v3/testsuite/ext/concept_checks.cc index d07beba..8109985 100644 --- a/libstdc++-v3/testsuite/ext/concept_checks.cc +++ b/libstdc++-v3/testsuite/ext/concept_checks.cc @@ -1,6 +1,6 @@ // 2001-12-28 Phil Edwards <pme@gcc.gnu.org> // -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002 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 @@ -30,7 +30,7 @@ using namespace std; -// PR libstdc++/2054 +// PR libstdc++/2054 and follow-up discussion struct indirectCompare { indirectCompare(const vector<string>& v) : V(v) {} @@ -45,6 +45,11 @@ struct indirectCompare return V[x] < a; } + bool operator()( const string& a, int x) const + { + return V[x] < a; + } + const vector<string>& V; }; @@ -66,6 +71,9 @@ test2054( ) string SearchTerm; lower_bound(Index.begin(), Index.end(), SearchTerm, aComparison); + upper_bound(Index.begin(), Index.end(), SearchTerm, aComparison); + equal_range(Index.begin(), Index.end(), SearchTerm, aComparison); + binary_search(Index.begin(), Index.end(), SearchTerm, aComparison); } int main() |