ambiguous overload for 'operator>>'

Karl Lindstrom karlssunny@yahoo.com
Sun Jul 6 15:30:00 GMT 2008


Hello,

How would one address an "error: ambiguous overload for 'operator>>'  
in 'in >> d'"
error in the test suite?  I tried typecasting something in front of  
both "in" and "d" but
to no avail.

It is in the file: source-gnu-2008.0.0019\gcc-cs-4.1-32\libstdc++-v3 
\testsuite\27_io\fpos\14320-5.cc.

Details:

I have the following error when trying to compile the \27_io\fpos 
\14320-5.cc file:

C:\Blunk\tools\2008.0\\source-gnu-2008.0.0019\gcc-cs-4.1-32\libstdc++- 
v3\testsuite\27_io\fpos\14320-5.cc: In function 'void test01()':
C:\Blunk\tools\2008.0\\source-gnu-2008.0.0019\gcc-cs-4.1-32\libstdc++- 
v3\testsuite\27_io\fpos\14320-5.cc:37: error: ambiguous overload for  
'operator>>' in 'in >> d'
C:/Blunk/tools/2008.0/gnu/m68k-elf/include/c++/4.1.1/istream:131:  
note: candidates are: std::basic_istream<_CharT, _Traits>&  
std::basic_istream<_CharT, _Traits>::operator>> 
(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT,  
_Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]  
<near match>
C:/Blunk/tools/2008.0/gnu/m68k-elf/include/c++/4.1.1/istream:134:  
note:                 std::basic_istream<_CharT, _Traits>&  
std::basic_istream<_CharT, _Traits>::operator>> 
(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT,  
_Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]  
<near match>
C:/Blunk/tools/2008.0/gnu/m68k-elf/include/c++/4.1.1/istream:137:  
note:                 std::basic_istream<_CharT, _Traits>&  
std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*) 
(std::ios_base&)) [with _CharT = char, _Traits =  
std::char_traits<char>] <near match>
C:/Blunk/tools/2008.0/gnu/m68k-elf/include/c++/4.1.1/istream:230:  
note:                 std::basic_istream<_CharT, _Traits>&  
std::basic_istream<_CharT, _Traits>::operator>> 
(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits  
= std::char_traits<char>] <near match>


The source code line where the error happens is:

void test01()
{
   using namespace std;
   bool test __attribute__((unused)) = true;

   typedef istreambuf_iterator<char>::difference_type Distance;
	
   Distance d;
   istringstream in("5");
   in >> d;   // <<<<<<<<<<<<<<<<< error is flagged here
   VERIFY( d == 5 );
}

I am not sure how to proceed to fix or address the problem.
Any help or pointers to help would be most appreciated.

Thanks!

-Karl



More information about the Libstdc++ mailing list