From 3050f19e0b2ff2ce2f500bc5ffe773e70c8c08f6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 31 Jan 2020 01:30:33 +0100 Subject: [PATCH] Leverage std::to_chars. --- server/TracyPrint.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/TracyPrint.hpp b/server/TracyPrint.hpp index b6150391..4586d233 100644 --- a/server/TracyPrint.hpp +++ b/server/TracyPrint.hpp @@ -1,7 +1,11 @@ #ifndef __TRACYPRINT_HPP__ #define __TRACYPRINT_HPP__ -#include +#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L +# include +#else +# include +#endif namespace tracy { @@ -9,7 +13,11 @@ namespace tracy template static inline char* PrintFloat( char* begin, char* end, T value, int precision ) { +#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L + return std::to_chars( begin, end, value, std::chars_format::fixed, precision ).ptr; +#else return begin + sprintf( begin, "%.*f", precision, value ); +#endif } const char* TimeToString( int64_t ns );