Skip to content

<algorithm>: lexicographical_compare_three_way missing _Mandates_ check #4877

@hewillk

Description

@hewillk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions