I wanted to use defaulted equal operator bool operator ==(...) = default; if only compiler supports it, otherwise I could still use existing implementation.
But I cannot find an appropriate feature test in https://en.cppreference.com/w/cpp/feature_test
Point me the correct feature test or help to fix this code:
struct Some {
constexpr bool operator == (const Some& rhs) const noexcept
#if __cpp_what?
= default;
#else
{
...
}
#endif
};
As default comparison is tightly connected to
<=>?you may be able make use of the __cpp_impl_three_way_comparison feature test also for the subset case of default comparison. See also P1185R2 (<=> != ==).
The document you're looking for is SD-FeatureTest. It ties in all the proposals and all the history of all the macro values.
Defaulted comparison is slightly unique in this sense, in that while it is a language feature, there is also a strong library component to it: in order to use <=>, you need to #include <compare> and use the comparison types defined in that header. As such, there are two macros here:
__cpp_impl_three_way_comparison__cpp_lib_three_way_comparisonThe language macro is really intended for the standard library to provide the library facility only when the compiler can support it.
The library macro is the one intended for the user (i.e., you) to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With