test: define a more generic boost_test_print_type
fmt::is_formattable<T>::value is false, even if
* T is a container of U, and
* fmt::is_formattable<U>, and
* U can be formatted using fmt::formatter
so, we have to define a more generic boost_test_print_type()
for the all types supported by {fmt}. it will help us to ditch the
operator<< for vector and unordered_map in Seastar, and allow us
to use the fmt::formatter specialization of the element
types.
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -113,10 +113,16 @@ extern std::mutex boost_logger_mutex;
|
||||
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename T, typename Char = char>
|
||||
concept formattable = fmt::is_formattable<std::remove_reference_t<T>, Char>::value;
|
||||
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
requires fmt::is_formattable<T>::value
|
||||
template <::internal::formattable T>
|
||||
std::ostream& boost_test_print_type(std::ostream& os, const T& p) {
|
||||
fmt::print(os, "{}", p);
|
||||
return os;
|
||||
|
||||
Reference in New Issue
Block a user