Created on 2012-10-31.00:00:00 last changed 116 months ago
Notes from the May, 2015 meeting:
CWG agreed that a default template argument should only be used if the parameter is not used in a deducible context. See also issue 2092.
Additional note, April, 2015:
EWG has requested that CWG resolve this issue along the lines discussed above.
Rationale (November, 2013):
CWG felt that this issue should be considered by EWG in a broader context before being resolved.
According to 13.10.3 [temp.deduct] paragraph 5,
The resulting substituted and adjusted function type is used as the type of the function template for template argument deduction. If a template argument has not been deduced and its corresponding template parameter has a default argument, the template argument is determined by substituting the template arguments determined for preceding template parameters into the default argument. If the substitution results in an invalid type, as described above, type deduction fails.
This leaves the impression that default arguments are used after deduction failure leaves an argument undeduced. For example,
template<typename T> struct Wrapper; template<typename T = int> void f(Wrapper<T>*); void g() { f(0); }
Deduction fails for T, so presumably int is used. However, some implementations reject this code. It appears that the intent would be better expressed as something like
...If a template argument is used only in a non-deduced context and its corresponding template parameter has a default argument...
History | |||
---|---|---|---|
Date | User | Action | Args |
2015-05-25 00:00:00 | admin | set | messages: + msg5532 |
2015-05-25 00:00:00 | admin | set | status: open -> drafting |
2015-04-13 00:00:00 | admin | set | messages: + msg5321 |
2015-04-13 00:00:00 | admin | set | status: extension -> open |
2014-01-20 00:00:00 | admin | set | messages: + msg4796 |
2014-01-20 00:00:00 | admin | set | status: drafting -> extension |
2013-05-03 00:00:00 | admin | set | status: open -> drafting |
2012-10-31 00:00:00 | admin | create |