Make is_formattable work with void

This commit is contained in:
Victor Zverovich 2024-09-04 07:33:56 -07:00
parent b4aea98b55
commit 3df47a4677
2 changed files with 6 additions and 2 deletions

View File

@ -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>

View File

@ -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);