From 400667857788337b2548629a35068bcd5cec782e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Wed, 14 Mar 2018 20:17:15 +0100 Subject: [PATCH] Fix warnings under MSVC (#679) Closes #678. --- include/fmt/core.h | 5 +++-- include/fmt/format.h | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 8acc2f6029cf..f43c579dc306 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1064,8 +1064,9 @@ class basic_format_args { unsigned max_size() const { int64_t signed_types = static_cast(types_); - return signed_types < 0 ? - -signed_types : static_cast(internal::max_packed_args); + return static_cast(signed_types < 0 + ? -signed_types + : static_cast(internal::max_packed_args)); } }; diff --git a/include/fmt/format.h b/include/fmt/format.h index dc2336cdf40e..ab19c85af84b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1452,7 +1452,7 @@ class arg_formatter_base { void operator()(const char_type *value) { internal::handle_cstring_type_spec( - specs_.type_, cstring_spec_handler(*this, value)); + static_cast(specs_.type_), cstring_spec_handler(*this, value)); } void operator()(basic_string_view value) { @@ -1461,7 +1461,7 @@ class arg_formatter_base { } void operator()(const void *value) { - check_pointer_type_spec(specs_.type_, internal::error_handler()); + check_pointer_type_spec(static_cast(specs_.type_), internal::error_handler()); write_pointer(value); } }; @@ -2394,7 +2394,7 @@ class basic_writer { void on_hex() { if (spec.flag(HASH_FLAG)) { prefix[prefix_size++] = '0'; - prefix[prefix_size++] = spec.type(); + prefix[prefix_size++] = static_cast(spec.type()); } unsigned num_digits = count_digits<4>(); writer.write_int(num_digits, get_prefix(), spec, @@ -2415,7 +2415,7 @@ class basic_writer { void on_bin() { if (spec.flag(HASH_FLAG)) { prefix[prefix_size++] = '0'; - prefix[prefix_size++] = spec.type(); + prefix[prefix_size++] = static_cast(spec.type()); } unsigned num_digits = count_digits<1>(); writer.write_int(num_digits, get_prefix(), spec, @@ -2465,7 +2465,7 @@ class basic_writer { // Writes a formatted integer. template void write_int(T value, const Spec &spec) { - internal::handle_int_type_spec(spec.type(), + internal::handle_int_type_spec(static_cast(spec.type()), int_writer(*this, value, spec)); } @@ -2698,7 +2698,7 @@ template void basic_writer::write_double(T value, const format_specs &spec) { // Check type. float_spec_handler handler(spec.type()); - internal::handle_float_type_spec(spec.type(), handler); + internal::handle_float_type_spec(static_cast(spec.type()), handler); char sign = 0; // Use isnegative instead of value < 0 because the latter is always