Simplify iterator detection

This commit is contained in:
Victor Zverovich 2024-07-13 11:11:47 -07:00
parent 3fe4641d3a
commit 1408f1824d

View File

@ -474,24 +474,23 @@ FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
return 0; return 0;
} }
namespace detect { namespace adl {
using namespace std; using namespace std;
template <typename Container>
auto invoke_back_inserter()
-> decltype(back_inserter(std::declval<Container&>()));
} // namespace adl
template <typename It, typename Enable = std::true_type> template <typename It, typename Enable = std::true_type>
struct is_back_insert_iterator : std::false_type {}; struct is_back_insert_iterator : std::false_type {};
template <typename It> template <typename It>
struct is_back_insert_iterator< struct is_back_insert_iterator<
It, It, bool_constant<std::is_same<
bool_constant<std::is_same< decltype(adl::invoke_back_inserter<typename It::container_type>()),
decltype(back_inserter(std::declval<typename It::container_type&>())),
It>::value>> : std::true_type {}; It>::value>> : std::true_type {};
} // namespace detect
using detect::is_back_insert_iterator;
// Extracts a reference to the container from *insert_iterator. // Extracts a reference to the container from *insert_iterator.
template <typename OutputIt> template <typename OutputIt>
inline auto get_container(OutputIt it) -> typename OutputIt::container_type& { inline auto get_container(OutputIt it) -> typename OutputIt::container_type& {
@ -1185,10 +1184,8 @@ template <typename T> class basic_appender {
using appender = basic_appender<char>; using appender = basic_appender<char>;
namespace detail { namespace detail {
namespace detect {
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> template <typename T, typename Enable = void>
struct locking : std::true_type {}; struct locking : std::true_type {};