From 67feef558969b9819987c6e55751075b8279c347 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 1 Jun 2019 09:35:02 -0700 Subject: [PATCH] Make enable_if_t more std-like and move to fmt namespace --- include/fmt/core.h | 12 ++++++++---- include/fmt/format-inl.h | 2 +- include/fmt/format.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index a733e4ef..6e73481f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -199,6 +199,11 @@ #endif FMT_BEGIN_NAMESPACE + +// An implementation of enable_if_t for pre-C++14 systems. +template +using enable_if_t = typename std::enable_if::type; + namespace internal { #if defined(FMT_USE_STRING_VIEW) @@ -210,10 +215,9 @@ using std_string_view = std::experimental::basic_string_view; template struct std_string_view {}; #endif -// An enable_if helper to be used in template parameters. enable_if in template -// parameters results in much shorter symbols: https://godbolt.org/z/sWw4vP. -template using enable_if_t = typename std::enable_if::type; -#define FMT_ENABLE_IF(...) internal::enable_if_t<__VA_ARGS__> = 0 +// An enable_if helper to be used in template parameters which results in much +// shorter symbols: https://godbolt.org/z/sWw4vP. +#define FMT_ENABLE_IF(...) enable_if_t<__VA_ARGS__, int> = 0 #if (__cplusplus >= 201703L || \ (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \ diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 24c6c77b..28027a59 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -674,7 +674,7 @@ template struct grisu_shortest_handler { } }; -template > +template > FMT_API bool grisu_format(Double value, buffer& buf, int precision, unsigned options, int& exp) { FMT_ASSERT(value >= 0, "value is negative"); diff --git a/include/fmt/format.h b/include/fmt/format.h index 7e4cf3be..42846f90 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2245,7 +2245,7 @@ FMT_CONSTEXPR bool do_check_format_string(basic_string_view s, } template ::value>> + enable_if_t::value, int>> void check_format_string(S format_str) { typedef typename S::char_type char_t; FMT_CONSTEXPR_DECL bool invalid_format =