https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119284
Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As you noted, using [](S&) solves the problem, because now the lambda body
doesn't need to be instantiated to see if is invocable with const S&, the
compiler can tell immediately that it's not.

You can also constrain the lambda, either with a trailing-return type:

    func(s, [](auto &x) -> decltype(x.member_func()) {
        x.member_func();
    });

or a requires-expression:


    func(s, [](auto &x) requires requires { x.member_func(); } {
        x.member_func();
    });

Reply via email to