Skip to content

Commit aecec01

Browse files
committed
Initial support for extended FP types
1 parent 5af8865 commit aecec01

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Diff for: include/fmt/base.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -1505,12 +1505,14 @@ template <typename Context> struct arg_mapper {
15051505
return {};
15061506
}
15071507

1508+
// is_fundamental is used to allow formatters for extended FP types.
15081509
template <typename T, typename U = remove_const_t<T>,
1509-
FMT_ENABLE_IF((std::is_class<U>::value || std::is_enum<U>::value ||
1510-
std::is_union<U>::value) &&
1511-
!has_to_string_view<U>::value && !is_char<U>::value &&
1512-
!is_named_arg<U>::value &&
1513-
!std::is_arithmetic<format_as_t<U>>::value)>
1510+
FMT_ENABLE_IF(
1511+
(std::is_class<U>::value || std::is_enum<U>::value ||
1512+
std::is_union<U>::value || std::is_fundamental<U>::value) &&
1513+
!has_to_string_view<U>::value && !is_char<U>::value &&
1514+
!is_named_arg<U>::value && !std::is_integral<U>::value &&
1515+
!std::is_arithmetic<format_as_t<U>>::value)>
15141516
FMT_MAP_API auto map(T& val) -> decltype(FMT_DECLTYPE_THIS do_map(val)) {
15151517
return do_map(val);
15161518
}

Diff for: include/fmt/format.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -3716,7 +3716,9 @@ FMT_CONSTEXPR auto write(OutputIt out, const T& value) -> enable_if_t<
37163716
template <typename Char, typename OutputIt, typename T,
37173717
typename Context = basic_format_context<OutputIt, Char>>
37183718
FMT_CONSTEXPR auto write(OutputIt out, const T& value)
3719-
-> enable_if_t<mapped_type_constant<T, Context>::value == type::custom_type,
3719+
-> enable_if_t<mapped_type_constant<T, Context>::value ==
3720+
type::custom_type &&
3721+
!std::is_fundamental<T>::value,
37203722
OutputIt> {
37213723
auto formatter = typename Context::template formatter_type<T>();
37223724
auto parse_ctx = typename Context::parse_context_type({});

0 commit comments

Comments
 (0)