mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-28 06:36:02 +00:00
Suppress MSVC warnings "C4127: conditional expression is constant" by used const_check (#4233)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
720da57bab
commit
542600013f
@ -2885,7 +2885,7 @@ FMT_API void vprint_buffered(FILE* f, string_view fmt, format_args args);
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
|
FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
|
||||||
vargs<T...> va = {{args...}};
|
vargs<T...> va = {{args...}};
|
||||||
if (!detail::use_utf8)
|
if (detail::const_check(!detail::use_utf8))
|
||||||
return detail::vprint_mojibake(stdout, fmt.str, va, false);
|
return detail::vprint_mojibake(stdout, fmt.str, va, false);
|
||||||
return detail::is_locking<T...>() ? vprint_buffered(stdout, fmt.str, va)
|
return detail::is_locking<T...>() ? vprint_buffered(stdout, fmt.str, va)
|
||||||
: vprint(fmt.str, va);
|
: vprint(fmt.str, va);
|
||||||
@ -2902,7 +2902,8 @@ FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
FMT_INLINE void print(FILE* f, format_string<T...> fmt, T&&... args) {
|
FMT_INLINE void print(FILE* f, format_string<T...> fmt, T&&... args) {
|
||||||
vargs<T...> va = {{args...}};
|
vargs<T...> va = {{args...}};
|
||||||
if (!detail::use_utf8) return detail::vprint_mojibake(f, fmt.str, va, false);
|
if (detail::const_check(!detail::use_utf8))
|
||||||
|
return detail::vprint_mojibake(f, fmt.str, va, false);
|
||||||
return detail::is_locking<T...>() ? vprint_buffered(f, fmt.str, va)
|
return detail::is_locking<T...>() ? vprint_buffered(f, fmt.str, va)
|
||||||
: vprint(f, fmt.str, va);
|
: vprint(f, fmt.str, va);
|
||||||
}
|
}
|
||||||
@ -2912,8 +2913,9 @@ FMT_INLINE void print(FILE* f, format_string<T...> fmt, T&&... args) {
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
FMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {
|
FMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {
|
||||||
vargs<T...> va = {{args...}};
|
vargs<T...> va = {{args...}};
|
||||||
return detail::use_utf8 ? vprintln(f, fmt.str, va)
|
return detail::const_check(detail::use_utf8)
|
||||||
: detail::vprint_mojibake(f, fmt.str, va, true);
|
? vprintln(f, fmt.str, va)
|
||||||
|
: detail::vprint_mojibake(f, fmt.str, va, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats `args` according to specifications in `fmt` and writes the output
|
/// Formats `args` according to specifications in `fmt` and writes the output
|
||||||
|
@ -1695,7 +1695,7 @@ FMT_API auto is_printable(uint32_t cp) -> bool;
|
|||||||
|
|
||||||
inline auto needs_escape(uint32_t cp) -> bool {
|
inline auto needs_escape(uint32_t cp) -> bool {
|
||||||
if (cp < 0x20 || cp == 0x7f || cp == '"' || cp == '\\') return true;
|
if (cp < 0x20 || cp == 0x7f || cp == '"' || cp == '\\') return true;
|
||||||
if (FMT_OPTIMIZE_SIZE > 1) return false;
|
if (const_check(FMT_OPTIMIZE_SIZE > 1)) return false;
|
||||||
return !is_printable(cp);
|
return !is_printable(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1718,7 +1718,7 @@ auto find_escape(const Char* begin, const Char* end)
|
|||||||
|
|
||||||
inline auto find_escape(const char* begin, const char* end)
|
inline auto find_escape(const char* begin, const char* end)
|
||||||
-> find_escape_result<char> {
|
-> find_escape_result<char> {
|
||||||
if (!use_utf8) return find_escape<char>(begin, end);
|
if (const_check(!use_utf8)) return find_escape<char>(begin, end);
|
||||||
auto result = find_escape_result<char>{end, nullptr, 0};
|
auto result = find_escape_result<char>{end, nullptr, 0};
|
||||||
for_each_codepoint(string_view(begin, to_unsigned(end - begin)),
|
for_each_codepoint(string_view(begin, to_unsigned(end - begin)),
|
||||||
[&](uint32_t cp, string_view sv) {
|
[&](uint32_t cp, string_view sv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user