From 9919f1aeb2861fc74d9ee4aed50a3f1646a4b626 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 7 Jun 2021 23:10:35 +0200 Subject: [PATCH] Use std::to_string when doing ascii conversions It's fast, it works, it's correct. No need for any of the fancy stuff when all we want is int to ascii string. Currently on my system the implementation of std::to_string is *very* similar to mine, but it doesn't have the overhead of calculating ASCII offsets because their lookup already contains ASCII values. --- include/duckhandy/int_conv.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/duckhandy/int_conv.hpp b/include/duckhandy/int_conv.hpp index 69fa51c..34bd733 100644 --- a/include/duckhandy/int_conv.hpp +++ b/include/duckhandy/int_conv.hpp @@ -24,6 +24,8 @@ #include #include +#define DHANDY_INTCONV_USE_STDSTRING + namespace dhandy { namespace implem { template > @@ -42,6 +44,14 @@ namespace dhandy { return IntConvString{retval.begin(), retval.end() - 1}; } }; +#if defined(DHANDY_INTCONV_USE_STDSTRING) + template + struct IntConv>, F, ASCIITranslator, true> { + static IntConvString> conv (const F& in) { + return std::to_string(in); + } + }; +#endif template struct IntConv, F, Tr, true> { consteval static IntConvStringView conv (const F& in) {