15 template<
typename TChainInput,
typename TModifierFn>
16 requires std::is_object_v<typename trait::Iterator<TChainInput>::Item> || (!std::is_const_v<typename trait::Iterator<TChainInput>::Item>)
17 class [[nodiscard(CXXITER_CHAINER_NODISCARD_WARNING)]] InplaceModifier :
public IterApi<InplaceModifier<TChainInput, TModifierFn>> {
18 friend struct trait::Iterator<InplaceModifier<TChainInput, TModifierFn>>;
19 friend struct trait::DoubleEndedIterator<InplaceModifier<TChainInput, TModifierFn>>;
20 friend struct trait::ExactSizeIterator<InplaceModifier<TChainInput, TModifierFn>>;
22 using InputItem =
typename TChainInput::Item;
25 TModifierFn modifierFn;
27 constexpr InplaceModifier(TChainInput&& input, TModifierFn modifierFn) : input(std::move(input)), modifierFn(modifierFn) {}
32 template<
typename TChainInput,
typename TModifierFn>
33 struct trait::Iterator<op::InplaceModifier<TChainInput, TModifierFn>> {
34 using ChainInputIterator = trait::Iterator<TChainInput>;
36 using Self = op::InplaceModifier<TChainInput, TModifierFn>;
37 using Item =
typename ChainInputIterator::Item;
39 static constexpr inline IterValue<Item>
next(
Self& self) {
40 auto item = ChainInputIterator::next(self.input);
41 if(!item.has_value()) [[unlikely]] {
return {}; }
42 self.modifierFn(item.value());
45 static constexpr inline SizeHint
sizeHint(
const Self& self) {
return ChainInputIterator::sizeHint(self.input); }
46 static constexpr inline size_t advanceBy(
Self& self,
size_t n) {
return ChainInputIterator::advanceBy(self.input, n); }
49 template<CXXIterDoubleEndedIterator TChainInput,
typename TModifierFn>
50 struct trait::DoubleEndedIterator<op::InplaceModifier<TChainInput, TModifierFn>> {
51 using ChainInputIterator = trait::DoubleEndedIterator<TChainInput>;
53 using Self = op::InplaceModifier<TChainInput, TModifierFn>;
54 using Item =
typename ChainInputIterator::Item;
56 static constexpr inline IterValue<Item>
nextBack(Self& self) {
57 auto item = ChainInputIterator::nextBack(self.input);
58 if(!item.has_value()) [[unlikely]] {
return {}; }
59 self.modifierFn(item.value());
64 template<CXXIterExactSizeIterator TChainInput,
typename TItem>
65 struct trait::ExactSizeIterator<op::InplaceModifier<TChainInput, TItem>> {
static constexpr IterValue< typename Iterator< T >::Item > nextBack(Self &self)=delete
Pull the next last element from the iterator pipeline previous to this pipeline-element.
static constexpr size_t size(const typename trait::Iterator< T >::Self &self)=delete
Get the iterator's exact number of elements.
static constexpr IterValue< Item > next(Self &self)=delete
Pull one element from the iterator pipeline previous to this pipeline-element.
void Item
Item-Type. This is the type of elements that can be pulled from this pipeline-element.
trait::Iterator< T > Self
Self-Type. This is the type of the struct for which the trait::Iterator is being specialized.
static constexpr SizeHint sizeHint(const Self &self)=delete
Get the bounds on the remaining length of the iterator pipeline until this pipeline-element,...
static constexpr size_t advanceBy(Self &self, size_t n)=delete
Advance the iterator by n elements.