Skip to content

Commit 3f0eb88

Browse files
committed
Change container comparison code to compile faster
1 parent 2ac804a commit 3f0eb88

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

source/containers/compare_container.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,36 @@ export struct base {
2323

2424
} // namespace range_equality
2525

26+
// I would like to have the comparison bases just publicly derive from
27+
// `range_equality::base` to reuse the code, but that causes compile times to
28+
// get much worse.
29+
2630
namespace lexicographical_comparison {
2731

28-
export struct base : range_equality::base {
32+
export struct base {
2933
template<range T> requires bounded::ordered<range_value_t<T>>
3034
friend constexpr auto operator<=>(T const & lhs, T const & rhs) {
3135
return ::containers::lexicographical_compare_3way(lhs, rhs);
3236
}
37+
template<range T> requires bounded::equality_comparable<range_value_t<T>>
38+
friend constexpr auto operator==(T const & lhs, T const & rhs) -> bool {
39+
return ::containers::equal(lhs, rhs);
40+
}
3341
};
3442

3543
} // namespace lexicographical_comparison
3644

3745
namespace shortlex_comparison {
3846

39-
export struct base : range_equality::base {
47+
export struct base {
4048
template<range T> requires bounded::ordered<range_value_t<T>>
4149
friend constexpr auto operator<=>(T const & lhs, T const & rhs) {
4250
return ::containers::shortlex_compare(lhs, rhs);
4351
}
52+
template<range T> requires bounded::equality_comparable<range_value_t<T>>
53+
friend constexpr auto operator==(T const & lhs, T const & rhs) -> bool {
54+
return ::containers::equal(lhs, rhs);
55+
}
4456
};
4557

4658
} // namespace shortlex_comparison

0 commit comments

Comments
 (0)