From 08663e439fcfc0c29b9bd8298bf8a113b2ee269a Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Mon, 14 Aug 2023 19:18:29 +0300 Subject: [PATCH] Implement `atomic_flag` formatter Copy-pasta from @wangzw PR --- include/fmt/std.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/fmt/std.h b/include/fmt/std.h index 5cfe1d87..2d3faf05 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -448,5 +448,19 @@ struct formatter, Char, } }; +#if defined(__cpp_lib_atomic_flag_test) && __cpp_lib_atomic_flag_test >= 201907L +FMT_EXPORT +template +struct formatter::value>> + : formatter { + template + auto format(const std::atomic_flag& v, FormatContext& ctx) const + -> decltype(ctx.out()) { + return formatter::format(v.test(), ctx); + } +}; +#endif // defined(__cpp_lib_atomic_flag_test) && __cpp_lib_atomic_flag_test >= 201907L + FMT_END_NAMESPACE #endif // FMT_STD_H_