fixup! Clean-up sign-conversion warnings in public headers
This commit is contained in:
parent
e06d524c9e
commit
89321b86bf
@ -795,6 +795,15 @@ struct chrono_formatter {
|
|||||||
std::chrono::duration<Rep, Period> d)
|
std::chrono::duration<Rep, Period> d)
|
||||||
: context(ctx), out(o), val(static_cast<rep>(std::abs(d.count()))), negative(d.count() < 0) {
|
: context(ctx), out(o), val(static_cast<rep>(std::abs(d.count()))), negative(d.count() < 0) {
|
||||||
|
|
||||||
|
if (d.count() < 0) {
|
||||||
|
val = static_cast<rep>(- d.count());
|
||||||
|
negative = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val = static_cast<rep>(d.count());
|
||||||
|
negative = false;
|
||||||
|
}
|
||||||
|
|
||||||
// this may overflow and/or the result may not fit in the
|
// this may overflow and/or the result may not fit in the
|
||||||
// target type.
|
// target type.
|
||||||
#if FMT_SAFE_DURATION_CAST
|
#if FMT_SAFE_DURATION_CAST
|
||||||
|
|||||||
@ -141,7 +141,7 @@ class format_string_compiler : public error_handler {
|
|||||||
auto it = parse_format_specs(begin, end, handler);
|
auto it = parse_format_specs(begin, end, handler);
|
||||||
if (*it != '}') on_error("missing '}' in format string");
|
if (*it != '}') on_error("missing '}' in format string");
|
||||||
repl.arg_id = part_.part_kind == part::kind::arg_index
|
repl.arg_id = part_.part_kind == part::kind::arg_index
|
||||||
? arg_ref<Char>(static_cast<int>(part_.val.arg_index))
|
? arg_ref<Char>(part_.val.arg_index)
|
||||||
: arg_ref<Char>(part_.val.str);
|
: arg_ref<Char>(part_.val.str);
|
||||||
auto part = part::make_replacement(repl);
|
auto part = part::make_replacement(repl);
|
||||||
part.arg_id_end = begin;
|
part.arg_id_end = begin;
|
||||||
|
|||||||
@ -1244,7 +1244,7 @@ int snprintf_float(T value, int precision, float_specs specs,
|
|||||||
buffer<char>& buf);
|
buffer<char>& buf);
|
||||||
|
|
||||||
template <typename T> T promote_float(T value) { return value; }
|
template <typename T> T promote_float(T value) { return value; }
|
||||||
inline double promote_float(float value) { return static_cast<double>(value); }
|
inline double promote_float(float value) { return value; }
|
||||||
|
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) {
|
FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) {
|
||||||
@ -2620,18 +2620,18 @@ class format_string_checker {
|
|||||||
public:
|
public:
|
||||||
explicit FMT_CONSTEXPR format_string_checker(
|
explicit FMT_CONSTEXPR format_string_checker(
|
||||||
basic_string_view<Char> format_str, ErrorHandler eh)
|
basic_string_view<Char> format_str, ErrorHandler eh)
|
||||||
: arg_id_(max_value<unsigned>()),
|
: arg_id_(ARG_ID_SENTINEL),
|
||||||
context_(format_str, eh),
|
context_(format_str, eh),
|
||||||
parse_funcs_{&parse_format_specs<Args, parse_context_type>...} {}
|
parse_funcs_{&parse_format_specs<Args, parse_context_type>...} {}
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
|
FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_arg_id() {
|
FMT_CONSTEXPR void on_arg_id() {
|
||||||
arg_id_ = static_cast<unsigned>(context_.next_arg_id());
|
arg_id_ = context_.next_arg_id();
|
||||||
check_arg_id();
|
check_arg_id();
|
||||||
}
|
}
|
||||||
FMT_CONSTEXPR void on_arg_id(int id) {
|
FMT_CONSTEXPR void on_arg_id(int id) {
|
||||||
arg_id_ = static_cast<unsigned>(id);
|
arg_id_ = id;
|
||||||
context_.check_arg_id(id);
|
context_.check_arg_id(id);
|
||||||
check_arg_id();
|
check_arg_id();
|
||||||
}
|
}
|
||||||
@ -2661,7 +2661,9 @@ class format_string_checker {
|
|||||||
// Format specifier parsing function.
|
// Format specifier parsing function.
|
||||||
using parse_func = const Char* (*)(parse_context_type&);
|
using parse_func = const Char* (*)(parse_context_type&);
|
||||||
|
|
||||||
unsigned arg_id_;
|
enum { ARG_ID_SENTINEL = -1 };
|
||||||
|
|
||||||
|
int arg_id_;
|
||||||
parse_context_type context_;
|
parse_context_type context_;
|
||||||
parse_func parse_funcs_[num_args > 0 ? num_args : 1];
|
parse_func parse_funcs_[num_args > 0 ? num_args : 1];
|
||||||
};
|
};
|
||||||
|
|||||||
@ -183,6 +183,12 @@ internal::truncating_iterator<OutputIt> printf(
|
|||||||
basic_format_args<Context> args) {
|
basic_format_args<Context> args) {
|
||||||
return Context(it, format, args).format();
|
return Context(it, format, args).format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ARG_INDEX_SENTINEL = -1
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
using internal::printf; // For printing into memory_buffer.
|
using internal::printf; // For printing into memory_buffer.
|
||||||
@ -335,10 +341,10 @@ template <typename OutputIt, typename Char> class basic_printf_context {
|
|||||||
|
|
||||||
// Returns the argument with specified index or, if arg_index is equal
|
// Returns the argument with specified index or, if arg_index is equal
|
||||||
// to the maximum unsigned value, the next argument.
|
// to the maximum unsigned value, the next argument.
|
||||||
format_arg get_arg(unsigned arg_index = internal::max_value<unsigned>());
|
format_arg get_arg(int arg_index = internal::ARG_INDEX_SENTINEL);
|
||||||
|
|
||||||
// Parses argument index, flags and width and returns the argument index.
|
// Parses argument index, flags and width and returns the argument index.
|
||||||
unsigned parse_header(const Char*& it, const Char* end, format_specs& specs);
|
int parse_header(const Char*& it, const Char* end, format_specs& specs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -397,18 +403,18 @@ void basic_printf_context<OutputIt, Char>::parse_flags(format_specs& specs,
|
|||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
template <typename OutputIt, typename Char>
|
||||||
typename basic_printf_context<OutputIt, Char>::format_arg
|
typename basic_printf_context<OutputIt, Char>::format_arg
|
||||||
basic_printf_context<OutputIt, Char>::get_arg(unsigned arg_index) {
|
basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
|
||||||
if (arg_index == internal::max_value<unsigned>())
|
if (arg_index == internal::ARG_INDEX_SENTINEL)
|
||||||
arg_index = static_cast<unsigned>(parse_ctx_.next_arg_id());
|
arg_index = parse_ctx_.next_arg_id();
|
||||||
else
|
else
|
||||||
parse_ctx_.check_arg_id(static_cast<int>(--arg_index));
|
parse_ctx_.check_arg_id(--arg_index);
|
||||||
return internal::get_arg(*this, static_cast<int>(arg_index));
|
return internal::get_arg(*this, arg_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
template <typename OutputIt, typename Char>
|
||||||
unsigned basic_printf_context<OutputIt, Char>::parse_header(
|
int basic_printf_context<OutputIt, Char>::parse_header(
|
||||||
const Char*& it, const Char* end, format_specs& specs) {
|
const Char*& it, const Char* end, format_specs& specs) {
|
||||||
unsigned arg_index = internal::max_value<unsigned>();
|
int arg_index = internal::ARG_INDEX_SENTINEL;
|
||||||
char_type c = *it;
|
char_type c = *it;
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
// Parse an argument index (if followed by '$') or a width possibly
|
// Parse an argument index (if followed by '$') or a width possibly
|
||||||
@ -417,7 +423,7 @@ unsigned basic_printf_context<OutputIt, Char>::parse_header(
|
|||||||
int value = parse_nonnegative_int(it, end, eh);
|
int value = parse_nonnegative_int(it, end, eh);
|
||||||
if (it != end && *it == '$') { // value is an argument index
|
if (it != end && *it == '$') { // value is an argument index
|
||||||
++it;
|
++it;
|
||||||
arg_index = static_cast<unsigned>(value);
|
arg_index = value;
|
||||||
} else {
|
} else {
|
||||||
if (c == '0') specs.fill[0] = '0';
|
if (c == '0') specs.fill[0] = '0';
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
@ -464,7 +470,7 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
|
|||||||
specs.align = align::right;
|
specs.align = align::right;
|
||||||
|
|
||||||
// Parse argument index, flags and width.
|
// Parse argument index, flags and width.
|
||||||
unsigned arg_index = parse_header(it, end, specs);
|
int arg_index = parse_header(it, end, specs);
|
||||||
if (arg_index == 0) on_error("argument index out of range");
|
if (arg_index == 0) on_error("argument index out of range");
|
||||||
|
|
||||||
// Parse precision.
|
// Parse precision.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user