Move FMT_USE_FLOAT and friends to fmt/format.h

This commit is contained in:
Victor Zverovich 2020-03-20 06:59:41 -07:00
parent d3e668418f
commit 2951169481
2 changed files with 17 additions and 17 deletions

View File

@ -284,7 +284,8 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
#ifndef FMT_ASSERT #ifndef FMT_ASSERT
# ifdef NDEBUG # ifdef NDEBUG
# define FMT_ASSERT(condition, message) // FMT_ASSERT is not empty to avoid -Werror=empty-body.
# define FMT_ASSERT(condition, message) ((void)0)
# else # else
# define FMT_ASSERT(condition, message) \ # define FMT_ASSERT(condition, message) \
((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \
@ -316,18 +317,6 @@ struct int128_t {};
struct uint128_t {}; struct uint128_t {};
#endif #endif
#ifndef FMT_USE_FLOAT
# define FMT_USE_FLOAT 1
#endif
#ifndef FMT_USE_DOUBLE
# define FMT_USE_DOUBLE 1
#endif
#ifndef FMT_USE_LONG_DOUBLE
# define FMT_USE_LONG_DOUBLE 1
#endif
// Casts a nonnegative integer to unsigned. // Casts a nonnegative integer to unsigned.
template <typename Int> template <typename Int>
FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) { FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {

View File

@ -138,6 +138,18 @@ FMT_END_NAMESPACE
# endif # endif
#endif #endif
#ifndef FMT_USE_FLOAT
# define FMT_USE_FLOAT 1
#endif
#ifndef FMT_USE_DOUBLE
# define FMT_USE_DOUBLE 1
#endif
#ifndef FMT_USE_LONG_DOUBLE
# define FMT_USE_LONG_DOUBLE 1
#endif
// __builtin_clz is broken in clang with Microsoft CodeGen: // __builtin_clz is broken in clang with Microsoft CodeGen:
// https://github.com/fmtlib/fmt/issues/519 // https://github.com/fmtlib/fmt/issues/519
#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER #if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER
@ -1893,11 +1905,10 @@ class arg_formatter_base {
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)> template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
iterator operator()(T value) { iterator operator()(T value) {
if (const_check(!is_supported_floating_point(value))) { if (const_check(is_supported_floating_point(value)))
writer_.write(value, specs_ ? *specs_ : format_specs());
else
FMT_ASSERT(false, "unsupported float argument type"); FMT_ASSERT(false, "unsupported float argument type");
return out();
}
writer_.write(value, specs_ ? *specs_ : format_specs());
return out(); return out();
} }