From 8029bf955cabed62d6b80501c4a2bc7b6b4b90f2 Mon Sep 17 00:00:00 2001 From: Roman-Koshelev <34384083+Roman-Koshelev@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:25:26 +0300 Subject: [PATCH] Fix copy_str performance (#2477) --- include/fmt/core.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 3d32e3ec..94c23e97 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -332,6 +332,8 @@ template using bool_constant = std::integral_constant; template using remove_reference_t = typename std::remove_reference::type; template +using remove_const_t = typename std::remove_const::type; +template using remove_cvref_t = typename std::remove_cv>::type; template struct type_identity { using type = T; }; template using type_identity_t = typename type_identity::type; @@ -755,13 +757,14 @@ FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) return out; } -template ::value)> -FMT_CONSTEXPR auto copy_str(const Char* begin, const Char* end, Char* out) - -> Char* { +template , U>::value && is_char::value)> +FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) + -> U* { if (is_constant_evaluated()) - return copy_str(begin, end, out); + return copy_str(begin, end, out); auto size = to_unsigned(end - begin); - memcpy(out, begin, size); + memcpy(out, begin, size * sizeof(U)); return out + size; }