Clang now has an answer for you: it depends™
C++26 introduced std::type_order from P2830 to answer this very question.
GCC has had support for it for quite a while; now Clang does too. Earlier today I merged the required changes to libc++. My implementation of the underlying builtin used to implement this was merged into Clang about two weeks ago.
So, why would you compare types in the first place and what does “it depends” mean?
[…]