The attached file contains the test for the lib.binary.search algorithm.
Here I use new compare functor instead of binary_predicate because
the following code fails to compile:
template
bool
std::binary_search (int*, int*,
const int&,
binary_predicate<int >);
with error:
stdlib\\include\algorithm(1036): error C2248:
'conv_to_bool::operator`!'' : cannot access private member declared in
class 'conv_to_bool'
The binary_search accepts Compare (not BinaryPredicate) functor. The
standard (25.3, p2) says that Compare should return true or false. At
the same time, it says (25, p8) that BinaryPredicate should return value
testable as true. The difference results in the error above.
It looks like we shouldn't use binary_predicate to test this algorithm
(as well as lower.bound, upper.bound, equal.range there the difference
between compare and binary_predicate is not significant). So it would be
useful to add compare functor to the alg_test.h header. Or it is
possible to modify the binary_search algorithm to not use the
"! operator()".
What do you think about it?
And here is another small question:
may be it would be useful to merge tests for lower.bound, upper.bound,
equal.range and binary.search into one .cpp file (tests for these
algorithms are very similar)?
Thanks,
Anton Pevtsov
