Again with this non-conformance stupidity!

This commit is contained in:
Bartosz Taudul 2020-01-31 18:09:25 +01:00
parent 289637384d
commit 87989a5f09

View File

@ -2,9 +2,17 @@
#define __TRACYPRINT_HPP__ #define __TRACYPRINT_HPP__
#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L #if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L
# if __has_include(<charconv>) && __has_include(<type_traits>)
# include <charconv> # include <charconv>
# include <type_traits> # include <type_traits>
# else
# define NO_CHARCONV
# endif
#else #else
# define NO_CHARCONV
#endif
#ifdef NO_CHARCONV
# include <stdio.h> # include <stdio.h>
#endif #endif
@ -63,7 +71,7 @@ static tracy_force_inline void RealToStringInteger( char* buf, char* end )
template<typename T> template<typename T>
static inline char* PrintFloat( char* begin, char* end, T value, int precision ) static inline char* PrintFloat( char* begin, char* end, T value, int precision )
{ {
#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L #ifndef NO_CHARCONV
return std::to_chars( begin, end, value, std::chars_format::fixed, precision ).ptr; return std::to_chars( begin, end, value, std::chars_format::fixed, precision ).ptr;
#else #else
return begin + sprintf( begin, "%.*f", precision, value ); return begin + sprintf( begin, "%.*f", precision, value );
@ -73,14 +81,14 @@ static inline char* PrintFloat( char* begin, char* end, T value, int precision )
template<typename T> template<typename T>
static inline char* PrintFloat( char* begin, char* end, T value ) static inline char* PrintFloat( char* begin, char* end, T value )
{ {
#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L #ifndef NO_CHARCONV
return std::to_chars( begin, end, value, std::chars_format::fixed ).ptr; return std::to_chars( begin, end, value, std::chars_format::fixed ).ptr;
#else #else
return begin + sprintf( begin, "%f", value ); return begin + sprintf( begin, "%f", value );
#endif #endif
} }
#if ( defined _MSC_VER && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L #ifndef NO_CHARCONV
template<typename T> template<typename T>
static inline const char* RealToString( T val ) static inline const char* RealToString( T val )
{ {