-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #206
Labels
Comments
Let's keep it open before it arrives into the book |
I close this due to it took too much time. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
实在是抱歉,这一段时间因为需要准备秋招,所以我可能没时间弄 PR 了。今天看到这个项目想起来我 Range 做的笔记了,这里贴出来希望能对你有所帮助:
Ranges 本身内容比较少,所以确实也没什么可写的,主要特征应该是
数据不变
和管道符的使用吧。我本身的笔记是 rst 的,转成 md 后多出来了一部分换行这里是预览:
Range
Range 是 C++ 社区对
反应式编程 ()
的回应。最初由boost
社区实现, v3 版本 分离出来成为 C++ 20
标准库的基础。与其类似的还有 RxCpp
。Range 相当于 RxCpp 的数据处理部分。
反应式编程是基于
数据流 (Data Stream)
和变化传递 (Propagation of Change Value)
的声明式 编程方式。数据在传递过程中保持不变。原始数据通过通道符传递到一个一个 view 中,view
对数据进行处理之后又形成了新的数据,就这样,数据通过管道符在一个一个 view
中流动中发生变化,最终成品。
先看一个简单的 Demo 以对 Range 有初步的印象:
如代码所述,原始的数据 ints 在成品(形成
res)的过程中分别经过过滤(views::filter)、转换(views::transform)形成,最后由
for 将成品打印出来。ints 在这过程中始终保持不变。
概述
Range 库由头文件
<ranges>
提供,并带来一个命名空间 std::views 。 std::views 名为视图适配器 ,负责对数据的处理,常用的视图适配器如下:
这里是源码:
Range.md
The text was updated successfully, but these errors were encountered: