* add test for byte formatting with `FMT_COMPILE`
* fix byte formatting with `FMT_COMPILE`, use `__cpp_lib_byte` macro
* use is not custom mapped type check
* workaround MSVC bug
Problem:
- gcc-8 gives the following error when compiling this function on all
standards:
test/std-format-test.cc: In member function 'constexpr auto std::formatter<S>::parse(std::format_parse_context&)':
test/std-format-test.cc:112:17: error: call to non-'constexpr' function 'int isdigit(int)'
if (!isdigit(c) || (++iter, get_char()) != '}')
~~~~~~~^~~
Solution:
- Write a `constexpr` version of `isdigit` for use in this function.
Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
Problem:
- gcc-10 is generating the following warning at all standards:
test/format-test.cc: In member function 'virtual void UtilTest_BitCast_Test::TestBody()':
test/format-test.cc:108:42: error: useless cast to type 'uint64_t' {aka 'long long unsigned int'} [-Werror=useless-cast]
108 | s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
| ^~~~~~~~~~~~~~~
- gcc-8 is generating the following warning at all standards:
test/format-test.cc: In member function 'virtual void UtilTest_BitCast_Test::TestBody()':
test/format-test.cc:108:56: error: useless cast to type 'uint64_t' {aka 'long long unsigned int'} [-Werror=useless-cast]
s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
^
Solution:
- Cast 0 to a 64 unsigned bit int and then invert.
Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
Problem:
- On Apple clang 11.0.3 (clang-1103.0.32.62), pedantic mode compilation
generates the following error:
test/std-format-test.cc:114:22: error: implicit conversion changes
signedness: 'int' to 'size_t' (aka 'unsigned long')
[-Werror,-Wsign-conversion]
width_arg_id = c - '0';
~ ~~^~~~~
Solution:
- Use a `to_unsigned` to make the conversion explicit. This is
guaranteed to be safe due to the check before the ASCII-to-int
conversion.