diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 56b486f5..94dd42c2 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -8,14 +8,8 @@ #ifndef FMT_COMPILE_H_ #define FMT_COMPILE_H_ -#ifndef FMT_HAS_CONSTRUCTIBLE_TRAITS -# define FMT_HAS_CONSTRUCTIBLE_TRAITS \ - (FMT_GCC_VERSION >= 407 || FMT_CLANG_VERSION || FMT_MSC_VER) -#endif - -#include "format.h" - #include +#include "format.h" FMT_BEGIN_NAMESPACE @@ -506,12 +500,10 @@ struct compiletime_parts_provider { template struct parts_container_concept_check : std::true_type { -#if FMT_HAS_CONSTRUCTIBLE_TRAITS static_assert(std::is_copy_constructible::value, "PartsContainer is not copy constructible"); static_assert(std::is_move_constructible::value, "PartsContainer is not move constructible"); -#endif template struct has_format_part_type : std::false_type {}; @@ -669,98 +661,77 @@ template struct format_tag { #if FMT_USE_CONSTEXPR template -auto do_prepare(runtime_format_tag, Format format) { +auto do_compile(runtime_format_tag, Format format) { return preparator::prepare(std::move(format)); } template -FMT_CONSTEXPR auto do_prepare(compiletime_format_tag, const Format& format) { +FMT_CONSTEXPR auto do_compile(compiletime_format_tag, const Format& format) { return typename basic_prepared_format::type(format); } #else template -auto do_prepare(const Format& format) +auto do_compile(const Format& format) -> decltype(preparator::prepare(format)) { return preparator::prepare(format); } #endif } // namespace internal -template >> -struct parts_container { - typedef internal::parts_container type; -}; - -template -struct basic_prepared_format { - typedef typename internal::basic_prepared_format::type type; -}; - template struct prepared_format { - typedef typename basic_prepared_format< - std::string, typename parts_container::type, Args...>::type type; + typedef typename internal::basic_prepared_format< + std::string, internal::parts_container, Args...>::type type; }; template struct wprepared_format { - typedef - typename basic_prepared_format::type, - Args...>::type type; + typedef typename internal::basic_prepared_format< + std::wstring, internal::parts_container, Args...>::type type; }; -template >> -using parts_container_t = typename parts_container::type; - -template -using basic_prepared_format_t = - typename basic_prepared_format::type; +template +using prepared_format_t = typename internal::basic_prepared_format< + std::string, internal::parts_container, Args...>::type; template -using prepared_format_t = - basic_prepared_format_t, Args...>; - -template -using wprepared_format_t = - basic_prepared_format_t, Args...>; +using wprepared_format_t = typename internal::basic_prepared_format< + std::wstring, internal::parts_container, Args...>::type; #if FMT_USE_CONSTEXPR -template -FMT_CONSTEXPR auto compile(Format format) { - return internal::do_prepare( - typename internal::format_tag::type{}, std::move(format)); +template +FMT_CONSTEXPR auto compile(S format_str) { + return internal::do_compile( + typename internal::format_tag::type{}, std::move(format_str)); } #else -template -auto compile(Format format) -> - typename internal::preparator::prepared_format_type { - return internal::preparator::prepare(std::move(format)); +template +auto compile(S format_str) -> + typename internal::preparator::prepared_format_type { + return internal::preparator::prepare(std::move(format_str)); } #endif template -auto compile(const Char* format) -> +auto compile(const Char* format_str) -> typename internal::preparator, Args...>::prepared_format_type { - return compile(internal::to_runtime_format(format)); + return compile(internal::to_runtime_format(format_str)); } template -auto compile(const Char(format)[N]) -> +auto compile(const Char(format_str)[N]) -> typename internal::preparator, Args...>::prepared_format_type { - const auto view = basic_string_view(format, N); + const auto view = basic_string_view(format_str, N); return compile(internal::to_runtime_format(view)); } template -auto compile(basic_string_view format) -> +auto compile(basic_string_view format_str) -> typename internal::preparator, Args...>::prepared_format_type { - return compile(internal::to_runtime_format(format)); + return compile(internal::to_runtime_format(format_str)); } FMT_END_NAMESPACE diff --git a/test/compile-test.cc b/test/compile-test.cc index e3fdec09..c0bf7689 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -486,9 +486,9 @@ TEST(PrepareTest, ReusedPreparedFormatType) { TEST(PrepareTest, UserProvidedPartsContainerUnderlyingContainer) { typedef fmt::format_part format_part; - typedef fmt::parts_container>::type + typedef fmt::internal::parts_container> parts_container; - typedef fmt::basic_prepared_format::type prepared_format; prepared_format prepared = fmt::compile("The {} is {}."); @@ -532,7 +532,7 @@ class custom_parts_container { }; TEST(PrepareTest, UserProvidedPartsContainer) { - typedef fmt::basic_prepared_format::type prepared_format; prepared_format prepared = fmt::compile("The {} is {}.");