// 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
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>)
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>)
// 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;
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>)
// 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;
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>)
{
// 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);
// 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
using namespace std;
-// PR libstdc++/2054
+// PR libstdc++/2054 and follow-up discussion
struct indirectCompare
{
indirectCompare(const vector<string>& v) : V(v) {}
return V[x] < a;
}
+ bool operator()( const string& a, int x) const
+ {
+ return V[x] < a;
+ }
+
const vector<string>& V;
};
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()