[libcxx-commits] [PATCH] D144262: [libc++][ranges] Implement LWG-3865 Sorting a range of pairs

A. Jiang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 19 07:01:42 PST 2023


frederick-vs-ja added inline comments.


================
Comment at: libcxx/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp:68
-    return lhs.first == rhs.first && lhs.second == rhs.second;
-}
-
----------------
Mordante wrote:
> We typically back-port LWG issues to older language versions.
> However I'm a bit wary of retroactively applying this LWG issue, since it may affect existing code.
> Looking at MSVC STL it seems @strega-nil has the same concerns.
> https://github.com/microsoft/STL/pull/3476/files/4f2ec495a6b5e6ab61d504663b0ad7d3db9db547#r1110452521
> 
> Since `operator==` and `operator<=>` are added/changed in C++20, I feel less wary to change it there.
> Doing this back to C++03 feels a bit scary.
> 
> @ldionne What's your opinion?
> 
> 
The changes do break such not-so-reasonable code:
```
struct BadPairs : std::pair<int, int>, std::pair<long, long> {};
std::pair<int, int>{} == BadPairs{};
```
And some uses of (IMO, unreasonable) explicit usage of `operartor@(p, x)` or `operator@<T, U>(p, x)`.

I think if we provide both old and new overloads, almost nothing is broken (except some code expecting incomparability).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144262/new/

https://reviews.llvm.org/D144262



More information about the libcxx-commits mailing list