mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-02 14:04:20 +00:00
fix iterator implementation
This commit is contained in:
parent
4c996bd47b
commit
7c706381d4
65 changed files with 494 additions and 313 deletions
|
@ -76,24 +76,6 @@ namespace sprout {
|
|||
sprout::swap(index_, other.index_);
|
||||
sprout::swap(size_, other.size_);
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator==(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return lhs.index_ == rhs.index_;
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator!=(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator<(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return lhs.index_ < rhs.index_;
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator>(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return rhs < lhs;
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator<=(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator>=(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
SPROUT_CONSTEXPR reference operator*() const {
|
||||
return sprout::detail::dft_element_impl(first_, last_, index_, size_);
|
||||
}
|
||||
|
@ -136,14 +118,49 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
|
||||
return sprout::detail::dft_element_impl(first_, last_, index_ + n, size_);
|
||||
}
|
||||
friend SPROUT_CONSTEXPR difference_type operator-(dft_iterator const& lhs, dft_iterator const& rhs) {
|
||||
return lhs.index_ - rhs.index_;
|
||||
}
|
||||
friend SPROUT_CONSTEXPR dft_iterator operator+(difference_type n, dft_iterator const& it) {
|
||||
return it + n;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator==(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return lhs.index() == rhs.index();
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator!=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator<(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return lhs.index_ < rhs.index_;
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator>(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return rhs < lhs;
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator<=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator>=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::dft_iterator<Iterator>::difference_type
|
||||
operator-(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
|
||||
return lhs.index() - rhs.index();
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR sprout::dft_iterator<Iterator>
|
||||
operator+(typename sprout::dft_iterator<Iterator>::difference_type n, sprout::dft_iterator<Iterator> const& it) {
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// make_dft_iterator
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue