diff --git a/include/fmt/format.h b/include/fmt/format.h index dfd5d78abce6c..e45a2087adc7c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -41,6 +41,7 @@ #include // std::uninitialized_copy #include // std::runtime_error #include // std::system_error +#include // std::vector::reference #ifdef __cpp_lib_bit_cast # include // std::bitcast @@ -4076,6 +4077,7 @@ FMT_FORMAT_AS(std::basic_string, basic_string_view); FMT_FORMAT_AS(std::nullptr_t, const void*); FMT_FORMAT_AS(detail::std_string_view, basic_string_view); FMT_FORMAT_AS(void*, const void*); +FMT_FORMAT_AS(std::vector::reference, bool); template struct formatter : formatter, Char> {}; diff --git a/test/format-test.cc b/test/format-test.cc index 52ac2cafeadee..483ab551f325f 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2257,3 +2257,8 @@ FMT_END_NAMESPACE TEST(format_test, formatter_nonconst_char) { EXPECT_EQ(fmt::format("{}", convertible_to_nonconst_cstring()), "bar"); } + +TEST(format_test, format_vector_bool_specialization) { + std::vector v = {true, false}; + EXPECT_EQ(fmt::format("{} {}", v[0], v[1]), "true false"); +} \ No newline at end of file