refactor(tests): printable now checks if the type is std::formattable

This commit is contained in:
light7734 2025-09-18 19:32:11 +03:30
parent 794b52c10b
commit 249cecdb50
Signed by: light7734
GPG key ID: 8C30176798F1A6BA

View file

@ -7,9 +7,12 @@
namespace lt::test {
template<typename T>
concept Printable = requires(std::ostream &stream, T value) {
{ stream << value } -> std::same_as<std::ostream &>;
} || requires(std::ostream &stream, T value) {
concept Formattable = requires(T &v, std::format_context ctx) {
std::formatter<std::remove_cvref_t<T>>().format(v, ctx);
};
template<typename T>
concept Printable = Formattable<T> || requires(std::ostream &stream, T value) {
{ stream << std::to_underlying<T>(value) } -> std::same_as<std::ostream &>;
};