catch_to_string.hpp 717 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Created by Martin on 9/5/2018.
  3. *
  4. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef TWOBLUECUBES_CATCH_TO_STRING_H_INCLUDED
  8. #define TWOBLUECUBES_CATCH_TO_STRING_H_INCLUDED
  9. #include <string>
  10. #include "catch_compiler_capabilities.h"
  11. #include "catch_stream.h"
  12. namespace Catch {
  13. template <typename T>
  14. std::string to_string(T const& t) {
  15. #if defined(CATCH_CONFIG_CPP11_TO_STRING)
  16. return std::to_string(t);
  17. #else
  18. ReusableStringStream rss;
  19. rss << t;
  20. return rss.str();
  21. #endif
  22. }
  23. } // end namespace Catch
  24. #endif // TWOBLUECUBES_CATCH_TO_STRING_H_INCLUDED