Is it possible to pass a stringstream as a function parameter?

rsk82 picture rsk82 · May 31, 2012 · Viewed 22.4k times · Source

Is it possible to pass in a stringstream and have the function write to it directly?

I remember I saw a function invoked similar to something like this:

my_func(ss << "text" << hex << 33);

Answer

eq- picture eq- · May 31, 2012

Sure thing. Why wouldn't it be? Example declaration of such function:

void my_func(std::ostringstream& ss);