@@ -968,6 +968,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
968
968
return {Template, AliasRhsTemplateArgs};
969
969
}
970
970
971
+ bool IsNonDeducedArgument (const TemplateArgument &TA) {
972
+ // The following cases indicate the template argument is non-deducible:
973
+ // 1. The result is null. E.g. When it comes from a default template
974
+ // argument that doesn't appear in the alias declaration.
975
+ // 2. The template parameter is a pack and that cannot be deduced from
976
+ // the arguments within the alias declaration.
977
+ // Non-deducible template parameters will persist in the transformed
978
+ // deduction guide.
979
+ return TA.isNull () ||
980
+ (TA.getKind () == TemplateArgument::Pack &&
981
+ llvm::any_of (TA.pack_elements (), IsNonDeducedArgument));
982
+ }
983
+
971
984
// Build deduction guides for a type alias template from the given underlying
972
985
// deduction guide F.
973
986
FunctionTemplateDecl *
@@ -1031,20 +1044,6 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
1031
1044
AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
1032
1045
/* NumberOfArgumentsMustMatch=*/ false );
1033
1046
1034
- static std::function<bool (const TemplateArgument &TA)> IsNonDeducedArgument =
1035
- [](const TemplateArgument &TA) {
1036
- // The following cases indicate the template argument is non-deducible:
1037
- // 1. The result is null. E.g. When it comes from a default template
1038
- // argument that doesn't appear in the alias declaration.
1039
- // 2. The template parameter is a pack and that cannot be deduced from
1040
- // the arguments within the alias declaration.
1041
- // Non-deducible template parameters will persist in the transformed
1042
- // deduction guide.
1043
- return TA.isNull () ||
1044
- (TA.getKind () == TemplateArgument::Pack &&
1045
- llvm::any_of (TA.pack_elements (), IsNonDeducedArgument));
1046
- };
1047
-
1048
1047
SmallVector<TemplateArgument> DeducedArgs;
1049
1048
SmallVector<unsigned > NonDeducedTemplateParamsInFIndex;
1050
1049
// !!NOTE: DeduceResults respects the sequence of template parameters of
0 commit comments