================
@@ -261,6 +261,20 @@ getDeducedNTTParameterFromExpr(TemplateDeductionInfo
&Info, Expr *E) {
return getDeducedNTTParameterFromExpr(E, Info.getDeducedDepth());
}
+/// C++26 [temp.deduct.type]p13:
+/// When the value of the argument corresponding to a constant template
+/// parameter P that is declared with a dependent type is deduced from an
+/// expression, the template parameters in the type of P are deduced from the
+/// type of the value.
+static QualType getTypeOfTemplateArgumentValue(TemplateDeductionInfo &Info,
+ const TemplateArgument &A) {
+ const Expr *E = unwrapExpressionForDeduction(A.getAsExpr());
+ if (NonTypeOrVarTemplateParmDecl NTTP =
+ getDeducedNTTParameterFromExpr(E, Info.getDeducedDepth()))
+ return NTTP.getType();
+ return E->getType();
----------------
zyn0217 wrote:
Or simplify to
```cpp
static QualType getTypeOfTemplateArgumentValue(Expr *E, unsigned Depth) {
if (NonTypeOrVarTemplateParmDecl NTTP =
getDeducedNTTParameterFromExpr(E, Depth))
return NTTP.getType();
return E->IgnoreImplicitAsWritten()->getType();
}
```
https://github.com/llvm/llvm-project/pull/223645
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits