Skip to content

Nested CTAD fails with "could not match 'inner_foo<T2>' against 'int'" #57812

Closed
@royjacobson

Description

@royjacobson

CTAD on this example:

template <class T1>
struct outer_foo {
  template <class T2>
  struct inner_foo {
    inner_foo(const T2& t);
  };
};

void f() {
  auto X = outer_foo<int>::inner_foo(1);
}

fails with

<source>:10:12: error: no viable constructor or deduction guide for deduction of template arguments of 'inner_foo'
  auto X = outer_foo<int>::inner_foo(1);
           ^
<source>:4:10: note: candidate template ignored: could not match 'inner_foo<T2>' against 'int'
  struct inner_foo {
         ^
<source>:4:10: note: candidate function template not viable: requires 0 arguments, but 1 was provided
1 error generated.
Compiler returned: 1

https://godbolt.org/z/Ea9j6GxdP

Metadata

Metadata

Assignees

Labels

c++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contributerejects-valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions