diff --git a/include/fmt/std.h b/include/fmt/std.h index a71a59db..62e091ce 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "format.h" #include "ostream.h" @@ -391,4 +392,12 @@ struct formatter< }; FMT_END_NAMESPACE +namespace std +{ +template ::reference>::value)> +inline auto format_as(T b) -> bool { + return static_cast(b); +} +} + #endif // FMT_STD_H_ diff --git a/test/std-test.cc b/test/std-test.cc index fda8e96b..643d93c6 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -221,3 +221,8 @@ TEST(std_test, exception) { } #endif } + +TEST(std_test, format_vector_bool_specialization) { + std::vector v = {true, false}; + EXPECT_EQ(fmt::format("{} {}", v[0], v[1]), "true false"); +}