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: "jean-pierre dot chevallet at imag dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jan 2005 03:04:02 -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 jean-pierre dot chevallet at imag dot fr 2005-01-10 03:04 -------
(In reply to comment #3)
> 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; }
// Non template version of operator using nested temptate class
// ostream& operator << (ostream& out, C1<float>::nested& c) {return out<<c.W;}
int main() {
C1<float>::nested n(3.5);
cout<<n.W<<endl;;
// Tested with gcc 3.3.2
// cout<<n<<endl;;
// Works with non template, doesn't work with template version
// operator<<(cout,n)<<endl;;
// Works with non template, doesn't work with template version
//cout.operator<< <float> (n);
// Never works : because << is a function and not a member function
//operator<< <float> (cout,n);
// Never work !! but it should ???
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19288