4

I can do

std::ostringstream oss;
oss << 1;
oss.str();

so why can't I do:

((std::ostringstream()) << 1).str() ?

Thanks!

anon
  • 41,035
  • 53
  • 197
  • 293

1 Answers1

11

The << operator returns the base type ostream, while the str member function exists only on the derived type ostringstream.

interjay
  • 107,303
  • 21
  • 270
  • 254