This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/19288] No more possible to have a template function that uses a nested class of a template class


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]