mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Mark more formatters nonlocking
This commit is contained in:
@ -1185,20 +1185,6 @@ namespace detail {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_back_insert_iterator<basic_appender<T>> : std::true_type {};
|
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).
|
// An optimized version of std::copy with the output value type (T).
|
||||||
template <typename T, typename InputIt, typename OutputIt,
|
template <typename T, typename InputIt, typename OutputIt,
|
||||||
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
|
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
|
||||||
@ -2074,6 +2060,21 @@ using sign_t = sign::type;
|
|||||||
|
|
||||||
namespace detail {
|
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>
|
template <typename Char>
|
||||||
using unsigned_char = typename conditional_t<std::is_integral<Char>::value,
|
using unsigned_char = typename conditional_t<std::is_integral<Char>::value,
|
||||||
std::make_unsigned<Char>,
|
std::make_unsigned<Char>,
|
||||||
|
@ -92,6 +92,10 @@ TEST(string_view_test, compare) {
|
|||||||
check_op<std::greater_equal>();
|
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) {
|
TEST(base_test, is_output_iterator) {
|
||||||
EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));
|
EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));
|
||||||
EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));
|
EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));
|
||||||
|
Reference in New Issue
Block a user