diff --git a/include/fmt/base.h b/include/fmt/base.h index d41de5f2..74144fe9 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -585,6 +585,17 @@ struct has_to_string_view< T, void_t()))>> : std::true_type {}; +template struct string_literal { + static constexpr CharT value[sizeof...(C)] = {C...}; + constexpr operator basic_string_view() const { + return {value, sizeof...(C)}; + } +}; +#if FMT_CPLUSPLUS < 201703L +template +constexpr CharT string_literal::value[sizeof...(C)]; +#endif + enum class type { none_type, // Integer types should go first, diff --git a/include/fmt/format.h b/include/fmt/format.h index 17b8e761..174c2c42 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -292,18 +292,6 @@ template using std_string_view = std::basic_string_view; template struct std_string_view {}; #endif -template struct string_literal { - static constexpr CharT value[sizeof...(C)] = {C...}; - constexpr operator basic_string_view() const { - return {value, sizeof...(C)}; - } -}; - -#if FMT_CPLUSPLUS < 201703L -template -constexpr CharT string_literal::value[sizeof...(C)]; -#endif - // Implementation of std::bit_cast for pre-C++20. template FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To { diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 6a66843a..34b3afd7 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -9,10 +9,11 @@ #define FMT_RANGES_H_ #include +#include #include #include -#include "format.h" +#include "base.h" FMT_BEGIN_NAMESPACE @@ -676,12 +677,10 @@ struct formatter, Char> { typename FormatContext::iterator { auto out = std::get(formatters_) .format(std::get(value.tuple), ctx); - if (N > 1) { - out = std::copy(value.sep.begin(), value.sep.end(), out); - ctx.advance_to(out); - return do_format(value, ctx, std::integral_constant()); - } - return out; + if (N <= 1) return out; + out = detail::copy(value.sep, out); + ctx.advance_to(out); + return do_format(value, ctx, std::integral_constant()); } }; diff --git a/test/ranges-odr-test.cc b/test/ranges-odr-test.cc index 031354d3..6115dcb7 100644 --- a/test/ranges-odr-test.cc +++ b/test/ranges-odr-test.cc @@ -7,6 +7,7 @@ #include +#include "fmt/format.h" #include "fmt/ranges.h" #include "gtest/gtest.h" diff --git a/test/ranges-test.cc b/test/ranges-test.cc index fd569c67..3e9cbdc0 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -20,6 +20,7 @@ # include #endif +#include "fmt/format.h" #include "gtest/gtest.h" #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601