From 3cc32fdc8b01fd54fd415d8a76931bfdcc232b52 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 21 Jul 2024 08:00:34 -0700 Subject: [PATCH] Mark more formatters nonlocking --- include/fmt/base.h | 29 +++++++++++++++-------------- test/base-test.cc | 4 ++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 6276494253dd..9336cd3fc0f9 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1185,20 +1185,6 @@ namespace detail { template struct is_back_insert_iterator> : std::true_type {}; -template -struct locking : std::true_type {}; -template -struct locking>::nonlocking>> - : std::false_type {}; - -template FMT_CONSTEXPR inline auto is_locking() -> bool { - return locking::value; -} -template -FMT_CONSTEXPR inline auto is_locking() -> bool { - return locking::value || is_locking(); -} - // An optimized version of std::copy with the output value type (T). template ::value)> @@ -2074,6 +2060,21 @@ using sign_t = sign::type; namespace detail { +template +struct locking : bool_constant::value == + type::custom_type> {}; +template +struct locking>::nonlocking>> + : std::false_type {}; + +template FMT_CONSTEXPR inline auto is_locking() -> bool { + return locking::value; +} +template +FMT_CONSTEXPR inline auto is_locking() -> bool { + return locking::value || is_locking(); +} + template using unsigned_char = typename conditional_t::value, std::make_unsigned, diff --git a/test/base-test.cc b/test/base-test.cc index 765700368628..4e2164a4517c 100644 --- a/test/base-test.cc +++ b/test/base-test.cc @@ -92,6 +92,10 @@ TEST(string_view_test, compare) { check_op(); } +TEST(base_test, is_locking) { + EXPECT_FALSE(fmt::detail::is_locking()); +} + TEST(base_test, is_output_iterator) { EXPECT_TRUE((fmt::detail::is_output_iterator::value)); EXPECT_FALSE((fmt::detail::is_output_iterator::value));