Skip to content

Commit

Permalink
Fix warnings under MSVC (#679)
Browse files Browse the repository at this point in the history
Closes #678.
  • Loading branch information
foonathan committed Mar 14, 2018
1 parent 9c5f54a commit 4006678
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,9 @@ class basic_format_args {

unsigned max_size() const {
int64_t signed_types = static_cast<int64_t>(types_);
return signed_types < 0 ?
-signed_types : static_cast<int64_t>(internal::max_packed_args);
return static_cast<unsigned>(signed_types < 0
? -signed_types
: static_cast<int64_t>(internal::max_packed_args));
}
};

Expand Down
12 changes: 6 additions & 6 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(specs_.type_), cstring_spec_handler(*this, value));
}

void operator()(basic_string_view<char_type> value) {
Expand All @@ -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<char>(specs_.type_), internal::error_handler());
write_pointer(value);
}
};
Expand Down Expand Up @@ -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<char>(spec.type());
}
unsigned num_digits = count_digits<4>();
writer.write_int(num_digits, get_prefix(), spec,
Expand All @@ -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<char>(spec.type());
}
unsigned num_digits = count_digits<1>();
writer.write_int(num_digits, get_prefix(), spec,
Expand Down Expand Up @@ -2465,7 +2465,7 @@ class basic_writer {
// Writes a formatted integer.
template <typename T, typename Spec>
void write_int(T value, const Spec &spec) {
internal::handle_int_type_spec(spec.type(),
internal::handle_int_type_spec(static_cast<char>(spec.type()),
int_writer<T, Spec>(*this, value, spec));
}

Expand Down Expand Up @@ -2698,7 +2698,7 @@ template <typename T>
void basic_writer<Range>::write_double(T value, const format_specs &spec) {
// Check type.
float_spec_handler<char_type> handler(spec.type());
internal::handle_float_type_spec(spec.type(), handler);
internal::handle_float_type_spec(static_cast<char>(spec.type()), handler);

char sign = 0;
// Use isnegative instead of value < 0 because the latter is always
Expand Down

0 comments on commit 4006678

Please sign in to comment.