Mark more formatters nonlocking

This commit is contained in:
Victor Zverovich 2024-07-21 08:00:34 -07:00
parent 0c9fce2ffe
commit 3cc32fdc8b
2 changed files with 19 additions and 14 deletions

View File

@ -1185,20 +1185,6 @@ namespace detail {
template <typename T>
struct is_back_insert_iterator<basic_appender<T>> : std::true_type {};
template <typename T, typename Enable = void>
struct locking : std::true_type {};
template <typename T>
struct locking<T, void_t<typename formatter<remove_cvref_t<T>>::nonlocking>>
: std::false_type {};
template <typename T = int> FMT_CONSTEXPR inline auto is_locking() -> bool {
return locking<T>::value;
}
template <typename T1, typename T2, typename... Tail>
FMT_CONSTEXPR inline auto is_locking() -> bool {
return locking<T1>::value || is_locking<T2, Tail...>();
}
// An optimized version of std::copy with the output value type (T).
template <typename T, typename InputIt, typename OutputIt,
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
@ -2074,6 +2060,21 @@ using sign_t = sign::type;
namespace detail {
template <typename T, typename Enable = void>
struct locking : bool_constant<mapped_type_constant<T, format_context>::value ==
type::custom_type> {};
template <typename T>
struct locking<T, void_t<typename formatter<remove_cvref_t<T>>::nonlocking>>
: std::false_type {};
template <typename T = int> FMT_CONSTEXPR inline auto is_locking() -> bool {
return locking<T>::value;
}
template <typename T1, typename T2, typename... Tail>
FMT_CONSTEXPR inline auto is_locking() -> bool {
return locking<T1>::value || is_locking<T2, Tail...>();
}
template <typename Char>
using unsigned_char = typename conditional_t<std::is_integral<Char>::value,
std::make_unsigned<Char>,

View File

@ -92,6 +92,10 @@ TEST(string_view_test, compare) {
check_op<std::greater_equal>();
}
TEST(base_test, is_locking) {
EXPECT_FALSE(fmt::detail::is_locking<const char (&)[3]>());
}
TEST(base_test, is_output_iterator) {
EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));
EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));