C_STR.h 343 B

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