Extended Description
In the C++20 standard, std::tuple is meant to have its old {<,<=,==,!=,>=,>} comparison operators deprecated in favor of the three-way comparison spaceship operator, <=>. In the very latest iteration of libc++ (currently 1:13~++20210710113609+8cf7ddbdd4e5-1exp120210710094359.522), this has yet to be the case.
Example:
clang-13 -xc++ -std=c++20 -stdlib=libstdc++ -lstdc++ <(cat <<EOF
#include
int main(int, char**) {
int a = 1, b = 1;
auto compared = std::tie(a) <=> std::tie(b);
return compared < 0;
}
EOF
) && ./a.out && echo "okay"
The above command prints "okay", because libstdc++ supports <=> comparison between std::tuples.
clang-13 -xc++ -std=c++20 -stdlib=libc++ -lc++ <(cat <<EOF
#include
int main(int, char**) {
int a = 1, b = 1;
auto compared = std::tie(a) <=> std::tie(b);
return compared < 0;
}
EOF
) && ./a.out && echo "okay"
The above command fails to compile the program, with the following error message:
error: invalid operands to binary expression ('tuple<int &>' and 'tuple<int &>')
auto compared = std::tie(a) <=> std::tie(b);
~~~~~~~~~~~ ^ ~~~~~~~~~~~
Further investigation reveals that the header contains no definitions for operator<=>, and my efforts to locate a TODO for this feature in the libc++ effort have come up fruitless.
Extended Description
In the C++20 standard, std::tuple is meant to have its old {<,<=,==,!=,>=,>} comparison operators deprecated in favor of the three-way comparison spaceship operator, <=>. In the very latest iteration of libc++ (currently 1:13~++20210710113609+8cf7ddbdd4e5-1
exp120210710094359.522), this has yet to be the case.Example:
clang-13 -xc++ -std=c++20 -stdlib=libstdc++ -lstdc++ <(cat <<EOF
#include
int main(int, char**) {
int a = 1, b = 1;
auto compared = std::tie(a) <=> std::tie(b);
return compared < 0;
}
EOF
) && ./a.out && echo "okay"
The above command prints "okay", because libstdc++ supports <=> comparison between std::tuples.
clang-13 -xc++ -std=c++20 -stdlib=libc++ -lc++ <(cat <<EOF
#include
int main(int, char**) {
int a = 1, b = 1;
auto compared = std::tie(a) <=> std::tie(b);
return compared < 0;
}
EOF
) && ./a.out && echo "okay"
The above command fails to compile the program, with the following error message:
error: invalid operands to binary expression ('tuple<int &>' and 'tuple<int &>')
auto compared = std::tie(a) <=> std::tie(b);
~~~~~~~~~~~ ^ ~~~~~~~~~~~
Further investigation reveals that the header contains no definitions for operator<=>, and my efforts to locate a TODO for this feature in the libc++ effort have come up fruitless.