Consider the following code.
int id = 666;
stringstream stream(stringstream::in | stringstream::out);
stream << "Object " << id << " active.";
file.write(stream.str());
It combines all the values preceded by << in a string quite nicely. I would love to discover a shorter, easier to use version with less code duplication. Furthermore, the above code is just an example, and the command should accept arbitrary combinations of variables and strings. Ideally something like:
int id = 666;
WRITE("Object ", id, " active.");
Is this possible in C++ in a portable way, even with Boost.Preprocessor, inlined functions and all the bag of tricks.
WRITE
.WRITE
something likeprintf
with the...
concept?std::stringstream
is open for reading and writing by default, there's no need to construct it with(stringstream::in | stringstream::out)