Investigating c++2a features

After several years out of c++, I’m getting back into it and a lot has changed. I had to write an equality operator for a large struct the other day and was looking for something (maybe a generator) to write it for me and I came across a post mentioning c++ 20? would do this for free. So I grabbed a copy of Clang 8 and wrote this simple program but I cannot get it to compile. It fails with

error: only special member functions may be defaulted

#include

struct foo {
int x;
int operator<=>(const foo&)=default;
};

int main() {
foo f0 = {1}, f1 = {1};

std::cout << ((f0 <=> f1) == 0) << std::endl;

char ch;
std::cin >> ch;
}

Any help appreciated

C++20 is still a draft standard, some parts of it are tentatively supported (by Clang, GCC etc.) and some aren’t. This seems to be one of the latter cases, also for GCC. You can follow the progress on C++2a on https://libcxx.llvm.org/cxx2a_status.html If you want to get back to C++ as a user of the language, my personal opinion is that you should stick with C++17 until after C++20 comes out and gets support from major compilers.

Kind regards,
Boldizsár Palotás

Paul Tait via llvm-dev <llvm-dev@lists.llvm.org> ezt írta (időpont: 2018. dec. 12., Sze, 7:07):