My understanding was the best practice is:
#if __cplusplus >= 202002L
// code
#endif
However, it does not work, even though I do compile with -std=c++20
.
Also, the output of g++ -x c++ -std=c++20 -dM -E - </dev/null | grep __cplusplus
is:
#define __cplusplus 201709L
Which really confuses me, because I assumed that the correct define for C++17 is 201703L.
Am i missing something?
I have tried to check if <=>
support exists. So i can also try to do:
#if __cplusplus >= __cpp_impl_three_way_comparison && __cplusplus >= __cpp_lib_three_way_comparison
However, that does not work, as both of those constants say 201907L
.
P.S.
$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6