to_string.h 407 B

12345678910111213141516171819202122232425
  1. //
  2. // to_string.h
  3. // logger
  4. //
  5. // Created by Sam Jaffe on 4/4/19.
  6. //
  7. #pragma once
  8. #include <iostream>
  9. #include <sstream>
  10. namespace logging { namespace detail {
  11. template <typename T>
  12. void to_stream(T const & obj, std::ostream & os) {
  13. os << obj;
  14. }
  15. template <typename T>
  16. std::string to_string(T const & obj) {
  17. std::stringstream ss;
  18. to_stream(obj, ss);
  19. return ss.str();
  20. }
  21. } }