6#include "../util/TraitImpl.h"
15 template<
typename TChainInput,
typename TMapFn,
typename TItem>
16 class [[nodiscard(CXXITER_CHAINER_NODISCARD_WARNING)]] Map :
public IterApi<Map<TChainInput, TMapFn, TItem>> {
17 friend struct trait::Iterator<Map<TChainInput, TMapFn, TItem>>;
18 friend struct trait::DoubleEndedIterator<Map<TChainInput, TMapFn, TItem>>;
19 friend struct trait::ExactSizeIterator<Map<TChainInput, TMapFn, TItem>>;
24 constexpr Map(TChainInput&& input, TMapFn mapFn) : input(std::move(input)), mapFn(mapFn) {}
29 template<
typename TChainInput,
typename TMapFn,
typename TItem>
30 struct trait::Iterator<op::Map<TChainInput, TMapFn, TItem>> {
31 using ChainInputIterator = trait::Iterator<TChainInput>;
32 using InputItemOwned =
typename TChainInput::ItemOwned;
34 using Self = op::Map<TChainInput, TMapFn, TItem>;
37 static constexpr inline IterValue<Item> next(Self& self) {
38 auto item = ChainInputIterator::next(self.input);
39 return item.template map<Item, TMapFn&>(self.mapFn);
41 static constexpr inline SizeHint sizeHint(
const Self& self) {
return ChainInputIterator::sizeHint(self.input); }
42 static constexpr inline size_t advanceBy(Self& self,
size_t n) {
return util::advanceByPull(self, n); }
45 template<CXXIterDoubleEndedIterator TChainInput,
typename TMapFn,
typename TItem>
46 struct trait::DoubleEndedIterator<op::Map<TChainInput, TMapFn, TItem>> {
47 using ChainInputIterator = trait::DoubleEndedIterator<TChainInput>;
48 using InputItemOwned =
typename TChainInput::ItemOwned;
50 using Self = op::Map<TChainInput, TMapFn, TItem>;
53 static constexpr inline IterValue<Item> nextBack(Self& self) {
54 auto item = ChainInputIterator::nextBack(self.input);
55 return item.template map<Item, TMapFn&>(self.mapFn);
59 template<CXXIterExactSizeIterator TChainInput,
typename TMapFn,
typename TItem>
60 struct trait::ExactSizeIterator<op::Map<TChainInput, TMapFn, TItem>> {
61 static constexpr inline size_t size(
const op::Map<TChainInput, TMapFn, TItem>& self) {
return trait::ExactSizeIterator<TChainInput>::size(self.input); }