mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Fix bogus "conditional expression is constant" MSVC warnings
This commit is contained in:
parent
aab64b55a4
commit
fd53bb6fb8
10
format.h
10
format.h
@ -800,6 +800,10 @@ struct EnableIf {};
|
|||||||
template<class T>
|
template<class T>
|
||||||
struct EnableIf<true, T> { typedef T type; };
|
struct EnableIf<true, T> { typedef T type; };
|
||||||
|
|
||||||
|
// A helper function to suppress bogus "conditional expression is constant"
|
||||||
|
// warnings.
|
||||||
|
inline bool check(bool value) { return value; }
|
||||||
|
|
||||||
// Makes an Arg object from any type.
|
// Makes an Arg object from any type.
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
class MakeValue : public Arg {
|
class MakeValue : public Arg {
|
||||||
@ -859,7 +863,7 @@ class MakeValue : public Arg {
|
|||||||
MakeValue(long value) {
|
MakeValue(long value) {
|
||||||
// To minimize the number of types we need to deal with, long is
|
// To minimize the number of types we need to deal with, long is
|
||||||
// translated either to int or to long long depending on its size.
|
// translated either to int or to long long depending on its size.
|
||||||
if (sizeof(long) == sizeof(int))
|
if (check(sizeof(long) == sizeof(int)))
|
||||||
int_value = static_cast<int>(value);
|
int_value = static_cast<int>(value);
|
||||||
else
|
else
|
||||||
long_long_value = value;
|
long_long_value = value;
|
||||||
@ -869,7 +873,7 @@ class MakeValue : public Arg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MakeValue(unsigned long value) {
|
MakeValue(unsigned long value) {
|
||||||
if (sizeof(unsigned long) == sizeof(unsigned))
|
if (check(sizeof(unsigned long) == sizeof(unsigned)))
|
||||||
uint_value = static_cast<unsigned>(value);
|
uint_value = static_cast<unsigned>(value);
|
||||||
else
|
else
|
||||||
ulong_long_value = value;
|
ulong_long_value = value;
|
||||||
@ -2634,7 +2638,7 @@ struct ArgArraySize {
|
|||||||
Arg array[fmt::internal::ArgArraySize<sizeof...(Args)>::VALUE] = { \
|
Arg array[fmt::internal::ArgArraySize<sizeof...(Args)>::VALUE] = { \
|
||||||
fmt::internal::MakeValue<Char>(args)... \
|
fmt::internal::MakeValue<Char>(args)... \
|
||||||
}; \
|
}; \
|
||||||
if (sizeof...(Args) > fmt::ArgList::MAX_PACKED_ARGS) \
|
if (fmt::internal::check((sizeof...(Args) > fmt::ArgList::MAX_PACKED_ARGS))) \
|
||||||
set_types(array, args...); \
|
set_types(array, args...); \
|
||||||
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), \
|
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), \
|
||||||
fmt::ArgList(fmt::internal::make_type(args...), array)); \
|
fmt::ArgList(fmt::internal::make_type(args...), array)); \
|
||||||
|
Loading…
Reference in New Issue
Block a user