I've been playing with my own implementation of std::array and noticed libc++'s version uses explicitly defined operators for each of the comparisons (==,!=,<,>,<=,>=). I figured I could simplify my code by implementing C++20's spaceship operator (<=>). However, when I replaced the non-member comparison operators with auto operator<=>(const Array<TYPE,SIZE>&) const = default;
in the struct body, GCC trunk indicated that the function was "implicitly deleted because the default definition would be ill-formed". Some investigation indicated that the raw array member was the culprit.
This webpage indicates that, "The compiler knows how to expand members of classes that are arrays into their lists of sub-objects and compare them recursively." And this SO answer indicates that only copyable arrays participate in the comparison synthesis.
Out of curiousity, I ran the code from the first link on Compiler Explorer. It also fails to compile on gcc trunk. However, clang trunk compiles the code successfully.
So, my question is: which compiler is right? Should the comparison be synthesized for member arrays or not?
Yes. This is what the standard (final working draft) says: