fork download
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4.  
  5. void log(ostream& o) {
  6. stringstream* s = dynamic_cast<stringstream*>(&o);
  7. if (s) {
  8. cout << s->str() << endl;
  9. }
  10. }
  11.  
  12. int main() {
  13. int x = 5, y = 6;
  14. log(stringstream() << "x=" << x << ", y=" << y);
  15. return 0;
  16. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
x=5, y=6