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