Consider this code:
std::sort(vec.begin(), vec.end(),
[](const Foo& lhs, const Foo& rhs) { return !(lhs < rhs); }
);
If lhs == rhs, then lambda (lhs, rhs) and lambda (rhs, lhs) will return true, which violates the requirement to ensure a strict weak order. However, does the standard indicate that such a comparator indicates undefined behavior?
source
share