From e30d8391e401f74a48d822c64d96f965ff16c722 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 11 Apr 2020 06:26:42 -0700 Subject: [PATCH] Suppress an MSVC warning (#1622) --- include/fmt/format.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 9060dc94..3b1ebe59 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2139,12 +2139,18 @@ template class numeric_specs_checker { // A format specifier handler that checks if specifiers are consistent with the // argument type. template class specs_checker : public Handler { + private: + numeric_specs_checker checker_; + + // Suppress an MSVC warning about using this in initializer list. + FMT_CONSTEXPR Handler& error_handler() { return *this; } + public: FMT_CONSTEXPR specs_checker(const Handler& handler, internal::type arg_type) - : Handler(handler), checker_(*this, arg_type) {} + : Handler(handler), checker_(error_handler(), arg_type) {} FMT_CONSTEXPR specs_checker(const specs_checker& other) - : Handler(other), checker_(*this, other.arg_type_) {} + : Handler(other), checker_(error_handler(), other.arg_type_) {} FMT_CONSTEXPR void on_align(align_t align) { if (align == align::numeric) checker_.require_numeric_argument(); @@ -2177,9 +2183,6 @@ template class specs_checker : public Handler { } FMT_CONSTEXPR void end_precision() { checker_.check_precision(); } - - private: - numeric_specs_checker checker_; }; template