×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

why does visual studio 2005 do this?
2

why does visual studio 2005 do this?

why does visual studio 2005 do this?

(OP)
hi guys,

I tried to compile a program like this

#include <iostream>
using namespace std;

int main()
{
    float f, g = 0;
    cin << f; //wrong here, should be >>
    return 0;
}


So I just deliberately inverted the direction of io stream direction. Then visual studio 2005 compiled this with 41 errors? Why so many errors with many repeated ones?

Error    1    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    2    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    3    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    4    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    5    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    6    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    7    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    8    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    9    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    10    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    11    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    12    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    13    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    14    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    15    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    16    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    17    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    18    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    19    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    20    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    21    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    22    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    23    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    24    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    25    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    26    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    27    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    28    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    29    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    30    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    31    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    32    error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    33    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    34    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    35    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    36    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    37    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    38    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    39    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    40    error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'    c:\acm\zju\1048\financialmanagement.cpp    7    
Error    41    error C2676: binary '<<' : 'std::istream' does not define this operator or a conversion to a type acceptable to the predefined operator    c:\acm\zju\1048\financialmanagement.cpp    7    

RE: why does visual studio 2005 do this?

(OP)
Just some addition:
The program above was created as an windows console program with no precompiled header in vs2k5. thanks

RE: why does visual studio 2005 do this?

I'm not sure why it does it, but I did notice that it tried every overload of operator<<() 4 times.
I'd guess it's trying to find a version of operator<<() that matches what you're trying to do, but why it does it 4 times and why it feels the need to tell you every single time it fails to find a match -- I don't have the slightest clue.

You could spend days (weeks, months...) trying to figure out why it does it, or you can simply accept the fact that it does very strange things that you have no control over...  winky smile

RE: why does visual studio 2005 do this?

We pay off templates old scores.

No intrinsic stream i/o operators in C++. The compiler does not know anything about simplest thing - do not try output ops on input streams. It deduces STL templates (implementation-dependent) and reports its troubles step by step. As usually it generates totally incomprehensible error/warning messages (not only in that cin>> case). The C++ has a great semantic gap between basic and generic programming parts. Honestly, I do not divide the C++ founder(s) delights on templates (delayed-action bomb placed in the language body;)...

May be we will see some improvements in new Standard but now I 100% agree with excellent cpjust's advice: you can simply accept the fact that it does very strange things that you have no control over...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close