@@ -968,6 +968,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
968968 return {Template, AliasRhsTemplateArgs};
969969}
970970
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+
971984// Build deduction guides for a type alias template from the given underlying
972985// deduction guide F.
973986FunctionTemplateDecl *
@@ -1031,20 +1044,6 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
10311044 AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
10321045 /* NumberOfArgumentsMustMatch=*/ false );
10331046
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-
10481047 SmallVector<TemplateArgument> DeducedArgs;
10491048 SmallVector<unsigned > NonDeducedTemplateParamsInFIndex;
10501049 // !!NOTE: DeduceResults respects the sequence of template parameters of
0 commit comments