STR.h 327 B

1234567891011
  1. #ifndef STR_H
  2. #define STR_H
  3. // http://stackoverflow.com/a/2433143/148668
  4. #include <string>
  5. #include <sstream>
  6. // Suppose you have a function:
  7. // void func(std::string c);
  8. // Then you can write:
  9. // func(STR("foo"<<1<<"bar"));
  10. #define STR(X) static_cast<std::ostringstream&>(std::ostringstream().seekp(0) << X).str()
  11. #endif