Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Aug 26, 2021
1 parent f889e52 commit b9ce56d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,8 @@ using long_type = conditional_t<long_short, int, long long>;
using ulong_type = conditional_t<long_short, unsigned, unsigned long long>;

// Maps formatting arguments to core types.
// arg_mapper reports errors by returning unformattable instead of using
// static_assert because it's used in the is_formattable trait.
template <typename Context> struct arg_mapper {
using char_type = typename Context::char_type;

Expand Down Expand Up @@ -1325,10 +1327,6 @@ template <typename Context> struct arg_mapper {
template <typename T>
FMT_CONSTEXPR auto map(T)
-> enable_if_t<std::is_pointer<T>::value, unformattable_pointer> {
// Formatting of arbitrary pointers is disallowed. If you want to output
// a pointer cast it to "void *" or "const void *". In particular, this
// forbids formatting of "[const] volatile char *" which is printed as bool
// by iostreams.
return {};
}

Expand Down Expand Up @@ -1593,10 +1591,14 @@ template <bool IS_PACKED, typename Context, type, typename T,
FMT_ENABLE_IF(IS_PACKED)>
FMT_CONSTEXPR FMT_INLINE auto make_arg(T&& val) -> value<Context> {
const auto& arg = arg_mapper<Context>().map(std::forward<T>(val));

// Formatting of arbitrary pointers is disallowed. If you want to output
// a pointer cast it to "void *" or "const void *". In particular, this
// forbids formatting of "[const] volatile char *" which is printed as bool
// by iostreams.
constexpr bool void_ptr =
!std::is_same<decltype(arg), const unformattable_pointer&>::value;
static_assert(void_ptr,
"Formatting of non-void pointers is disallowed.");
static_assert(void_ptr, "Formatting of non-void pointers is disallowed.");
constexpr bool formattable =
!std::is_same<decltype(arg), const unformattable&>::value;
static_assert(
Expand Down

0 comments on commit b9ce56d

Please sign in to comment.