Comments (6)
You're mistaken as to the purpose of as_range
. It's for promoting Iterables to Ranges. Most of these exist already, but the have their own dedicated API. Why do you think the should all be unified?
from range-v3.
You're mistaken as to the purpose of
as_range
. It's for promoting Iterables to Ranges.
I'll have to re-read your posts again!
Why do you think the should all be unified?
I just find that a ranges::make(...)
that does the right thing is more comfortable to use than particular functions like ranges::make_counting_range
, ranges::make_iterator_range
, ... although the implementation trouble might not be worth it since those above are the cases I have a use for but there might be more (way more maybe). I just build ranges from integers and pointers/iterators/raw arrays very often.
from range-v3.
I just find that a
ranges::make(...)
that does the right thing is more comfortable to use than particular functions likeranges::make_counting_range
If you mean a counted range that starts at some iterator and includes the next N elements, I call that ranges::view::counted
. If you mean, all the integers starting from N, that's called ranges::view::iota
.
ranges::make_iterator_range
I call that ranges::range
.
There are so many different kinds of ranges, I just can't imaging an interface that unifies construction of all of them. And I don't see why that would be a better interface than saying what you mean explicitly, and having the programmer's intent visible in the code.
from range-v3.
The "problem" (and feature) of iota
is that it is an "infinite" range. Most of the time I just want an integer range [a, b)
so I would really appreciate having an utility function for creating them:
/// Integer range [a, b)
auto irng(Integral a, Integral b) { return view::take(view::iota(a), b); }
/// Integer range [a, b) with stride
auto irng(Integral a, Integral b, Integral stride) { return view::take(view::iota(a), b) | view::strided(stride); }
/// Predicated integer range starting at a
auto irng(Integral a, Predicate p) { return view::iota(a) | view::take_while(p); }
For the iterator versions I didn't knew about counted
so the only case I'm missing is a "predicated" version of it. Any name suggestions for that one? If we had a way of creating an "infinite" range from a single iterator (the same way iota
does for integers) one could use that with take_while
to implement it.
from range-v3.
Agreed about iota
. I've also never loved the name, despite the historical precedent. This needs a rethink.
from range-v3.
Opened a separate ticket for just the iota issue. Closing this one.
from range-v3.
Related Issues (20)
- ranges::to eigen HOT 2
- C++23's range_adaptor_closure equivalent HOT 2
- Security disclosure policy
- Range-v3 fails to compile on the latest MSVC version with Visual Studio 2022 HOT 2
- CMAKE_CXX_STANDARD 20 and RANGES_CXX_STD 17 - does not work HOT 1
- pipe adaptor support for tuple_algorithm.hpp
- Nested `key_type` for lazy set algorithms formatting?
- UB in std::views::split HOT 7
- action::remove not included
- Error when using function return value directly HOT 1
- MSVC warning C4702: unreachable code with NDEBUG
- JVM / Python / OOP like group_by view
- operator = for ranges::views::concat result HOT 1
- Is there an approach to concat 2 vector? HOT 2
- ranges::views::chunk_by and std::views::chunk_by return different results HOT 1
- ranges::transform cannot be compiled with c++17
- With compiling with gcc >= 11.1 for C++20, constraint depending on itself when checking for member begin on constant ref_view around boost range
- Why isn't repeat_n a range adaptor?
- Implementation Request for ranges::views::pairwise and ranges::views::adjacent
- Make range-v3 a Bazel module (Support Bzlmod) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from range-v3.