Skip to content

Commit

Permalink
Make is_formattable work with void
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 4, 2024
1 parent b4aea98 commit 3df47a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2810,8 +2810,11 @@ template <typename Char, typename... T> class fstring {
template <typename... T> using format_string = typename fstring<char, T...>::t;

template <typename T, typename Char = char>
using is_formattable = bool_constant<
!std::is_base_of<detail::unformattable, detail::mapped_t<T, Char>>::value>;
using is_formattable = bool_constant<!std::is_base_of<
detail::unformattable,
detail::mapped_t<
conditional_t<std::is_same<T, void>::value, detail::unformattable, T>,
Char>>::value>;

#ifdef __cpp_concepts
template <typename T, typename Char = char>
Expand Down
1 change: 1 addition & 0 deletions test/base-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ FMT_END_NAMESPACE
enum class unformattable_scoped_enum {};

TEST(base_test, is_formattable) {
EXPECT_FALSE(fmt::is_formattable<void>::value);
EXPECT_FALSE(fmt::is_formattable<wchar_t>::value);
#ifdef __cpp_char8_t
EXPECT_FALSE(fmt::is_formattable<char8_t>::value);
Expand Down

0 comments on commit 3df47a4

Please sign in to comment.