Added format_as for std::vector<bool>::reference
This commit is contained in:
parent
8a4bec5cf5
commit
8cb0961fba
@ -15,6 +15,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "ostream.h"
|
#include "ostream.h"
|
||||||
@ -391,4 +392,12 @@ struct formatter<
|
|||||||
};
|
};
|
||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template <typename T, FMT_ENABLE_IF(std::is_same<T, std::vector<bool>::reference>::value)>
|
||||||
|
inline auto format_as(T b) -> bool {
|
||||||
|
return static_cast<bool>(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // FMT_STD_H_
|
#endif // FMT_STD_H_
|
||||||
|
|||||||
@ -221,3 +221,8 @@ TEST(std_test, exception) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(std_test, format_vector_bool_specialization) {
|
||||||
|
std::vector<bool> v = {true, false};
|
||||||
|
EXPECT_EQ(fmt::format("{} {}", v[0], v[1]), "true false");
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user