You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the above code, at the point of #1, Does the template-id Test<T> require a template argument for corresponding template parameter U? The only quote that mentioned default argument as template argument in the standard is the following :
When a simple-template-id does not name a function, a default template-argument is implicitly instantiated when the value of that default argument is needed. [ Example:
template<typename T, typename U = int> struct S { };
S* p; // the type of p is S<bool, int>*
The default argument for U is instantiated to form the type S<bool, int>*. — end example ]
However at the point of #1, The specialization of Test<T> is just a part of a function template definition, that is, there's no instantiation occurs here. So, the above quote seems to be not suitable for this case.
In the standard, there's a quote explicitly specified when to supply default arguments as arguments for function call, that is:
If an initializer-clause is specified in a parameter-declaration this initializer-clause is used as a default argument. Default arguments will be used in calls where trailing arguments are missing.
So, Is it necessary to formulate a formally terminology to cover this case? such as
A default template-argument is a template-argument ([temp.arg]) specified after = in a template-parameter. Default arguments will be used in template-id where trailing arguments are missing and the corresponding template parameter does not participate in template argument deduction.
The text was updated successfully, but these errors were encountered:
xmh0511
changed the title
The standard does not specify when supply default arguments as template arguments
The standard does not specify when to supply default arguments as template arguments
Jul 14, 2020
Sorry, I don't see any mention in P1787 about that, the modification of [temp.names]/P7 is written as the following:
When the template-name of a simple-template-id names a constrained non-function template or a constrained template template-parameter, and all template-arguments in the simple-template-id are non-dependent ([temp.dep.temp]), the associated constraints ([temp.constr.decl]) of the constrained template shall be satisfied ([temp.constr.constr]). [Example:[…]
Consider the above code, at the point of
#1
, Does the template-idTest<T>
require a template argument for corresponding template parameterU
? The only quote that mentioned default argument as template argument in the standard is the following :However at the point of
#1
, The specialization ofTest<T>
is just a part of a function template definition, that is, there's no instantiation occurs here. So, the above quote seems to be not suitable for this case.In the standard, there's a quote explicitly specified when to supply default arguments as arguments for function call, that is:
So, Is it necessary to formulate a formally terminology to cover this case? such as
The text was updated successfully, but these errors were encountered: