I have the following code which compiles correctly on godbolt:
#include <array>
#include <iostream>
template <class T>
class A
{
public:
std::array<T,2> data_;
constexpr friend auto operator<=>(const A<T>& a, const A<T>& b)
{
return ( a.data_ <=> b.data_ );
}
};
int main()
{
using B = A<int>;
auto a = B{0,0};
auto b = B{1,1};
std::cout << std::boolalpha;
std::cout << (a.data_ <b.data_ );
std::cout << (a<b);
}
The same program on Arm Mac, compiling with
clang++ spacetest.cpp -o spaceship -std=c++20
gives me the following error
spacetest.cpp:11:27: error: invalid operands to binary expression ('const std::array<int, 2>' and 'const std::array<int, 2>')
return ( a.data_ <=> b.data_ );
The compiler version is
clang++ -v
Homebrew clang version 13.0.0
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
So, I dunno what I'm doing wrong here. Appreciate hints.