I have an overload operator for my own class & lt; & Lt; () Want template My classes are as follows:
template & lt; Typename refCountType, typename TraitsType = std :: char_traits & lt; Char & gt;, typanem allocative = std :: allocator & lt; Typename TraitsType :: char_type & gt; & Gt; class rep { // ... }; Template & lt; Typename RepType & gt; Class t_zstring {// ...}; Operator & lt; & Lt; () is the code for: template & lt; Typewrite typetime, typename spots type, typewriter allocator, typewriter ref type type, template & lt; Class, class, class & gt; Class Rule Type & gt; Inline std :: basic_ostream & lt; CharType, TraitsType & gt; & Amp; For operator & lt; & Lt; (Std :: basic_ostream & lt; CharType, TraitsType & gt; & amp; OS, t_zstring & lt; RepType & lt; RefCountType, TraitsType, Suppressor & gt; & gt; constants & amp; s) {os return & lt Return ; & Lt; S.c_str (); }
The template code just compiled properly; However, when I try to use it (with code for my_ref_count class) elided:
typedef rep & lt; My_ref_count & gt; My_rep; Typedef t_zstring & lt; My_rep & gt; Zstring; Zstring z; Cout & lt; & Lt; Z; // ztest.cpp, line 201
I get (using G ++ 4.2.1):
ztest.cpp: 201: Error: No match for 'Operator & lt; & Lt; & gt; In 'std :: cout & lt; & Lt; Z1 '
How can I declare my operator & lt; & Lt ;? If you want to & lt; & Lt; The operator for class t_zstring, I think it is easy to write:
of the template
Comments
Post a Comment