I want to write a bunch of data to an ostream object and return the number of bytes written. For example:
using namespace std; size_t writeStuffToStream(ostream &stream) { stream << some_string << some_integer << some_other_arbitrary_object << endl; return number_of_bytes_written; } There is the obvious workaround of writing everything to a stringstream and getting the byte count out of that, and then writing the stringstream to the stream, but that takes extra time and memory.
I also realize that if if all the data I wanted to write were preexisting strings, then there would be no problem. It's some_integer and some_other_arbitrary_object that are the problem.