[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error: ambiguous overload for 'operator <<' in ...
From: |
glen |
Subject: |
error: ambiguous overload for 'operator <<' in ... |
Date: |
Thu, 26 Oct 2006 11:15:35 -0400 |
User-agent: |
Pan/0.14.2.91 (As She Crawled Across the Table) |
Hi.
Don't know if this is a compiler issue, or a problem with my code.
The code below compiles fine under vc++, but I'm having trouble
using gcc. It's just a templated container output.
/**
outputs elements of a vector in the form '{el1,el2...elEnd}'
*/
template<typename C>
std::ostream& operator<< (std::ostream& op, const C& cpi )
{
typename C::const_iterator start( cpi.begin() ); typename
C::const_iterator end( --(cpi.end() )); typename C::const_iterator iter;
op << "{";
for (iter=start;iter!=end; ++iter){
op<<*iter<<",";
}
op<<*iter<<"}";
return op;
};
The offending lines are the
op<<"{";
and
op<<"}";
apparently it doesn't know what to do with a simple string, but it can
handle the template argument... Is this a compiler problem (gcc version
4.1.1, on redhat fc 5)? Or is it a subtlety of templates and the standard
that I don't quite get?
I appreciate any assistance that can be given. Searched the web but was
unable to find anything that helped.
Glen
- error: ambiguous overload for 'operator <<' in ...,
glen <=