diff --git a/include/fmt/base.h b/include/fmt/base.h index af91a11a..e4cdd5ec 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1146,10 +1146,10 @@ template struct arg_mapper { FMT_MAP_API auto map(long double x) -> long double { return x; } template - FMT_MAP_API auto map(bitint) + static auto map(bitint) -> conditional_t; template - FMT_MAP_API auto map(ubitint) + static auto map(ubitint) -> conditional_t; FMT_MAP_API auto map(Char* x) -> const Char* { return x; } @@ -1228,9 +1228,7 @@ template struct arg_mapper { } template ::value)> - FMT_MAP_API auto map(const T& named_arg) -> decltype(map(named_arg.value)) { - return map(named_arg.value); - } + static auto map(const T& named_arg) -> decltype(map(named_arg.value)); FMT_MAP_API auto map(...) -> unformattable { return {}; } }; @@ -2187,12 +2185,18 @@ template class value { } FMT_INLINE value(const void* x FMT_BUILTIN) : pointer(x) {} + template ::value)> + value(const T& named_arg) : value(named_arg.value) {} + + template > + using mappable = + bool_constant::value && !is_named_arg::value>; + // We can't use mapped_t because of a bug in MSVC 2017. template < typename T, typename M = decltype(arg_mapper::map(std::declval())), - FMT_ENABLE_IF(!std::is_same::value && - !std::is_integral>::value)> + FMT_ENABLE_IF(!std::is_same::value && mappable::value)> FMT_CONSTEXPR20 FMT_INLINE value(T&& x) { *this = arg_mapper::map(x); } @@ -2200,8 +2204,7 @@ template class value { template < typename T, typename M = decltype(arg_mapper::map(std::declval())), - FMT_ENABLE_IF(std::is_same::value && - !std::is_integral>::value)> + FMT_ENABLE_IF(std::is_same::value&& mappable::value)> FMT_CONSTEXPR20 FMT_INLINE value(T&& x) { // Formatting of arbitrary pointers is disallowed. If you want to format a // pointer cast it to `void*` or `const void*`. In particular, this forbids