Reputation: 24402
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
};
Upvotes: 4
Views: 344
Reputation: 302852
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_comparison
The 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.
Upvotes: 2