-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ranges::base #1179
base: master
Are you sure you want to change the base?
ranges::base #1179
Conversation
I'm not a fan of this functionality. I don't see enough of a need, and I never want to call |
The main motivation for this - algorithms:
The core part of this PR is only: ranges::base<Iterator>(iter); Everything else actually is auxiliary, and can be hided/removed. |
added example 3. |
This PR is now badly out of date. I never was able to convince myself that this problem justifies any solution, or that this solution is it. Do you still want this, @tower120? |
My last line of defense is " That's probably main use-case for Important property of projection is that it can't skip elements, nor change their order. While view can. using Pair =std::pair<int, int>;
std::vector<Pair> pairs;
auto iter1 = ranges::find(pairs | view::partition(256) | view::each_range(view::take(4)).base(pairs); You can't do that at all with projections, and you can't do that efficiently with predicates. And you definitely can't have that elegant solution with manual loop. N.B. auto each_range = [](auto view){
// view::forward_iter = view::iota(view.begin(), view.end()) kinda...
return view::forward_iter | view::transform([](auto&& rng){ return *rng | view; });
};
// view::partition = given a range and N value, return range of ranges:
// N 2
// In 1 2 3 4 5 6 7 8 9
// Out 12|34|56|78|9 I still think this is useful. But if you think it has too narrow application, close it. UPDATE 1. Example updated, I mistakenly used wrong view. |
Abstract
This PR introduces
ranges::base
standalone function. It provides machinery for retrieving iterator of desired type from iterator base() chains (base().base().base()....
).Motivation
You have to "guess" count of base() calls to the desired layer of iterator adaptor.
Usage with algorithms:
Interface
Principle of operation
Iterator/range
base()
called until it's type does not match required. On type comparison references removed, constness remains.WIP