Contraints on equal_range comparison function object
For:
template<class ForwardIterator, class T, class Compare>
pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first, ForwardIterator last, const T&
value, Compare comp);
what are the constraints on T?
The Standard only specifies that "Type T is LessThanComparable
(20.1.2)." Is that it?
The reason I am asking is because I have a case something like:
struct Compare
{
bool operator()(const std::string& lhs, int rhs);
bool operator()(int lhs, const std::string& rhs);
};
...
std::vector<int> v;
std::string k("abc");
std::equal_range(v.begin(), v.end(), k, Compare());
Now this only works if there is *not* a constraint stating that the
value type of ForwardIterator == T.
Is the above well-defined in terms of the Standard?
It works on most compiler, but on VC++ 8.0 in debug mode I hit problem.
The reason being that their debug implementation of std::equal_range
uses Compare to ensure that the sequence is actually ordered. Since I
don't have a 'bool operator()(int lhs, int rhs' I get compilation
problems.
--Meador
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]