Ostringstream and ends
I was working with someone else's code and noticed that with all the uses of ostringsteam they used to add explicitly std::ends
.
This is something that I have never done and never faced a problem.
It doesn't show up, but should I std::ends
change the following code?
ostringstream message;
message << "Hello world, version " << 2 /* << std::ends ??? */;
printf( "%s\n", message.str().c_str() );
Adding std::ends
here is pointless since stringstream
s c_str
returns null-terminated char*
. The same was not for the (now deprecated) strstream
where it was necessary to add std::ends
. I believe the author was simply not aware of this behavior change.
Should not, c_str()
returns a null terminated string.