Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<algorithm>: lexicographical_compare_three_way missing _Mandates_ check #4877

Closed
hewillk opened this issue Aug 5, 2024 · 0 comments · Fixed by #4878
Closed

<algorithm>: lexicographical_compare_three_way missing _Mandates_ check #4877

hewillk opened this issue Aug 5, 2024 · 0 comments · Fixed by #4878
Labels
bug Something isn't working fixed Something works now, yay! ranges C++20/23 ranges

Comments

@hewillk
Copy link
Contributor

hewillk commented Aug 5, 2024

There is a Mandates in [alg.three.way], which seems to be missing in the MSVC-STL implementation:

Mandates: decltype(comp(*b1, *b2)) is a comparison category type.

#include <algorithm>

struct Hack {
  Hack(auto);
  bool operator==(int) const;
};

struct Cmp {
  Hack operator()(const auto&, const auto&) const;
};

int main() {
  int x[] = {42};
  auto r = std::lexicographical_compare_three_way(x, x+1, x, x+1, Cmp{}); // only ok in MSVC-STL
}

https://godbolt.org/z/P6jPedes9

@StephanTLavavej StephanTLavavej added bug Something isn't working ranges C++20/23 ranges labels Aug 5, 2024
CaseyCarter added a commit to CaseyCarter/STL that referenced this issue Aug 5, 2024
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay! ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants