From bb6842ba35206d4a2019366f450936f8428a7e0a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 5 Apr 2019 19:14:55 -0700 Subject: [PATCH] Simplify to_string --- include/fmt/format.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 013416c9..1e8cae5c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3335,21 +3335,15 @@ auto join(const Range& range, wstring_view sep) std::string answer = fmt::to_string(42); \endrst */ -template std::string to_string(const T& value) { - std::string str; - internal::container_buffer buf(str); - writer(buf).write(value); - return str; +template inline std::string to_string(const T& value) { + return format("{}", value); } /** Converts *value* to ``std::wstring`` using the default format for type *T*. */ -template std::wstring to_wstring(const T& value) { - std::wstring str; - internal::container_buffer buf(str); - wwriter(buf).write(value); - return str; +template inline std::wstring to_wstring(const T& value) { + return format(L"{}", value); } template