tags:

views:

49

answers:

1

May I know what is the workaround to make this code passed, in Visual C++ 6?

#include <sstream>

int main()
{
    std::ostringstream ss;
    ss << 123;
    __int64 i;
    // error C2593: 'operator <<' is ambiguous
    ss << i;
}

Upgrade the compiler is not a choice, as I need to use this old compiler, to interface with a legacy system.

+2  A: 

provide custom override for stream insertion operation.

sample implementation as below

std::ostream& operator<<(std::ostream& stream, __int64 data)
{
    char buf[255] = {0};
    _i64tot( data, buf, 10 );

    stream << buf;
    return stream;
}
YeenFei