29#include <boost/iterator/iterator_facade.hpp>
30#include <itertools/itertools.hpp>
35namespace triqs::utility {
38 template <
typename IteratorType,
typename Dressing,
typename DressingAuxiliaryArgumentPtrType =
void>
struct dressed_iterator;
42 template <
typename IteratorType>
43 constexpr bool is_bidir = std::is_same_v<typename IteratorType::iterator_category, std::bidirectional_iterator_tag>;
68 template <
typename IteratorType,
typename Dressing,
typename DressingAuxiliaryArgumentPtrType>
70 :
public boost::iterator_facade<
71 dressed_iterator<IteratorType, Dressing, DressingAuxiliaryArgumentPtrType>, Dressing,
72 std::conditional_t<detail::is_bidir<IteratorType>, boost::bidirectional_traversal_tag, boost::forward_traversal_tag>, Dressing> {
83 template <
typename T>
dressed_iterator(T
const &it, DressingAuxiliaryArgumentPtrType *aux) : _it(it), _aux(aux) {}
91 swap(it._it, this->_it);
92 swap(this->_aux, it._aux);
100 IteratorType
const &
get()
const {
return _it; }
106 IteratorType &
get() {
return _it; }
109 operator IteratorType()
const {
return _it; }
130 template <
typename OtherSentinel>
bool operator==(itertools::sentinel_t<OtherSentinel> other) {
return _it == other.it; }
135 friend class boost::iterator_core_access;
136 void increment() { ++_it; }
138 requires(detail::is_bidir<IteratorType>)
142 bool equal(
dressed_iterator const &other)
const {
return (other._it == _it); }
143 Dressing dereference()
const {
return Dressing(_it, _aux); }
147 DressingAuxiliaryArgumentPtrType *_aux;
156 template <
typename IteratorType,
typename Dressing>
158 :
public boost::iterator_facade<
159 dressed_iterator<IteratorType, Dressing>, Dressing,
160 std::conditional_t<detail::is_bidir<IteratorType>, boost::bidirectional_traversal_tag, boost::forward_traversal_tag>, Dressing> {
177 swap(it._it, this->_it);
185 IteratorType
const &
get()
const {
return _it; }
191 IteratorType &
get() {
return _it; }
194 operator IteratorType()
const {
return _it; }
203 template <
typename OtherSentinel>
bool operator==(itertools::sentinel_t<OtherSentinel> other) {
return _it == other.it; }
208 friend class boost::iterator_core_access;
209 void increment() { ++_it; }
211 requires(detail::is_bidir<IteratorType>)
215 bool equal(
dressed_iterator const &other)
const {
return (other._it == _it); }
216 Dressing dereference()
const {
return Dressing(_it); }
Compiler / platform glue and the dcomplex alias (must be included before any Boost header).
IteratorType const & get() const
Access the underlying iterator.
dressed_iterator(T const &it)
Construct a dressed iterator from an underlying iterator.
bool operator==(itertools::sentinel_t< OtherSentinel > other)
Equal-to operator to compare a itertools::sentinel_t type with a dressed iterator.
IteratorType & get()
Access the underlying iterator.
dressed_iterator()=default
Default constructor leaves the underlying iterator uninitialized.
STL-compatible iterator that wraps an underlying iterator and dereferences to a user-supplied dressin...
IteratorType & get()
Access the underlying iterator.
dressed_iterator(T const &it, DressingAuxiliaryArgumentPtrType *aux)
Construct a dressed iterator from an underlying iterator and an auxiliary pointer.
const auto * get_aux() const
Access the auxiliary pointer.
IteratorType const & get() const
Access the underlying iterator.
auto * get_aux()
Access the auxiliary pointer.
dressed_iterator()=default
Default constructor leaves the underlying iterator and auxiliary pointer uninitialized.
bool operator==(itertools::sentinel_t< OtherSentinel > other)
Equal-to operator to compare a itertools::sentinel_t type with a dressed iterator.