Skip to content

Commit fe6caf8

Browse files
authored
[parsing] Drop compatibility code for Ventura (#22029)
1 parent 2ae5ce5 commit fe6caf8

File tree

3 files changed

+1
-48
lines changed

3 files changed

+1
-48
lines changed

Diff for: multibody/parsing/detail_instanced_name.cc

-22
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,6 @@ namespace drake {
66
namespace multibody {
77
namespace internal {
88

9-
// Apple Xcode fails to correctly implement <=> for either
10-
// std::optional (prior to 15.3) or std::string (prior to 15.2
11-
// maybe?), so the default implementation of <=> here gets
12-
// "implicitly deleted", leading to a train of compile errors. So,
13-
// until Ventura support ends, write an explicit implementation
14-
// instead.
15-
//
16-
// TODO(rpoyner-tri): replace explicit implementation with compiler
17-
// default once macOS Ventura support ends.
18-
std::strong_ordering InstancedName::operator<=>(
19-
const InstancedName& that) const {
20-
if (index.has_value() && that.index.has_value()) {
21-
if (auto cmp = (*index <=> *that.index); cmp != 0) {
22-
return cmp;
23-
}
24-
}
25-
if (auto cmp = (index.has_value() <=> that.index.has_value()); cmp != 0) {
26-
return cmp;
27-
}
28-
return std::strcmp(name.c_str(), that.name.c_str()) <=> 0;
29-
}
30-
319
std::string InstancedName::to_string() const {
3210
return fmt::format(
3311
"[{}, {}]", index.has_value() ? fmt::to_string(*index) : "nullopt", name);

Diff for: multibody/parsing/detail_instanced_name.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ struct InstancedName {
1919
std::string name;
2020

2121
bool operator==(const InstancedName&) const = default;
22-
// TODO(rpoyner-tri): replace explicit implementation with compiler
23-
// default once macOS Ventura support ends.
24-
std::strong_ordering operator<=>(const InstancedName& that) const;
22+
auto operator<=>(const InstancedName& that) const = default;
2523

2624
std::string to_string() const;
2725
};

Diff for: multibody/parsing/test/detail_instanced_name_test.cc

-23
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,6 @@ namespace multibody {
88
namespace internal {
99
namespace {
1010

11-
// TODO(rpoyner-tri): replace explicit spaceship implementation with compiler
12-
// default once macOS Ventura support ends. Once it is gone, this test (and
13-
// perhaps this whole file) can go too.
14-
GTEST_TEST(InstancedNameTest, ExplicitSpaceship) {
15-
InstancedName empty;
16-
InstancedName global_a{{}, "a"};
17-
InstancedName global_b{{}, "b"};
18-
InstancedName one_a{ModelInstanceIndex(1), "a"};
19-
InstancedName one_b{ModelInstanceIndex(1), "b"};
20-
InstancedName two_a{ModelInstanceIndex(2), "a"};
21-
InstancedName two_b{ModelInstanceIndex(2), "b"};
22-
23-
std::vector ordered{
24-
empty, global_a, global_b, one_a, one_b, two_a, two_b};
25-
26-
for (int ii = 0; ii < ssize(ordered); ++ii) {
27-
for (int jj = 0; jj < ssize(ordered); ++jj) {
28-
SCOPED_TRACE(fmt::format("compare at ({}, {})", ii, jj));
29-
EXPECT_EQ(ordered[ii] <=> ordered[jj], ii <=> jj);
30-
}
31-
}
32-
}
33-
3411
GTEST_TEST(InstanceNameTest, ToString) {
3512
InstancedName empty;
3613
EXPECT_EQ(empty.to_string(), "[nullopt, ]");

0 commit comments

Comments
 (0)