[Bug c++/106651] [C++23] P1169 - static operator()

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Sep 12 17:46:50 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106651

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 53565
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53565&action=edit
gcc13-pr106651-wip.patch

WIP patch which has parts of the changes implemented.
What is missing is [over.match.best.general]/1 and [over.best.ics.general]
changes and the library side, which means e.g. for the testcase from the paper:
struct less {
    static constexpr auto operator()(int i, int j) -> bool {
        return i < j;
    }

    using P = bool(*)(int, int);
    operator P() const { return operator(); }
};

static_assert(less{}(1, 2));
we ICE.
Testcase I've been playing with that compiles now:
template <typename T>
struct S
{
  static constexpr bool operator() (T const& x, T const& y) { return x < y; };
};

template <typename T>
void
bar (T &x)
{
  x (1, 2);
}

void
foo ()
{
  auto a = [](int x, int y) static { return x + y; };
  bar (*a);
  auto b = []<typename T, typename U>(T x, U y) static { return x + y; };
  b (1, 2L);
  S<int> s;
  s(1, 2);
}


More information about the Gcc-bugs mailing list