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
You will probably need to write your own stream inserter for __int64 using
sprintf.
Andre Folkers wrote in message
<35E17C3C...@informatik.mu-luebeck.de>...
/*
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
: >
: >
:
:
--
--
/* Andrew */
WWW: http://www.halcyon.com/ast
Email: a...@halcyon.com
(Aside: I could quibble with labeling this issue a "bug"... I don't see why
one should assume that standard library support will be extended to
non-standard types; but certainly users will notice it...)
// -----------------------------------------------------------------------
// andrew todd brown
// mailto:andre...@acm.org
// -----------------------------------------------------------------------