[libcxx-commits] [PATCH] D146094: [libc++][spaceship] Implement `operator<=>` for `stack`

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jun 4 03:32:40 PDT 2023


Mordante added inline comments.


================
Comment at: libcxx/include/stack:357
+operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {
+    return __x.__get_container() <=> __y.__get_container();
+}
----------------
H-G-Hristov wrote:
> Mordante wrote:
> > If possible we prefer to do exactly what the Standard says. This is consistent with `operator==` and `operator<`.
> `c` is a protected member of `stack`, which requires to declare the `operator<=>` as a friend similar to `operator==` and `operator<`. Such implementation compiles fine with Apple Clang 14.0.3 (LLVM 15) but it fails to compile on the CI with newer Clang 16/17 (I think) with myriad of `ambiguous operator declarations` errors all over the place. I did some research but all of this was over my head, so I settled on the above implementation.
> I did the same for `queue`. I'll refrain to land these patches until I get more feedback.
I really would like to know what the issue with friends are. I tested with queue and it works for me. I will post more info on that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146094



More information about the libcxx-commits mailing list