diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 1c7c83f9..53923480 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -176,7 +176,7 @@ class prepared_format { using char_type = char_t; using format_part_t = format_part; - prepared_format(Format f) + constexpr prepared_format(Format f) : format_(std::move(f)), parts_provider_(to_string_view(format_)) {} prepared_format() = delete; @@ -518,45 +518,14 @@ struct preparator struct format_tag { - using type = conditional_t::value, - compiletime_format_tag, runtime_format_tag>; -}; - -#if FMT_USE_CONSTEXPR -template -auto do_compile(runtime_format_tag, Format format) { - return preparator::prepare(std::move(format)); -} - -template -FMT_CONSTEXPR auto do_compile(compiletime_format_tag, const Format& format) { - return typename basic_prepared_format::type(format); -} -#else -template -auto do_compile(const Format& format) - -> decltype(preparator::prepare(format)) { - return preparator::prepare(format); -} -#endif - -template -using prepared_format_t = - typename basic_prepared_format, - Args...>::type; } // namespace internal #if FMT_USE_CONSTEXPR template ::value)> FMT_CONSTEXPR auto compile(S format_str) { - return internal::do_compile( - typename internal::format_tag::type{}, std::move(format_str)); + return typename internal::basic_prepared_format::type( + format_str); } #endif @@ -566,7 +535,7 @@ auto compile(const Char (&format_str)[N]) -> Args...>::prepared_format_type { const auto view = basic_string_view(format_str, N - 1); return internal::preparator, Args...>::prepare( - internal::to_runtime_format(view)); + internal::to_runtime_format(view)); } template