From 5859e58ba17073cf1c16536205450528f3530df0 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Apr 2018 21:11:31 -0700 Subject: [PATCH] Fix msvc warnings --- include/fmt/format.h | 4 ++-- test/format-test.cc | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index a556a6d6..7ba53e31 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1804,9 +1804,9 @@ struct arg_ref { FMT_CONSTEXPR explicit arg_ref(unsigned index) : kind(INDEX), index(index) {} explicit arg_ref(basic_string_view name) : kind(NAME), name(name) {} - FMT_CONSTEXPR arg_ref &operator=(unsigned index) { + FMT_CONSTEXPR arg_ref &operator=(unsigned idx) { kind = INDEX; - this->index = index; + index = idx; return *this; } diff --git a/test/format-test.cc b/test/format-test.cc index a876f5a3..a1a9e723 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1565,7 +1565,7 @@ struct test_format_specs_handler { enum Result { NONE, PLUS, MINUS, SPACE, HASH, ZERO, ERROR }; Result res = NONE; - fmt::alignment align = fmt::ALIGN_DEFAULT; + fmt::alignment align_ = fmt::ALIGN_DEFAULT; char fill = 0; unsigned width = 0; fmt::internal::arg_ref width_ref; @@ -1577,12 +1577,12 @@ struct test_format_specs_handler { // to a constant" with compiler-generated copy ctor. FMT_CONSTEXPR test_format_specs_handler() {} FMT_CONSTEXPR test_format_specs_handler(const test_format_specs_handler &other) - : res(other.res), align(other.align), fill(other.fill), + : res(other.res), align_(other.align_), fill(other.fill), width(other.width), width_ref(other.width_ref), precision(other.precision), precision_ref(other.precision_ref), type(other.type) {} - FMT_CONSTEXPR void on_align(fmt::alignment a) { align = a; } + FMT_CONSTEXPR void on_align(fmt::alignment a) { align_ = a; } FMT_CONSTEXPR void on_fill(char f) { fill = f; } FMT_CONSTEXPR void on_plus() { res = PLUS; } FMT_CONSTEXPR void on_minus() { res = MINUS; } @@ -1597,11 +1597,13 @@ struct test_format_specs_handler { FMT_CONSTEXPR void on_precision(unsigned p) { precision = p; } FMT_CONSTEXPR void on_dynamic_precision(fmt::internal::auto_id) {} - FMT_CONSTEXPR void on_dynamic_precision(unsigned index) { precision_ref = index; } + FMT_CONSTEXPR void on_dynamic_precision(unsigned index) { + precision_ref = index; + } FMT_CONSTEXPR void on_dynamic_precision(string_view) {} FMT_CONSTEXPR void end_precision() {} - FMT_CONSTEXPR void on_type(char type) { this->type = type; } + FMT_CONSTEXPR void on_type(char t) { type = t; } FMT_CONSTEXPR void on_error(const char *) { res = ERROR; } }; @@ -1613,7 +1615,7 @@ FMT_CONSTEXPR test_format_specs_handler parse_test_specs(const char *s) { TEST(FormatTest, ConstexprParseFormatSpecs) { typedef test_format_specs_handler handler; - static_assert(parse_test_specs("<").align == fmt::ALIGN_LEFT, ""); + static_assert(parse_test_specs("<").align_ == fmt::ALIGN_LEFT, ""); static_assert(parse_test_specs("*^").fill == '*', ""); static_assert(parse_test_specs("+").res == handler::PLUS, ""); static_assert(parse_test_specs("-").res == handler::MINUS, ""); @@ -1711,7 +1713,7 @@ FMT_CONSTEXPR test_format_specs_handler check_specs(const char *s) { TEST(FormatTest, ConstexprSpecsChecker) { typedef test_format_specs_handler handler; - static_assert(check_specs("<").align == fmt::ALIGN_LEFT, ""); + static_assert(check_specs("<").align_ == fmt::ALIGN_LEFT, ""); static_assert(check_specs("*^").fill == '*', ""); static_assert(check_specs("+").res == handler::PLUS, ""); static_assert(check_specs("-").res == handler::MINUS, "");