[Bug c++/24588] Fails to identify template using local classes
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Tue Jan 24 05:48:00 GMT 2006
------- Comment #6 from bangerth at dealii dot org 2006-01-24 05:48 -------
(In reply to comment #5)
> Well, the actual argument type is wholely resolved at point of call. And the
> formal parameter type is valid at the point where sort is defined. It will
> recognize A<int> as an A<E>, it will recognize A<int>* as an A<E>*, and it
> should
> (I think) recognize A<int>::iterator as an A<E>::iterator.
No, it can't. Here, E is in what is called a non-deducible context.
As an example of why it can't be deduced, consider an example like this:
---------------------
template <class E> class C {
typedef int* iterator;
iterator begin();
};
template <class E>
void f (const C<E>::iterator);
int main () {
C<int> c;
f(c.begin());
}
---------------
It would seem that the compiler should deduce E=int in the call to f().
However, it is worth realizing that types would also match for f<double>, and
in fact for every other choice of E as well.
In effect, E can't be deduced. The standard says so.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24588
More information about the Gcc-bugs
mailing list