itostr.h 411 B

123456789101112131415161718192021
  1. #ifndef ITOSTR_H
  2. #define ITOSTR_H
  3. #include "fixed_types.h"
  4. #include <sstream>
  5. // Don't use std::string externally since it's not multithread safe
  6. // But the one internal to std::stringstream is never exposed to other threads,
  7. // so it should be fine to use it locally.
  8. template<typename T>
  9. String itostr(T val)
  10. {
  11. std::stringstream s;
  12. s << val;
  13. return String(s.str().c_str());
  14. }
  15. #endif // ITOSTR_H