@@ -3140,13 +3140,15 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction(
3140
3140
return TemplateDeductionResult::Success;
3141
3141
}
3142
3142
3143
- // / Perform template argument deduction to determine whether
3144
- // / the given template arguments match the given class template
3145
- // / partial specialization per C++ [temp.class.spec.match].
3146
- TemplateDeductionResult
3147
- Sema::DeduceTemplateArguments (ClassTemplatePartialSpecializationDecl *Partial,
3148
- ArrayRef<TemplateArgument> TemplateArgs,
3149
- TemplateDeductionInfo &Info) {
3143
+ // / Perform template argument deduction to determine whether the given template
3144
+ // / arguments match the given class or variable template partial specialization
3145
+ // / per C++ [temp.class.spec.match].
3146
+ template <typename T>
3147
+ static std::enable_if_t <IsPartialSpecialization<T>::value,
3148
+ TemplateDeductionResult>
3149
+ DeduceTemplateArguments (Sema &S, T *Partial,
3150
+ ArrayRef<TemplateArgument> TemplateArgs,
3151
+ TemplateDeductionInfo &Info) {
3150
3152
if (Partial->isInvalidDecl ())
3151
3153
return TemplateDeductionResult::Invalid;
3152
3154
@@ -3158,90 +3160,51 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
3158
3160
3159
3161
// Unevaluated SFINAE context.
3160
3162
EnterExpressionEvaluationContext Unevaluated (
3161
- * this , Sema::ExpressionEvaluationContext::Unevaluated);
3162
- SFINAETrap Trap (* this );
3163
+ S , Sema::ExpressionEvaluationContext::Unevaluated);
3164
+ Sema:: SFINAETrap Trap (S );
3163
3165
3164
3166
// This deduction has no relation to any outer instantiation we might be
3165
3167
// performing.
3166
- LocalInstantiationScope InstantiationScope (* this );
3168
+ LocalInstantiationScope InstantiationScope (S );
3167
3169
3168
3170
SmallVector<DeducedTemplateArgument, 4 > Deduced;
3169
3171
Deduced.resize (Partial->getTemplateParameters ()->size ());
3170
3172
if (TemplateDeductionResult Result = ::DeduceTemplateArguments (
3171
- * this , Partial->getTemplateParameters (),
3173
+ S , Partial->getTemplateParameters (),
3172
3174
Partial->getTemplateArgs ().asArray (), TemplateArgs, Info, Deduced,
3173
3175
/* NumberOfArgumentsMustMatch=*/ false );
3174
3176
Result != TemplateDeductionResult::Success)
3175
3177
return Result;
3176
3178
3177
3179
SmallVector<TemplateArgument, 4 > DeducedArgs (Deduced.begin (), Deduced.end ());
3178
- InstantiatingTemplate Inst (* this , Info.getLocation (), Partial, DeducedArgs,
3179
- Info);
3180
+ Sema:: InstantiatingTemplate Inst (S , Info.getLocation (), Partial, DeducedArgs,
3181
+ Info);
3180
3182
if (Inst.isInvalid ())
3181
3183
return TemplateDeductionResult::InstantiationDepth;
3182
3184
3183
3185
if (Trap.hasErrorOccurred ())
3184
3186
return TemplateDeductionResult::SubstitutionFailure;
3185
3187
3186
3188
TemplateDeductionResult Result;
3187
- runWithSufficientStackSpace (Info.getLocation (), [&] {
3188
- Result = ::FinishTemplateArgumentDeduction (* this , Partial,
3189
+ S. runWithSufficientStackSpace (Info.getLocation (), [&] {
3190
+ Result = ::FinishTemplateArgumentDeduction (S , Partial,
3189
3191
/* IsPartialOrdering=*/ false ,
3190
3192
TemplateArgs, Deduced, Info);
3191
3193
});
3192
3194
return Result;
3193
3195
}
3194
3196
3195
- // / Perform template argument deduction to determine whether
3196
- // / the given template arguments match the given variable template
3197
- // / partial specialization per C++ [temp.class.spec.match].
3197
+ TemplateDeductionResult
3198
+ Sema::DeduceTemplateArguments (ClassTemplatePartialSpecializationDecl *Partial,
3199
+ ArrayRef<TemplateArgument> TemplateArgs,
3200
+ TemplateDeductionInfo &Info) {
3201
+ return ::DeduceTemplateArguments (*this , Partial, TemplateArgs, Info);
3202
+ }
3198
3203
TemplateDeductionResult
3199
3204
Sema::DeduceTemplateArguments (VarTemplatePartialSpecializationDecl *Partial,
3200
3205
ArrayRef<TemplateArgument> TemplateArgs,
3201
3206
TemplateDeductionInfo &Info) {
3202
- if (Partial->isInvalidDecl ())
3203
- return TemplateDeductionResult::Invalid;
3204
-
3205
- // C++ [temp.class.spec.match]p2:
3206
- // A partial specialization matches a given actual template
3207
- // argument list if the template arguments of the partial
3208
- // specialization can be deduced from the actual template argument
3209
- // list (14.8.2).
3210
-
3211
- // Unevaluated SFINAE context.
3212
- EnterExpressionEvaluationContext Unevaluated (
3213
- *this , Sema::ExpressionEvaluationContext::Unevaluated);
3214
- SFINAETrap Trap (*this );
3215
-
3216
- // This deduction has no relation to any outer instantiation we might be
3217
- // performing.
3218
- LocalInstantiationScope InstantiationScope (*this );
3219
-
3220
- SmallVector<DeducedTemplateArgument, 4 > Deduced;
3221
- Deduced.resize (Partial->getTemplateParameters ()->size ());
3222
- if (TemplateDeductionResult Result = ::DeduceTemplateArguments (
3223
- *this , Partial->getTemplateParameters (),
3224
- Partial->getTemplateArgs ().asArray (), TemplateArgs, Info, Deduced,
3225
- /* NumberOfArgumentsMustMatch=*/ false );
3226
- Result != TemplateDeductionResult::Success)
3227
- return Result;
3228
-
3229
- SmallVector<TemplateArgument, 4 > DeducedArgs (Deduced.begin (), Deduced.end ());
3230
- InstantiatingTemplate Inst (*this , Info.getLocation (), Partial, DeducedArgs,
3231
- Info);
3232
- if (Inst.isInvalid ())
3233
- return TemplateDeductionResult::InstantiationDepth;
3234
-
3235
- if (Trap.hasErrorOccurred ())
3236
- return TemplateDeductionResult::SubstitutionFailure;
3237
-
3238
- TemplateDeductionResult Result;
3239
- runWithSufficientStackSpace (Info.getLocation (), [&] {
3240
- Result = ::FinishTemplateArgumentDeduction (*this , Partial,
3241
- /* IsPartialOrdering=*/ false ,
3242
- TemplateArgs, Deduced, Info);
3243
- });
3244
- return Result;
3207
+ return ::DeduceTemplateArguments (*this , Partial, TemplateArgs, Info);
3245
3208
}
3246
3209
3247
3210
// / Determine whether the given type T is a simple-template-id type.
0 commit comments