Make operator<=> friend.

This commit is contained in:
Anthony Calandra
2025-04-05 19:59:07 -04:00
parent 65d08b8d53
commit 30a6ca2307
2 changed files with 6 additions and 4 deletions

View File

@@ -260,7 +260,7 @@ struct foo {
char c;
// Compare `a` first, then `b`, then `c` ...
auto operator<=>(const foo&) const = default;
friend auto operator<=>(const foo&) const = default;
};
foo f1{0, false, 'a'}, f2{0, true, 'b'};
@@ -275,7 +275,8 @@ struct foo {
int x;
bool b;
char c;
std::strong_ordering operator<=>(const foo& other) const {
friend std::strong_ordering operator<=>(const foo& other) const {
return x <=> other.x;
}
};

View File

@@ -364,7 +364,7 @@ struct foo {
char c;
// Compare `a` first, then `b`, then `c` ...
auto operator<=>(const foo&) const = default;
friend auto operator<=>(const foo&) const = default;
};
foo f1{0, false, 'a'}, f2{0, true, 'b'};
@@ -379,7 +379,8 @@ struct foo {
int x;
bool b;
char c;
std::strong_ordering operator<=>(const foo& other) const {
friend std::strong_ordering operator<=>(const foo& other) const {
return x <=> other.x;
}
};