问题
My reference is to the binary predicate Compare comp
expected in the overload of std::lower_bound etc.:
The description reads:
The signature of the predicate function should be equivalent to the following:
bool pred(const Type1 &a, const Type2 &b);
While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy (since C++11)).
I am a bit confused by the following part of the description (which appears to be contradictory?):
...the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy (since C++11))
If the function should accept all value categories, why is Type1
not allowed? Also, why should a move
be equivalent to copy
for Type1
to be allowed, since C++11?
来源:https://stackoverflow.com/questions/58194906/regarding-binary-predicate-compare