I have a question about standard call behavior tellp
on empty ostringstream
. I have a foo function that calls the tellp
first:
void foo(std::ostream& os)
{
std::ostream::pos_type pos = os.tellp();
}
int main()
{
std::ostringstream os;
foo(os);
}
In Visual Studio 2005, calling this function with the newly created and empty ostringstream
causes the variable pos
to be set to invalid pos_type
, which in Visual Studio 2005 is set to pos_type(_BADOFF)
.
ofstream
doesn't have the same behavior where tellp
returns pos_type(0)
, which is valid pos_type
.
Is this a standard match? Is this consistent with other compilers?
dalle source
share