16 template<
typename TChainInput,
typename TItem>
17 requires std::is_object_v<TItem>
18 class [[nodiscard(CXXITER_CHAINER_NODISCARD_WARNING)]] Caster :
public IterApi<Caster<TChainInput, TItem>> {
19 friend struct trait::Iterator<Caster<TChainInput, TItem>>;
20 friend struct trait::DoubleEndedIterator<Caster<TChainInput, TItem>>;
21 friend struct trait::ExactSizeIterator<Caster<TChainInput, TItem>>;
25 constexpr Caster(TChainInput&& input) : input(std::move(input)) {}
30 template<
typename TChainInput,
typename TItem>
31 requires std::is_object_v<TItem>
32 struct trait::Iterator<op::Caster<TChainInput, TItem>> {
33 using ChainInputIterator = trait::Iterator<TChainInput>;
35 using Self = op::Caster<TChainInput, TItem>;
38 static constexpr inline IterValue<Item> next(Self& self) {
39 auto item = ChainInputIterator::next(self.input);
40 return item.template map<Item>([](
auto&& item) {
return static_cast<Item
>(item); });
42 static constexpr inline SizeHint sizeHint(
const Self& self) {
return ChainInputIterator::sizeHint(self.input); }
43 static constexpr inline size_t advanceBy(Self& self,
size_t n) {
return ChainInputIterator::advanceBy(self.input, n); }
46 template<CXXIterDoubleEndedIterator TChainInput,
typename TItem>
47 requires std::is_object_v<TItem>
48 struct trait::DoubleEndedIterator<op::Caster<TChainInput, TItem>> {
49 using ChainInputIterator = trait::DoubleEndedIterator<TChainInput>;
50 using Self = op::Caster<TChainInput, TItem>;
53 static constexpr inline IterValue<TItem> nextBack(Self& self) {
54 auto item = ChainInputIterator::nextBack(self.input);
55 return item.template map<Item>([](
auto&& item) {
return static_cast<Item
>(item); });
59 template<CXXIterExactSizeIterator TChainInput,
typename TItem>
60 struct trait::ExactSizeIterator<op::Caster<TChainInput, TItem>> {
61 static constexpr inline size_t size(
const op::Caster<TChainInput, TItem>& self) {
return trait::ExactSizeIterator<TChainInput>::size(self.input); }