From e54eb6763995242abbc9de58303a4d68f86b118f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A9=D0=B0=D0=BF=D0=BE=D0=B2?= Date: Tue, 27 Oct 2020 13:55:26 +0500 Subject: [PATCH] Workaround bugs in gcc 8 --- include/fmt/color.h | 9 +++++---- include/fmt/compile.h | 16 ++++++++-------- include/fmt/core.h | 15 ++++++++------- include/fmt/locale.h | 8 ++++---- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/include/fmt/color.h b/include/fmt/color.h index 78910589..e89d4e3a 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -589,10 +589,11 @@ OutputIt vformat_to( \endrst */ template >::value&& - detail::is_string::value)> -inline OutputIt format_to(OutputIt out, const text_style& ts, - const S& format_str, Args&&... args) { + bool enable = (detail::is_output_iterator>::value&& + detail::is_string::value)> +inline auto format_to(OutputIt out, const text_style& ts, + const S& format_str, Args&&... args) -> + typename std::enable_if::type { return vformat_to(out, ts, to_string_view(format_str), fmt::make_args_checked(format_str, args...)); } diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 7db610d9..8b79a530 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -667,14 +667,14 @@ OutputIt format_to(OutputIt out, const S&, const Args&... args) { return format_to(out, compiled, args...); } -template ::value&& - std::is_base_of::value)> -format_to_n_result format_to_n(OutputIt out, size_t n, - const CompiledFormat& cf, - const Args&... args) { +template +typename std::enable_if<(detail::is_output_iterator< + OutputIt, typename CompiledFormat::char_type>::value&& + std::is_base_of::value), + format_to_n_result +>::type format_to_n(OutputIt out, size_t n, + const CompiledFormat& cf, const Args&... args) { auto it = format_to(detail::truncating_iterator(out, n), cf, args...); return {it.base(), it.count()}; diff --git a/include/fmt/core.h b/include/fmt/core.h index 2903be5a..4278f0e1 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1968,10 +1968,11 @@ inline void vprint_mojibake(std::FILE*, string_view, format_args) {} // GCC 8 and earlier cannot handle std::back_insert_iterator with // vformat_to(...) overload, so SFINAE on iterator type instead. template , - FMT_ENABLE_IF(detail::is_output_iterator::value)> -OutputIt vformat_to( + bool enable = detail::is_output_iterator::value> +auto vformat_to( OutputIt out, const S& format_str, - basic_format_args>> args) { + basic_format_args>> args) -> + typename std::enable_if::type { decltype(detail::get_buffer(out)) buf(detail::get_buffer_init(out)); detail::vformat_to(buf, to_string_view(format_str), args); return detail::get_iterator(buf); @@ -2023,10 +2024,10 @@ inline format_to_n_result vformat_to_n( \endrst */ template >::value)> -inline format_to_n_result format_to_n(OutputIt out, size_t n, - const S& format_str, - const Args&... args) { + bool enable = detail::is_output_iterator>::value> +inline auto format_to_n(OutputIt out, size_t n, + const S& format_str, const Args&... args) -> + typename std::enable_if>::type { const auto& vargs = fmt::make_args_checked(format_str, args...); return vformat_to_n(out, n, to_string_view(format_str), vargs); } diff --git a/include/fmt/locale.h b/include/fmt/locale.h index 517f6505..7301bf92 100644 --- a/include/fmt/locale.h +++ b/include/fmt/locale.h @@ -51,10 +51,10 @@ inline OutputIt vformat_to( } template , - FMT_ENABLE_IF(detail::is_output_iterator::value)> -inline OutputIt format_to(OutputIt out, const std::locale& loc, - const S& format_str, Args&&... args) { + bool enable = detail::is_output_iterator>::value> +inline auto format_to(OutputIt out, const std::locale& loc, + const S& format_str, Args&&... args) -> + typename std::enable_if::type { const auto& vargs = fmt::make_args_checked(format_str, args...); return vformat_to(out, loc, to_string_view(format_str), vargs); }