A change was made in C++20, and I'm having a hard time finding where in the standard I can go look to learn that this change happened. Would someone please quote me the section of the standard that tells me this will happen?
I am aware of this question: Breaking change in std::tuple lexicographic comparison in C++20 with conversion operators?
but it does not answer the question about where I can find this out in the standard.
With both gcc 11.2 and clang this code prints out 01
(the expected result) with -std=c++17
and 10
with -std=c++20
. Is this correct behavior? If it is, where in the standard should I look to find out why?
#include <iostream>
struct S {
int a;
S( int a ) : a( a ){ }
operator
int() const {
return a;
}
friend bool
operator<( const S & lhs, const S & rhs ){
return lhs.a > rhs.a;
}
};
int
main(){
std::pair< int, S > p1{ 0, 1 }, p2{ 0, 2 };
std::cout << (p1 < p2) << (p2 < p1) << std::endl;
}