diff options
Diffstat (limited to 'src/third_party/fmt/dist/include/fmt/color.h')
-rw-r--r-- | src/third_party/fmt/dist/include/fmt/color.h | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/third_party/fmt/dist/include/fmt/color.h b/src/third_party/fmt/dist/include/fmt/color.h index b29ab082192..f1683a7181f 100644 --- a/src/third_party/fmt/dist/include/fmt/color.h +++ b/src/third_party/fmt/dist/include/fmt/color.h @@ -518,17 +518,10 @@ inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT { buffer.append(begin, end); } -// The following specialization disables using std::FILE as a character type, -// which is needed because or else -// fmt::print(stderr, fmt::emphasis::bold, ""); -// would take stderr (a std::FILE *) as the format string. -template <> struct is_string<std::FILE*> : std::false_type {}; -template <> struct is_string<const std::FILE*> : std::false_type {}; - template <typename Char> -std::basic_string<Char> vformat( - const text_style& ts, basic_string_view<Char> format_str, - basic_format_args<typename buffer_context<Char>::type> args) { +std::basic_string<Char> vformat(const text_style& ts, + basic_string_view<Char> format_str, + basic_format_args<buffer_context<Char> > args) { basic_memory_buffer<Char> buffer; bool has_style = false; if (ts.has_emphasis()) { @@ -556,9 +549,9 @@ std::basic_string<Char> vformat( } } // namespace internal -template <typename S, typename Char = typename internal::char_t<S>::type> +template <typename S, typename Char = char_t<S> > void vprint(std::FILE* f, const text_style& ts, const S& format, - basic_format_args<typename buffer_context<Char>::type> args) { + basic_format_args<buffer_context<Char> > args) { bool has_style = false; if (ts.has_emphasis()) { has_style = true; @@ -587,15 +580,14 @@ void vprint(std::FILE* f, const text_style& ts, const S& format, fmt::print(fmt::emphasis::bold | fg(fmt::color::red), "Elapsed time: {0:.2f} seconds", 1.23); */ -template <typename String, typename... Args, - FMT_ENABLE_IF(internal::is_string<String>::value)> -void print(std::FILE* f, const text_style& ts, const String& format_str, +template <typename S, typename... Args, + FMT_ENABLE_IF(internal::is_string<S>::value)> +void print(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args) { internal::check_format_string<Args...>(format_str); - typedef typename internal::char_t<String>::type char_t; - typedef typename buffer_context<char_t>::type context_t; - format_arg_store<context_t, Args...> as{args...}; - vprint(f, ts, format_str, basic_format_args<context_t>(as)); + using context = buffer_context<char_t<S> >; + format_arg_store<context, Args...> as{args...}; + vprint(f, ts, format_str, basic_format_args<context>(as)); } /** @@ -605,17 +597,16 @@ void print(std::FILE* f, const text_style& ts, const String& format_str, fmt::print(fmt::emphasis::bold | fg(fmt::color::red), "Elapsed time: {0:.2f} seconds", 1.23); */ -template <typename String, typename... Args, - FMT_ENABLE_IF(internal::is_string<String>::value)> -void print(const text_style& ts, const String& format_str, - const Args&... args) { +template <typename S, typename... Args, + FMT_ENABLE_IF(internal::is_string<S>::value)> +void print(const text_style& ts, const S& format_str, const Args&... args) { return print(stdout, ts, format_str, args...); } -template <typename S, typename Char = FMT_CHAR(S)> +template <typename S, typename Char = char_t<S> > inline std::basic_string<Char> vformat( const text_style& ts, const S& format_str, - basic_format_args<typename buffer_context<Char>::type> args) { + basic_format_args<buffer_context<Char> > args) { return internal::vformat(ts, to_string_view(format_str), args); } @@ -631,10 +622,9 @@ inline std::basic_string<Char> vformat( "The answer is {}", 42); \endrst */ -template <typename S, typename... Args> -inline std::basic_string<FMT_CHAR(S)> format(const text_style& ts, - const S& format_str, - const Args&... args) { +template <typename S, typename... Args, typename Char = char_t<S> > +inline std::basic_string<Char> format(const text_style& ts, const S& format_str, + const Args&... args) { return internal::vformat(ts, to_string_view(format_str), {internal::make_args_checked(format_str, args...)}); } |