From aecec01b34aa3d1bb3fb991d4f75b0750508f9a0 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 22 Mar 2024 14:17:47 +0900 Subject: [PATCH] Initial support for extended FP types --- include/fmt/base.h | 12 +++++++----- include/fmt/format.h | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 6dedd4ec0387..b08d8267ff9f 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1505,12 +1505,14 @@ template struct arg_mapper { return {}; } + // is_fundamental is used to allow formatters for extended FP types. template , - FMT_ENABLE_IF((std::is_class::value || std::is_enum::value || - std::is_union::value) && - !has_to_string_view::value && !is_char::value && - !is_named_arg::value && - !std::is_arithmetic>::value)> + FMT_ENABLE_IF( + (std::is_class::value || std::is_enum::value || + std::is_union::value || std::is_fundamental::value) && + !has_to_string_view::value && !is_char::value && + !is_named_arg::value && !std::is_integral::value && + !std::is_arithmetic>::value)> FMT_MAP_API auto map(T& val) -> decltype(FMT_DECLTYPE_THIS do_map(val)) { return do_map(val); } diff --git a/include/fmt/format.h b/include/fmt/format.h index c68bf2fb41af..4b0babe80779 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3716,7 +3716,9 @@ FMT_CONSTEXPR auto write(OutputIt out, const T& value) -> enable_if_t< template > FMT_CONSTEXPR auto write(OutputIt out, const T& value) - -> enable_if_t::value == type::custom_type, + -> enable_if_t::value == + type::custom_type && + !std::is_fundamental::value, OutputIt> { auto formatter = typename Context::template formatter_type(); auto parse_ctx = typename Context::parse_context_type({});