From d05d42751ce55ecbbd1a357a602962b4379e0252 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 12 Jun 2019 18:14:56 -0700 Subject: [PATCH] Remove old msvc workaround from arg_formatter_base and fix warning --- include/fmt/format.h | 30 +++++++++++++++++------------- test/format-test.cc | 4 +++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 420cf652..0ed27167 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1423,20 +1423,24 @@ class arg_formatter_base { return out(); } - template ::value || - std::is_same::value)> + template ::value)> iterator operator()(T value) { - // MSVC2013 fails to compile separate overloads for bool and char_type so - // use std::is_same instead. - if (std::is_same::value) { - if (specs_ && specs_->type) return (*this)(value ? 1 : 0); - write(value != 0); - } else if (std::is_same::value) { - internal::handle_char_specs( - specs_, char_spec_handler(*this, static_cast(value))); - } else { - specs_ ? writer_.write_int(value, *specs_) : writer_.write(value); - } + if (specs_) + writer_.write_int(value, *specs_); + else + writer_.write(value); + return out(); + } + + iterator operator()(char_type value) { + internal::handle_char_specs( + specs_, char_spec_handler(*this, static_cast(value))); + return out(); + } + + iterator operator()(bool value) { + if (specs_ && specs_->type) return (*this)(value ? 1 : 0); + write(value != 0); return out(); } diff --git a/test/format-test.cc b/test/format-test.cc index 033d92ab..7c2b1c5a 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2494,7 +2494,9 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) { struct mychar { int value; mychar() = default; - mychar(char val) : value(val) {} + + template mychar(T val) : value(static_cast(val)) {} + operator int() const { return value; } };