Skip to content

generic lambda in tparam list is uncallable #62611

@ericniebler

Description

@ericniebler

Compile with -std=c++20:

template <auto A = [](auto x){}>
struct C {
  static constexpr auto B = A;
};

int main() {
  C<>::B(42);
}

result:

<source>:8:3: error: no matching function for call to object of type 'const (lambda at <source>:2:20)'
  C<>::B(42);
  ^~~~~~
<source>:2:20: note: candidate template ignored: couldn't infer template argument 'x:auto'
template <auto A = [](auto x){}>
                   ^
1 error generated.

I can't fathom why the compiler cannot infer the type of the lambda argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyrejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions