Check for the existence of <compare>, include it, use it; 0 <=> 0 doesn't work without it anyway.

This commit is contained in:
Peter Dimov
2025-01-29 04:03:41 +02:00
parent 37a4833e26
commit 84d0f84c9b

View File

@ -51,6 +51,12 @@
#include <utility> #include <utility>
#include <cstddef> #include <cstddef>
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
# if __has_include(<compare>)
# include <compare>
# endif
#endif
namespace boost { namespace boost {
template<class T, std::size_t N> template<class T, std::size_t N>
@ -383,6 +389,7 @@ namespace boost {
} }
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
# if __has_include(<compare>)
template<class T, std::size_t N> template<class T, std::size_t N>
constexpr auto operator<=> (const array<T,N>& x, const array<T,N>& y) constexpr auto operator<=> (const array<T,N>& x, const array<T,N>& y)
@ -394,16 +401,17 @@ namespace boost {
if( r != 0 ) return r; if( r != 0 ) return r;
} }
return 0 <=> 0; // std::strong_ordering::equal return std::strong_ordering::equal;
} }
template<class T> template<class T>
constexpr auto operator<=> (const array<T,0>& /*x*/, const array<T,0>& /*y*/) constexpr auto operator<=> (const array<T,0>& /*x*/, const array<T,0>& /*y*/)
-> decltype( 0 <=> 0 ) -> std::strong_ordering
{ {
return 0 <=> 0; // std::strong_ordering::equal return std::strong_ordering::equal;
} }
# endif
#endif #endif
// undocumented and obsolete // undocumented and obsolete