Created on 2012-11-04.00:00:00 last changed 115 months ago
Notes from the May, 2015 meeting:
The consensus of CWG was that the cv-qualification of the argument and parameter must match, so the original example should be rejected.
Additional note, November, 2014:
Concern was expressed regarding the proposed resolution over its treatment of an example like the following:
template<typename T> struct tuple_size {}; template<typename T> struct tuple_size<T const>: tuple_size<T> {}; tuple_size<void()> t;
In this case T const is always considered to be more specialized for void(), leading to infinite self-derivation.
The issue has been returned to "open" status for further consideration.
Proposed resolution (April, 2013):
Change 13.10.3.6 [temp.deduct.type] paragraph 18 as follows:
A template-argument can be deduced from a function, pointer to function, or pointer to member function type. [Note: cv-qualification of a deduced function type is ignored; see 9.3.4.6 [dcl.fct]. —end note] [Example:
template<class T> void f(void(*)(T,int)); template<class T> void f2(const T*); template<class T> void foo(T,int); void g(int,int); void g(char,int); void g2(); void h(int,int,int); void h(char,int); int m() { f(&g); // error: ambiguous f(&h); // OK: void h(char,int) is a unique match f(&foo); // error: type deduction fails because foo is a template f2(g2); // OK: cv-qualification of deduced function type ignored }—end example]
It is not clear whether the following is well-formed or not:
void foo(){} template<class T> void deduce(const T*) { } int main() { deduce(foo); }
Implementations vary in their treatment of this example.
History | |||
---|---|---|---|
Date | User | Action | Args |
2015-05-25 00:00:00 | admin | set | messages: + msg5533 |
2015-05-25 00:00:00 | admin | set | status: open -> drafting |
2014-11-24 00:00:00 | admin | set | messages: + msg5256 |
2014-11-24 00:00:00 | admin | set | status: ready -> open |
2014-03-03 00:00:00 | admin | set | status: review -> ready |
2013-05-03 00:00:00 | admin | set | messages: + msg4323 |
2013-05-03 00:00:00 | admin | set | status: open -> review |
2012-11-04 00:00:00 | admin | create |