Skip to content

Commit b7bef60

Browse files
committed
Drive-by fix for #132061 (comment)
1 parent 2894090 commit b7bef60

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
973986
FunctionTemplateDecl *
@@ -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

Comments
 (0)