CXXIter 0.2
Loading...
Searching...
No Matches
Concepts.h
1#pragma once
2
3#include "../Traits.h"
4
5namespace CXXIter::concepts {
6
15 template<typename TContainer>
16 concept SourceContainer = requires(
17 TContainer& container,
18 const TContainer& constContainer,
19 typename trait::Source<TContainer>::IteratorState& iterState,
20 typename trait::Source<TContainer>::ConstIteratorState& constIterState,
21 size_t n
22 ) {
26 typename trait::Source<TContainer>::IteratorState;
27 typename trait::Source<TContainer>::ConstIteratorState;
28
29 {trait::Source<TContainer>::initIterator(container)} -> std::same_as<typename trait::Source<TContainer>::IteratorState>;
30 {trait::Source<TContainer>::initIterator(constContainer)} -> std::same_as<typename trait::Source<TContainer>::ConstIteratorState>;
31
32 {trait::Source<TContainer>::hasNext(container, iterState)} -> std::same_as<bool>;
33 {trait::Source<TContainer>::hasNext(constContainer, constIterState)} -> std::same_as<bool>;
34
35 {trait::Source<TContainer>::next(container, iterState)} -> std::same_as<typename trait::Source<TContainer>::ItemRef>;
36 {trait::Source<TContainer>::next(constContainer, constIterState)} -> std::same_as<typename trait::Source<TContainer>::ItemConstRef>;
37
38 {trait::Source<TContainer>::peekNext(container, iterState)} -> std::same_as<typename trait::Source<TContainer>::ItemRef>;
39 {trait::Source<TContainer>::peekNext(constContainer, constIterState)} -> std::same_as<typename trait::Source<TContainer>::ItemConstRef>;
40
41 {trait::Source<TContainer>::skipN(container, iterState, n)} -> std::same_as<size_t>;
42 {trait::Source<TContainer>::skipN(container, constIterState, n)} -> std::same_as<size_t>;
43 };
44
53 template<typename TContainer>
55 TContainer& container,
56 const TContainer& constContainer,
57 typename trait::Source<TContainer>::IteratorState& iterState,
58 typename trait::Source<TContainer>::ConstIteratorState& constIterState,
59 size_t n
60 ) {
61
62 {trait::Source<TContainer>::nextBack(container, iterState)} -> std::same_as<typename trait::Source<TContainer>::ItemRef>;
63 {trait::Source<TContainer>::nextBack(constContainer, constIterState)} -> std::same_as<typename trait::Source<TContainer>::ItemConstRef>;
64
65 {trait::Source<TContainer>::skipNBack(container, iterState, n)} -> std::same_as<size_t>;
66 {trait::Source<TContainer>::skipNBack(container, constIterState, n)} -> std::same_as<size_t>;
67 };
68
69}
Concept that checks whether the given TContainer supports double-ended iteration when using CXXIter's...
Definition: Concepts.h:54
Concept that checks whether the given TContainer is supported by CXXIter's standard source classes CX...
Definition: Concepts.h:16
static constexpr ItemRef next(TContainer &container, IteratorState &iter)
Return the next item in the iteration with the given iter state on the given container.
Definition: Traits.h:206
static constexpr ItemRef nextBack(TContainer &container, IteratorState &iter)
Return the next item from the back of the iteration with the given iter state on the given container.
Definition: Traits.h:274
typename TContainer::value_type Item
Type of the item TContainer holds and provides for the iterator.
Definition: Traits.h:125
static constexpr size_t skipNBack(const TContainer &container, IteratorState &iter, size_t n)
Skip the next n elements from the back of this iterator.
Definition: Traits.h:293
static constexpr ItemRef peekNext(TContainer &container, IteratorState &iter)
Return the next item in the iteration with the given iter state on the given container,...
Definition: Traits.h:224
static constexpr IteratorState initIterator(TContainer &container)
Return an initial IteratorState instance for iteration on the given container.
Definition: Traits.h:172
static constexpr bool hasNext(TContainer &container, IteratorState &iter)
Checks whether there is a next item in the iteration with the given iter state on the given container...
Definition: Traits.h:189
static constexpr size_t skipN(const TContainer &container, IteratorState &iter, size_t n)
Skip the next n elements from the container.
Definition: Traits.h:243
typename TContainer::reference ItemRef
Type of the item TContainer holds and provides for the iterator, in referenced form.
Definition: Traits.h:129
typename TContainer::const_reference ItemConstRef
Type of the item TContainer holds and provides for the iterator, in const referenced form.
Definition: Traits.h:133