Here's the implementation I use:
/*
This function is necessary to overcome the fact that an
ostream operator<< is not supplied for the built in type
__int64.
*/
template <class _E, class _Tr>
inline basic_ostream<_E, _Tr>& __cdecl operator<<( basic_ostream<_E, _Tr>& _O, __int64 i64Val)
{
wchar_t wchBuf[32];
// VC5BUG: _i64tow cannot handle negative numbers
if (i64Val < 0)
{
_O << _U("-");
i64Val *= -1;
}
return (_O << _i64tow(i64Val, wchBuf, 10)) ;
}
Jonathan Dodds (do
...@amsa.com) wrote:
: As the underscores in the name should tell you, __int64 is a non-standard
: type. Unlike the other __int* types __int64 is not a synonym for a standard
: type.
:
: You will probably need to write your own stream inserter for __int64 using
: sprintf.
:
: Andre Folkers wrote in message
: <35E17C3C.4C79B
...@informatik.mu-luebeck.de>...
: >Hi !
: >
: >I don't get an __int64 value print on standard output with the cout
: >stream!
: >
: >I tried the following:
: >
: >#include <iostream>
: >using namespace std;
: >void main()
: >{
: > __int64 intvalue=0xffffffffffffffff;
: > cout << intvalue << endl;
: > return;
: >}
: >
: >And I got the following error-message from msvc5.0:
: >
: >R:\stl-test\msvcstl.cpp(38) : error C2593: 'operator <<' is ambiguous
: >
: >Does anyone know, if there is a solution with ostreams. I already know
: >the printf-solution with %I64 option!
: >
: >Thanks in advance!
: >
: >Andre Folkers
: >
: >
:
:
--
--
/* Andrew */
WWW: http://www.halcyon.com/ast
Email: a...@halcyon.com