Click here to Skip to main content
15,915,160 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
template <class Key, class Value>
ATOSTD ostream&
AtoScriptAsyncNotifierAgent<Key, Value>::insertKey(
    ATOSTD ostream& oStream,
    const void* aKey) const
    //{ return oStream << * (const Key*) aKey; }
{
    return oStream  << * (const Key*) aKey;
}


What I have tried:

C2593 'operator <<' is ambiguous
Posted
Updated 19-Sep-20 22:10pm
v2

1 solution

Cause
There is no operator << for __int64 type defined for the ostream class.
Resolution
Define your own version of operator <<. The following sample code section shows a simple solution for << operator that converts the __int64 variable to a char * type and passes it to the ostream << operator.

The following sample program demonstrates the problem and workaround:
C++
//Sample.cpp
// Compiler Options : /GX

//#define WORKAROUND   //Uncomment this line to workaround

#include<iostream>
using namespace std;

#ifdef WORKAROUND
std::ostream& operator<<(std::ostream& os, __int64 i )
{
    char buf[20];
    sprintf(buf,"%I64d", i );
    os << buf;
    return os;
}

#endif

int main(){
__int64  i64;

cout << i64 ;

return 0;
}

Reference: "error C2593: 'operator <<' is ambiguous"[^]
 
Share this answer
 
Comments
CPallini 21-Sep-20 2:11am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900