mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-27 04:39:44 +01:00
Remove dependency on back_insert_iterator
This commit is contained in:
@@ -263,12 +263,16 @@ FMT_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct iterator_traits<fmt::appender> {
|
||||
template <> struct iterator_traits<fmt::appender> {
|
||||
using value_type = void;
|
||||
using iterator_category = std::output_iterator_tag;
|
||||
using iterator_category = std::output_iterator_tag;
|
||||
};
|
||||
}
|
||||
template <typename Container>
|
||||
struct iterator_traits<fmt::back_insert_iterator<Container>> {
|
||||
using value_type = void;
|
||||
using iterator_category = std::output_iterator_tag;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace detail {
|
||||
@@ -500,6 +504,18 @@ FMT_INLINE void assume(bool condition) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Extracts a reference to the container from back_insert_iterator.
|
||||
template <typename Container>
|
||||
inline auto get_container(std::back_insert_iterator<Container> it)
|
||||
-> Container& {
|
||||
using base = std::back_insert_iterator<Container>;
|
||||
struct accessor : base {
|
||||
accessor(base b) : base(b) {}
|
||||
using base::container;
|
||||
};
|
||||
return *accessor(it).container;
|
||||
}
|
||||
|
||||
// An approximation of iterator_t for pre-C++20 systems.
|
||||
template <typename T>
|
||||
using iterator_t = decltype(std::begin(std::declval<T&>()));
|
||||
|
||||
Reference in New Issue
Block a user