Re:C++20 Ranges
by mikeloomis on Saturday December 22, 2018 @05:07PM
(#18742735)
A c++20 range is just a bounded container. instead of having to write, `(container.begin(), container.end())` for any function that uses iterators to bound itself, you just write `(container)` and it knows its a range.
The range function in python is similar only in name, the c++20 range concept is not a generator.
2. There is a coroutine feature branch, I believe developed by Gor Nishanov, https://github.com/GorNishanov. Also not related to c++20 ranges.
3. Eric Niebler used a single templated function. This is not anywhere close to template metaprogramming hell, and I think you should look into templates as once you learn about them they become way less intimidating. Also has nothing to do with c++20 ranges.
I have yet to see a non-managed systems programming language which supports coroutines properly.
Rust supports async/await, but it's not the same thing, as this comment illustrates:
Re:C++20 Ranges
by mikeloomis on Saturday December 22, 2018 @11:32PM
(#18744441)
It'll be after 20 for sure, we're still waiting for the executor TS for async networking to be able to come in.
The "for_each" (aka flatmap, or bind, or =<<), "maybe_view", and "yield_if" are basically a DSL for writing (admittedly ugly) lazy list comprehensions (generator expressions in Python or for comprehensions in Scala) in C++ without special language support for them. You're not supposed to have to implement these sorts of building blocks yourself, but they're not voted into the standard either at this point.
Re:C++20 Ranges
by mattnewport on Saturday December 22, 2018 @08:31PM
(#18743766)
Unlike Python, this compiles to pretty optimally efficient code.
Also the example has a lot of boilerplate code that reminds me of template metaprogramming hell. Is this something that's expected to be wrapped up nicely by Boost & co. for end users?