_M_find_next(iterator_t<_Vp> __current)
{
__glibcxx_assert(_M_pred.has_value());
- auto __pred = [this]<typename _Tp>(_Tp&& __x, _Tp&& __y) {
- return !bool((*_M_pred)(std::forward<_Tp>(__x), std::forward<_Tp>(__y)));
+ auto __pred = [this]<typename _Tp, typename _Up>(_Tp&& __x, _Up&& __y) {
+ return !bool((*_M_pred)(std::forward<_Tp>(__x), std::forward<_Up>(__y)));
};
auto __it = ranges::adjacent_find(__current, ranges::end(_M_base), __pred);
return ranges::next(__it, 1, ranges::end(_M_base));
_M_find_prev(iterator_t<_Vp> __current) requires bidirectional_range<_Vp>
{
__glibcxx_assert(_M_pred.has_value());
- auto __pred = [this]<typename _Tp>(_Tp&& __x, _Tp&& __y) {
- return !bool((*_M_pred)(std::forward<_Tp>(__y), std::forward<_Tp>(__x)));
+ auto __pred = [this]<typename _Tp, typename _Up>(_Tp&& __x, _Up&& __y) {
+ return !bool((*_M_pred)(std::forward<_Up>(__y), std::forward<_Tp>(__x)));
};
auto __rbegin = std::make_reverse_iterator(__current);
auto __rend = std::make_reverse_iterator(ranges::begin(_M_base));
ranges::chunk_by_view<ranges::empty_view<int>, ranges::equal_to> r;
}
+constexpr bool
+test04()
+{
+ // PR libstdc++/108291
+ using namespace std::literals;
+ std::string_view s = "hello";
+ auto r = s | views::chunk_by(std::less{});
+ VERIFY( ranges::equal(r,
+ (std::string_view[]){"h"sv, "el"sv, "lo"sv},
+ ranges::equal) );
+ VERIFY( ranges::equal(r | views::reverse,
+ (std::string_view[]){"lo"sv, "el"sv, "h"sv},
+ ranges::equal) );
+
+ return true;
+}
+
+void
+test05()
+{
+ // PR libstdc++/109474
+ std::vector<bool> v = {true, false, true, true, false, false};
+ auto r = v | views::chunk_by(std::equal_to{});
+ VERIFY( ranges::equal(r,
+ (std::initializer_list<bool>[])
+ {{true}, {false}, {true, true}, {false, false}},
+ ranges::equal) );
+ VERIFY( ranges::equal(r | views::reverse,
+ (std::initializer_list<bool>[])
+ {{false, false}, {true, true}, {false}, {true}},
+ ranges::equal) );
+}
+
int
main()
{
static_assert(test01());
test02();
test03();
+ static_assert(test04());
+ test05();
}