Skip to content

Commit

Permalink
Simplify iterator detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 13, 2024
1 parent 3fe4641 commit 1408f18
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,22 @@ FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
return 0;
}

namespace detect {

namespace adl {
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>
struct is_back_insert_iterator : std::false_type {};

template <typename It>
struct is_back_insert_iterator<
It,
bool_constant<std::is_same<
decltype(back_inserter(std::declval<typename It::container_type&>())),
It>::value>> : std::true_type {};

} // namespace detect

using detect::is_back_insert_iterator;
It, bool_constant<std::is_same<
decltype(adl::invoke_back_inserter<typename It::container_type>()),
It>::value>> : std::true_type {};

// Extracts a reference to the container from *insert_iterator.
template <typename OutputIt>
Expand Down Expand Up @@ -1185,10 +1184,8 @@ template <typename T> class basic_appender {
using appender = basic_appender<char>;

namespace detail {
namespace detect {
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 {};
Expand Down

0 comments on commit 1408f18

Please sign in to comment.