This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19288] No more possible to have a template function that uses a nested class of a template class
- From: "gdr at integrable-solutions dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jan 2005 04:39:23 -0000
- Subject: [Bug c++/19288] No more possible to have a template function that uses a nested class of a template class
- References: <20050106084006.19288.jean-pierre.chevallet@imag.fr>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From gdr at integrable-solutions dot net 2005-01-10 04:39 -------
Subject: Re: No more possible to have a template function that uses a nested class of a template class
"jean-pierre dot chevallet at imag dot fr" <gcc-bugzilla@gcc.gnu.org> writes:
| > Giving explicit template arguments for template operators works
| > the same way: write
| > x.operator<< <float> (abc)
| > instead of
| > x << abc
| >
|
| Ok, I have test it but with a function operator : it doesn't seems to work.
| So what is wrong ??
|
| #include <iostream>
|
| using namespace std;
|
| template <typename T> class C1 {
| public:
| T V;
| C1(T v) : V(v) {};
|
| class nested {
| public:
| T W;
| nested(T w) : W(w) {};
| };
|
| };
|
| // Template version of operator using nested temptate class
| template <typename T>
| ostream& operator << (ostream& out,typename C1<T>::nested& c) {return out<<c.W; }
This template is never going to contribute any candidate through the
usual template argument deduction process. The reason is very simple:
the template parameter "T" appears in nondeducible context.
| // Non template version of operator using nested temptate class
| // ostream& operator << (ostream& out, C1<float>::nested& c) {return out<<c.W;}
this function does not involve any template deduction, so it will "work".
[...]
| //operator<< <float> (cout,n);
| // Never work !! but it should ???
Yes.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19288