diff --git a/include/fmt/core.h b/include/fmt/core.h index 2f0cfb0b72c5..2c4a39cf3905 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -740,19 +740,26 @@ inline auto get_container(std::back_insert_iterator it) } template -FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) +FMT_CONSTEXPR auto copy_str_constexpr(InputIt begin, InputIt end, OutputIt out) -> OutputIt { while (begin != end) *out++ = static_cast(*begin++); return out; } -template ::value)> -FMT_CONSTEXPR auto copy_str(const Char* begin, const Char* end, Char* out) - -> Char* { +template +FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) + -> OutputIt { + return copy_str_constexpr(begin, end, out); +} + +template , Up>::value && is_char::value)> +FMT_CONSTEXPR auto copy_str(Tp* begin, Tp* end, Up* out) + -> Up* { if (is_constant_evaluated()) - return copy_str(begin, end, out); + return copy_str_constexpr(begin, end, out); auto size = to_unsigned(end - begin); - memcpy(out, begin, size); + memcpy(out, begin, size * sizeof(Up)); return out + size; }