In the implementation of `std::views::take`, it uses `subrange<Iter>` as part of the return type. But in case of input iterator, `subrange<Iter>` can be ill-formed
Differential Revision: https://reviews.llvm.org/D133220
};
template <class _Iter, class _Sent, subrange_kind _Kind>
+ requires requires{typename subrange<_Iter>;}
struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
using type = subrange<_Iter>;
};
[[maybe_unused]] auto partial = std::views::take(X{});
}
+ // Test when `subrange<Iter>` is not well formed
+ {
+ int input[] = {1, 2, 3};
+ using Iter = cpp20_input_iterator<int*>;
+ using Sent = sentinel_wrapper<Iter>;
+ std::ranges::subrange r{Iter{input}, Sent{Iter{input + 3}}};
+ auto tv = std::views::take(std::move(r), 1);
+ auto it = tv.begin();
+ assert(*it == 1);
+ ++it;
+ assert(it == tv.end());
+ }
+
return true;
}