template disambiguation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



does anybody knows if we can use  template disambiguation techniques outside
templates or not yet?
i have no examples right now except for this one:
operator<< <char,char_traits<char>,allocator<char> >(cout,e);//e is string
convertale object.
this example won't compile under g++ due to ambiguation giving the following
error:
myFile.cpp: In function ‘int main()’:
myFile.cpp:65: error: ‘operator<<’ not defined
myFile.cpp:65: error: expected primary-expression before ‘char’
myFile.cpp:65: error: expected `;' before ‘char’

and if i added template keyword like this:
::template operator<< <char,char_traits<char>,allocator<char> >(cout,e);
myFile.cpp:65: error: ‘template’ (as a disambiguator) is only allowed within
templates

the point was to use the string conversion operator instead of defining a
new operator<< for my class. But c++ doesn't allow to do conversion for
function argument whose types are template parameter. Which in this case is
the global operator<< defined for strings. I decided to us the full template
syntax forcing conversion but i couldn't solve the disambiguation. Is there
any solution that doesn't use explicit cast or wrapping the function call
inside another template function??

-- 
View this message in context: http://www.nabble.com/template-disambiguation-tf2427703.html#a6769055
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux