Skip to content

Commit

Permalink
Fix narrowing conversion warning in struct fstring
Browse files Browse the repository at this point in the history
Warning C4267: 'initializing': conversion from 'size_t' to 'const int',
possible loss of data.

Client applications fail to compile if warnings are treated as errors.
  • Loading branch information
sergio-nsk committed Oct 23, 2024
1 parent e9eaa27 commit ffb0f2b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2634,12 +2634,14 @@ inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; }
/// A compile-time format string.
template <typename... T> struct fstring {
private:
static constexpr int num_static_named_args =
static constexpr size_t num_static_named_args =
detail::count_static_named_args<T...>();

using checker = detail::format_string_checker<
char, static_cast<int>(sizeof...(T)), num_static_named_args,
num_static_named_args != detail::count_named_args<T...>()>;
using checker =
detail::format_string_checker<char, static_cast<int>(sizeof...(T)),
static_cast<int>(num_static_named_args),
num_static_named_args !=
detail::count_named_args<T...>()>;

using arg_pack = detail::arg_pack<T...>;

Expand Down

0 comments on commit ffb0f2b

Please sign in to comment.