Skip to content

std::tuple still missing C++20 three-way spaceship operator<=> #50396

@mumbleskates

Description

@mumbleskates
Bugzilla Link 51052
Version unspecified
OS Linux
CC @erikolofsson,@ldionne,@mclow,@smeenai

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions