Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4 batched.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ class iter::impl::Batcher {
&& (done() || !(sub_iter_ != other.sub_iter_));
}

DerefVec<ContainerT>& operator*() {
DerefVec<ContainerT>& operator*() const {
return *batch_;
}

DerefVec<ContainerT>* operator->() {
DerefVec<ContainerT>* operator->() const {
return batch_.get();
}
};
Expand Down
26 changes: 13 additions & 13 deletions 26 chain.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef ITER_CHAIN_HPP_
#define ITER_CHAIN_HPP_

#include "internal/iter_tuples.hpp"
#include "internal/iterator_wrapper.hpp"
#include "internal/iterbase.hpp"

#include <array>
#include <iterator>
#include <optional>
#include <tuple>
#include <type_traits>
#include <utility>

#include "internal/iter_tuples.hpp"
#include "internal/iterator_wrapper.hpp"
#include "internal/iterbase.hpp"

namespace iter {
namespace impl {
template <typename TupType, std::size_t... Is>
Expand Down Expand Up @@ -62,12 +62,12 @@ class iter::impl::Chained {
using ArrowType = iterator_arrow<std::tuple_element_t<0, TupTypeT>>;

template <std::size_t Idx>
static DerefType get_and_deref(IterTupType& iters) {
static DerefType get_and_deref(const IterTupType& iters) {
return *std::get<Idx>(iters);
}

template <std::size_t Idx>
static ArrowType get_and_arrow(IterTupType& iters) {
static ArrowType get_and_arrow(const IterTupType& iters) {
return apply_arrow(std::get<Idx>(iters));
}

Expand All @@ -82,8 +82,8 @@ class iter::impl::Chained {
return std::get<Idx>(lhs) != std::get<Idx>(rhs);
}

using DerefFunc = DerefType (*)(IterTupType&);
using ArrowFunc = ArrowType (*)(IterTupType&);
using DerefFunc = DerefType (*)(const IterTupType&);
using ArrowFunc = ArrowType (*)(const IterTupType&);
using IncFunc = void (*)(IterTupType&);
using NeqFunc = bool (*)(const IterTupType&, const IterTupType&);

Expand Down Expand Up @@ -137,11 +137,11 @@ class iter::impl::Chained {
check_for_end_and_adjust();
}

decltype(auto) operator*() {
decltype(auto) operator*() const {
return IterData::derefers[index_](iters_);
}

decltype(auto) operator-> () {
decltype(auto) operator->() const {
return IterData::arrowers[index_](iters_);
}

Expand All @@ -161,7 +161,7 @@ class iter::impl::Chained {
bool operator!=(const Iterator& other) const {
return index_ != other.index_
|| (index_ != sizeof...(Is)
&& IterData::neq_comparers[index_](iters_, other.iters_));
&& IterData::neq_comparers[index_](iters_, other.iters_));
}

bool operator==(const Iterator& other) const {
Expand Down Expand Up @@ -278,11 +278,11 @@ class iter::impl::ChainedFromIterable {
return !(*this != other);
}

iterator_deref<iterator_deref<ContainerT>> operator*() {
iterator_deref<iterator_deref<ContainerT>> operator*() const {
return **sub_iter_p_;
}

iterator_arrow<iterator_deref<ContainerT>> operator->() {
iterator_arrow<iterator_deref<ContainerT>> operator->() const {
return apply_arrow(*sub_iter_p_);
}
};
Expand Down
4 changes: 2 additions & 2 deletions 4 chunked.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class iter::impl::Chunker {
&& (done() || !(sub_iter_ != other.sub_iter_));
}

DerefVec<ContainerT>& operator*() {
DerefVec<ContainerT>& operator*() const {
return *chunk_;
}

DerefVec<ContainerT>* operator->() {
DerefVec<ContainerT>* operator->() const {
return chunk_.get();
}
};
Expand Down
6 changes: 3 additions & 3 deletions 6 combinations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class iter::impl::Combinator {
friend class Iterator;
constexpr static const int COMPLETE = -1;
std::remove_reference_t<ContainerT>* container_p_;
CombIteratorDeref<ContainerT> indices_;
mutable CombIteratorDeref<ContainerT> indices_;
int steps_{};

public:
Expand Down Expand Up @@ -73,11 +73,11 @@ class iter::impl::Combinator {
}
}

CombIteratorDeref<ContainerT>& operator*() {
CombIteratorDeref<ContainerT>& operator*() const {
return indices_;
}

CombIteratorDeref<ContainerT>* operator->() {
CombIteratorDeref<ContainerT>* operator->() const {
return &indices_;
}

Expand Down
6 changes: 3 additions & 3 deletions 6 combinations_with_replacement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class iter::impl::CombinatorWithReplacement {
friend class Iterator;
constexpr static const int COMPLETE = -1;
std::remove_reference_t<ContainerT>* container_p_;
CombIteratorDeref<ContainerT> indices_;
mutable CombIteratorDeref<ContainerT> indices_;
int steps_;

public:
Expand All @@ -60,11 +60,11 @@ class iter::impl::CombinatorWithReplacement {
? 0
: COMPLETE} {}

CombIteratorDeref<ContainerT>& operator*() {
CombIteratorDeref<ContainerT>& operator*() const {
return indices_;
}

CombIteratorDeref<ContainerT>* operator->() {
CombIteratorDeref<ContainerT>* operator->() const {
return &indices_;
}

Expand Down
4 changes: 2 additions & 2 deletions 4 compress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ class iter::impl::Compressed {
skip_failures();
}

iterator_deref<ContainerT> operator*() {
iterator_deref<ContainerT> operator*() const {
return *sub_iter_;
}

iterator_arrow<ContainerT> operator->() {
iterator_arrow<ContainerT> operator->() const {
return apply_arrow(sub_iter_);
}

Expand Down
4 changes: 2 additions & 2 deletions 4 cycle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ class iter::impl::Cycler {
sub_begin_{sub_iter},
sub_end_{std::move(sub_end)} {}

iterator_deref<ContainerT> operator*() {
iterator_deref<ContainerT> operator*() const {
return *sub_iter_;
}

iterator_arrow<ContainerT> operator->() {
iterator_arrow<ContainerT> operator->() const {
return apply_arrow(sub_iter_);
}

Expand Down
4 changes: 2 additions & 2 deletions 4 dropwhile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class iter::impl::Dropper {
sub_end_{std::move(sub_end)},
filter_func_(&filter_func) {}

typename Holder::reference operator*() {
typename Holder::reference operator*() const {
init_if_first_use();
return item_.get();
}

typename Holder::pointer operator->() {
typename Holder::pointer operator->() const {
init_if_first_use();
return item_.get_ptr();
}
Expand Down
4 changes: 2 additions & 2 deletions 4 enumerate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class iter::impl::Enumerable {
Iterator(IteratorWrapper<ContainerT>&& sub_iter, Index start)
: sub_iter_{std::move(sub_iter)}, index_{start} {}

IterYield<ContainerT> operator*() {
IterYield<ContainerT> operator*() const {
return {index_, *sub_iter_};
}

ArrowProxy<IterYield<ContainerT>> operator->() {
ArrowProxy<IterYield<ContainerT>> operator->() const {
return {**this};
}

Expand Down
4 changes: 2 additions & 2 deletions 4 filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class iter::impl::Filtered {
sub_end_{std::move(sub_end)},
filter_func_(&filter_func) {}

typename Holder::reference operator*() {
typename Holder::reference operator*() const {
init_if_first_use();
return item_.get();
}

typename Holder::pointer operator->() {
typename Holder::pointer operator->() const {
init_if_first_use();
return item_.get_ptr();
}
Expand Down
21 changes: 12 additions & 9 deletions 21 groupby.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class iter::impl::GroupProducer {
IteratorWrapper<ContainerT> sub_end_;
Holder<ContainerT> item_;
KeyFunc* key_func_;
std::optional<KeyGroupPair<ContainerT>> current_key_group_pair_;
mutable std::optional<KeyGroupPair<ContainerT>> current_key_group_pair_;

public:
using iterator_category = std::input_iterator_tag;
Expand All @@ -77,14 +77,17 @@ class iter::impl::GroupProducer {
key_func_(&key_func) {
if (sub_iter_ != sub_end_) {
item_.reset(*sub_iter_);
set_key_group_pair();
}
}

Iterator(const Iterator& other)
: sub_iter_{other.sub_iter_},
sub_end_{other.sub_end_},
item_{other.item_},
key_func_{other.key_func_} {}
key_func_{other.key_func_} {
set_key_group_pair();
}

Iterator& operator=(const Iterator& other) {
if (this == &other) {
Expand All @@ -95,6 +98,7 @@ class iter::impl::GroupProducer {
item_ = other.item_;
key_func_ = other.key_func_;
current_key_group_pair_.reset();
set_key_group_pair();
return *this;
}

Expand All @@ -103,13 +107,11 @@ class iter::impl::GroupProducer {
// NOTE the implicitly generated move constructor would
// be wrong

KeyGroupPair<ContainerT>& operator*() {
set_key_group_pair();
KeyGroupPair<ContainerT>& operator*() const {
return *current_key_group_pair_;
}

KeyGroupPair<ContainerT>* operator->() {
set_key_group_pair();
KeyGroupPair<ContainerT>* operator->() const {
return &*current_key_group_pair_;
}

Expand All @@ -118,6 +120,7 @@ class iter::impl::GroupProducer {
set_key_group_pair();
}
current_key_group_pair_.reset();
set_key_group_pair();
return *this;
}

Expand Down Expand Up @@ -163,7 +166,7 @@ class iter::impl::GroupProducer {
}

void set_key_group_pair() {
if (!current_key_group_pair_) {
if (!current_key_group_pair_ && item_) {
current_key_group_pair_.emplace(std::invoke(*key_func_, item_.get()),
Group<ContainerT>{*this, next_key()});
}
Expand Down Expand Up @@ -251,11 +254,11 @@ class iter::impl::GroupProducer {
return ret;
}

iterator_deref<ContainerT> operator*() {
iterator_deref<ContainerT> operator*() const {
return group_p_->owner_.get();
}

typename Holder<ContainerT>::pointer operator->() {
typename Holder<ContainerT>::pointer operator->() const {
return group_p_->owner_.get_ptr();
}
};
Expand Down
1 change: 1 addition & 0 deletions 1 internal/iterator_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cassert>
#include <functional>
#include <variant>

#include "iterbase.hpp"

namespace iter {
Expand Down
6 changes: 3 additions & 3 deletions 6 internal/iterbase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ namespace iter {
};

template <typename T>
struct ArrowHelper<T*, void> {
using type = T*;
constexpr type operator()(T* t) const noexcept {
struct ArrowHelper<T, std::enable_if_t<std::is_pointer_v<T>>> {
using type = T;
constexpr type operator()(T t) const noexcept {
return t;
}
};
Expand Down
6 changes: 3 additions & 3 deletions 6 permutations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class iter::impl::Permuter {
return *lhs < *rhs;
}

Permutable<ContainerT> working_set_;
mutable Permutable<ContainerT> working_set_;
int steps_{};

public:
Expand All @@ -72,11 +72,11 @@ class iter::impl::Permuter {
cmp_iters);
}

Permutable<ContainerT>& operator*() {
Permutable<ContainerT>& operator*() const {
return working_set_;
}

Permutable<ContainerT>* operator->() {
Permutable<ContainerT>* operator->() const {
return &working_set_;
}

Expand Down
4 changes: 2 additions & 2 deletions 4 powerset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class iter::impl::Powersetter {
return ret;
}

iterator_deref<CombinatorType<ContainerT>> operator*() {
iterator_deref<CombinatorType<ContainerT>> operator*() const {
return *comb_iter_;
}

iterator_arrow<CombinatorType<ContainerT>> operator->() {
iterator_arrow<CombinatorType<ContainerT>> operator->() const {
apply_arrow(comb_iter_);
}

Expand Down
4 changes: 2 additions & 2 deletions 4 product.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ class iter::impl::Productor {
return !(*this != other);
}

TupleDeref<TupleTypeT> operator*() {
TupleDeref<TupleTypeT> operator*() const {
return {(*std::get<Is>(iters_))...};
}

auto operator->() -> ArrowProxy<decltype(**this)> {
auto operator->() const -> ArrowProxy<decltype(**this)> {
return {**this};
}
};
Expand Down
4 changes: 2 additions & 2 deletions 4 reversed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class iter::impl::Reverser {
Iterator(ReverseIteratorWrapper<ContainerT>&& sub_iter)
: sub_iter_{std::move(sub_iter)} {}

reverse_iterator_deref<ContainerT> operator*() {
reverse_iterator_deref<ContainerT> operator*() const {
return *sub_iter_;
}

reverse_iterator_arrow<ContainerT> operator->() {
reverse_iterator_arrow<ContainerT> operator->() const {
return apply_arrow(sub_iter_);
}

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.