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 <iostream> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181209/5e7a6958/attachment.html>
Boldizsár Palotás via llvm-dev
2018-Dec-12 08:22 UTC
[llvm-dev] Investigating c++2a features
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 at lists.llvm.org> ezt írta (időpont: 2018. dec. 12., Sze, 7:07):> 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 <iostream> > > 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 > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181212/eef501e0/attachment.html>