Code: Select all
#include
#include
using namespace std;
struct UDTC
{
int i_;
UDTC(int i) : i_(i) {}
#if 1
friend std::strong_ordering operator(const UDTC &lhs, const UDTC &rhs) {
return lhs.i_ rhs.i_;
}
#else
friend std::strong_ordering operator(const UDTC &lhs, const UDTC &rhs) = default;
#endif
};
int main(void)
{
if constexpr (std::three_way_comparable) {
fprintf(stderr, "UDTC is three_way_comparable\n");
} else {
fprintf(stderr, "UDTC is NOT three_way_comparable\n");
}
}