mirror of
https://github.com/fmtlib/fmt.git
synced 2026-07-30 16:26:27 +08:00
avoid MSC warning C4702: unreachable code (#4822)
if FMT_CONSTEXPR is resolved to constexpr MSC warns about dead code after 'return' instruction. Explicitly using 'else' in these cases avoids the warning.
This commit is contained in:
parent
77b6ff700b
commit
b54093c658
@ -1285,10 +1285,13 @@ constexpr auto to_ascii(Char c) -> char {
|
||||
// Returns the number of code units in a code point or 1 on error.
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR auto code_point_length(const Char* begin) -> int {
|
||||
if FMT_CONSTEXPR20 (sizeof(Char) != 1) return 1;
|
||||
if FMT_CONSTEXPR20 (sizeof(Char) != 1) {
|
||||
return 1;
|
||||
} else {
|
||||
auto c = static_cast<unsigned char>(*begin);
|
||||
return static_cast<int>((0x3a55000000000000ull >> (2 * (c >> 3))) & 3) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Parses the range [begin, end) as an unsigned integer. This function assumes
|
||||
// that the range is non-empty and the first character is a digit.
|
||||
@ -2896,11 +2899,13 @@ FMT_API void vprint_buffered(FILE* f, string_view fmt, format_args args);
|
||||
template <typename... T>
|
||||
FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
|
||||
vargs<T...> va = {{args...}};
|
||||
if FMT_CONSTEXPR20 (!detail::use_utf8)
|
||||
return detail::vprint_mojibake(stdout, fmt.str, va, false);
|
||||
if FMT_CONSTEXPR20 (!detail::use_utf8) {
|
||||
detail::vprint_mojibake(stdout, fmt.str, va, false);
|
||||
} else {
|
||||
detail::is_locking<T...>() ? vprint_buffered(stdout, fmt.str, va)
|
||||
: vprint(fmt.str, va);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats `args` according to specifications in `fmt` and writes the
|
||||
@ -2913,20 +2918,25 @@ FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
|
||||
template <typename... T>
|
||||
FMT_INLINE void print(FILE* f, format_string<T...> fmt, T&&... args) {
|
||||
vargs<T...> va = {{args...}};
|
||||
if FMT_CONSTEXPR20 (!detail::use_utf8)
|
||||
return detail::vprint_mojibake(f, fmt.str, va, false);
|
||||
if FMT_CONSTEXPR20 (!detail::use_utf8) {
|
||||
detail::vprint_mojibake(f, fmt.str, va, false);
|
||||
} else {
|
||||
detail::is_locking<T...>() ? vprint_buffered(f, fmt.str, va)
|
||||
: vprint(f, fmt.str, va);
|
||||
}
|
||||
}
|
||||
|
||||
/// Formats `args` according to specifications in `fmt` and writes the output
|
||||
/// to the file `f` followed by a newline.
|
||||
template <typename... T>
|
||||
FMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {
|
||||
vargs<T...> va = {{args...}};
|
||||
if FMT_CONSTEXPR20 (detail::use_utf8) return vprintln(f, fmt.str, va);
|
||||
if FMT_CONSTEXPR20 (detail::use_utf8) {
|
||||
vprintln(f, fmt.str, va);
|
||||
} else {
|
||||
detail::vprint_mojibake(f, fmt.str, va, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Formats `args` according to specifications in `fmt` and writes the output
|
||||
/// to `stdout` followed by a newline.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user