Closed
Description
The following code is an example for aggregate deduction guides.
template <typename T1, typename T2>
struct Foo {
T1 t1;
T2 t2;
};
template<typename X, typename Y>
using A = Foo<X, Y>;
A a = {1, 2};
The related AST DeductionGuideDecl
nodes look like:
|-FunctionTemplateDecl 0x5633ce70b420 <line:7:1, line:8:19> col:1 implicit <deduction guide for A>
| |-TemplateTypeParmDecl 0x5633ce70ad90 <line:7:10, col:19> col:19 typename depth 0 index 0 X
| |-TemplateTypeParmDecl 0x5633ce70ae18 <col:22, col:31> col:31 typename depth 0 index 1 Y
| `-CXXDeductionGuideDecl 0x5633ce70b360 <col:1, line:8:19> col:1 implicit <deduction guide for A> 'auto () -> Foo<type-parameter-0-0, type-parameter-0-1>'
|-FunctionTemplateDecl 0x5633ce70c458 <line:7:1, line:8:19> col:1 implicit <deduction guide for A>
| |-TemplateTypeParmDecl 0x5633ce70b480 <line:7:10, col:19> col:19 typename depth 0 index 0 X
| |-TemplateTypeParmDecl 0x5633ce70b508 <col:22, col:31> col:31 typename depth 0 index 1 Y
| `-CXXDeductionGuideDecl 0x5633ce70c390 <col:1, line:8:19> col:1 implicit <deduction guide for A> 'auto (Foo<type-parameter-0-0, type-parameter-0-1>) -> Foo<type-parameter-0-0, type-parameter-0-1>'
| `-ParmVarDecl 0x5633ce70b8e8 <line:2:8> col:8 'Foo<type-parameter-0-0, type-parameter-0-1>'
`-FunctionTemplateDecl 0x5633ce70c748 <line:1:1, line:2:8> col:8 implicit <deduction guide for Foo>
|-TemplateTypeParmDecl 0x5633ce6eac18 <line:1:11, col:20> col:20 referenced typename depth 0 index 0 T1
|-TemplateTypeParmDecl 0x5633ce6eacd8 <col:24, col:33> col:33 referenced typename depth 0 index 1 T2
|-CXXDeductionGuideDecl 0x5633ce70c678 <line:2:8> col:8 implicit <deduction guide for Foo> 'auto (T1, T2) -> Foo<T1, T2>'
| |-ParmVarDecl 0x5633ce70c588 <col:8> col:8 'T1'
| `-ParmVarDecl 0x5633ce70c608 <col:8> col:8 'T2'
`-CXXDeductionGuideDecl 0x5633ce70ce68 <col:8> col:8 implicit used <deduction guide for Foo> 'auto (int, int) -> Foo<int, int>' implicit_instantiation
|-TemplateArgument type 'int'
| `-BuiltinType 0x5633ce699230 'int'
|-TemplateArgument type 'int'
| `-BuiltinType 0x5633ce699230 'int'
|-ParmVarDecl 0x5633ce70cad8 <col:8> col:8 'int'
`-ParmVarDecl 0x5633ce70cb88 <col:8> col:8 'int'
We have issues:
- we don't have the aggregate deduction guide decl for the alias
A
, we should synthesize one from the Foo'sauto (T1, T2) -> Foo<T1, T2>
; - the template argument deduction is performed on deduction guide for
Foo
, which should be performed on use this synthesized guide decl (the instantiation should not be performed on deduction guide forA
);