https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101485

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot 
com

--- Comment #15 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
FWIW, Clang supports `__is_trivially_equality_comparable(T)` as a compiler
builtin. It's true for most primitive types, true for structs with defaulted
`operator==` (as long as their data members are all trivially equality
comparable and the struct as a whole lacks any padding bits), and false for
types with user-provided `operator==`.
However, as of this writing the trait is false for `std::byte` and false for
enum types in general, precisely because it's permitted for the user to provide
an overloaded `operator==` for them. This was the conservative choice when the
feature was added in March 2023, but given how the feature has evolved, it
probably makes sense for Clang to revisit and permit it to Just Work for enums
too.

I bring this up because it would be cool for GCC to support the same builtin.
https://godbolt.org/z/dhTc64PzP
(libstdc++ optimizes int and byte but not S; libc++ optimizes int and S but not
byte)

The builtin is more powerful than anything overload-resolution-based, because
the builtin can tell the difference between "a member function exists" and "a
member function exists, defaulted, with the proper semantics."

Reply via email to