C++20 STL Features: 1 Year of Development on GitHubSeptember 15, 2020 1 C++20 STL Features: 1 Year of Development on GitHub Stephan T. Lavavej "Steh-fin Lah-wah-wade" Principal Software Engineer, Visual C++ Libraries stl@microsoft.com @StephanTLavavej2 Write down the slide numbers • Part 0: Overview • What's happened in the last year • Part 1: C++20 STL Features • Everything here is Standard, except as noted • Part 2: GitHub Development • For contributors Overview Part 04 CppCon 2019 CppCon 2020 • Announced at CppCon 2019 • github.com/microsoft/STL • Apache License v2.0 with LLVM Exception • Implemented ~50 C++20 features • Majority from our amazing0 码力 | 45 页 | 702.09 KB | 6 月前3
C++高性能并行编程与优化 - 课件 - 13 C++ STL 容器全解之 vectorC++ STL 容器全解之 vector by 彭于斌( @archibate ) 往期录播: https://www.bilibili.com/video/BV1fa411r7zp 课程 PPT 和代码: https://github.com/parallel101/course C++ 标准库五大件:容器( container ) C++ 标准库五大件:迭代器( iterator iterator ) C++ 标准库五大件:算法( algorithm ) C++ 标准库五大件:仿函数( functor ) C++ 标准库五大件:分配器( allocator ) 侯捷 STL 侯捷 STL vector 容器 vector 容器:构造函数 • vector 的功能是长度可变的数组,他里面的数据 存储在堆上。 • vector 是一个模板类,第一个模板参数是数组里 元素的类型。 对应到 链表的 curr = curr->next 上。 • 这样一个用起来就像普通的指针,但内部却通 过运算符重载适配不同容器的特殊类,就是迭 代器 (iterator) ,迭代器是 STL 中容器和算法 之间的桥梁。 迭代器模式:首迭代器+尾迭代器 • 如果让小彭老师来写 list 容器和他的迭代器,他的 内部具体实现可能是这样的。 • 迭代器的这些运算符,都是约定俗成的,其根本目0 码力 | 90 页 | 4.93 MB | 1 年前3
C++20's VI: Conclusion7 Part I: Development Process8 Development Process • Implemented in our microsoft/STL open-source GitHub repo with the help of our amazing contributors! • In particular, thanks to customers if their MSVC STL grew by such a large amount. PLUS, how would we handle updates to the data? • Try to figure out some networking scenario to pull in the data when needed The STL currently does not customers if their MSVC STL grew by such a large amount. PLUS, how would we handle updates to the data? • Try to figure out some networking scenario to pull in the data when needed The STL currently does not0 码力 | 55 页 | 8.67 MB | 6 月前3
C++高性能并行编程与优化 - 课件 - 14 C++ 标准库系列课 - 你所不知道的 set 容器string_view , const char * 的爱恨纠葛 4. 万能的 map 容器全家桶及其妙用举例 5. 函子 functor 与 lambda 表达式知多少 6. 通过实战案例来学习 STL 算法库 7. C++ 标准输入输出流 & 字符串格式化 8. traits 技术,用户自定义迭代器与算法 9. allocator ,内存管理与对象生命周期 set 和 vector 的区别 • https://www.cplusplus.com/reference/iterator/istream_iterator 包含关系:前向迭代器>双向迭代器>随机访问迭代器 这意味着如果一个 STL 模板函数(比如 std::find )要求迭代器是前向迭代器即可,那么也可 以给他随机访问迭代器,因为前向迭代器是随机访问迭代器的子集。 例如, vector 和 list 都可以调用 std::find com/w/cpp/iterator/distance 学有余力的同学可以看一下 glibc 源码 学有余力的同学可以看一下 glibc 源码 学有余力的同学可以看一下 glibc 源码 顺便一提:小彭老师打印任意 STL 容器的黑科技 向 set 中插入元素 • 可以通过调用 insert 往 set 中添加一个元素。 • 用户无需关心插入的位置, 例如插入元素 3 时, set 会 自动插入到 2 和0 码力 | 83 页 | 10.23 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 02 现代 C++ 入门:RAII 内存管理- 课程大纲 • 分为前半段和后半段,前半段主要介绍现代 C++ ,后半段主要介绍并行编程与优化。 1.课程安排与开发环境搭建: cmake 与 git 入门 2.现代 C++ 入门:常用 STL 容器, RAII 内存管理 3.现代 C++ 进阶:模板元编程与函数式编程 4.编译器如何自动优化:从汇编角度看 C++ 5.C++11 起的多线程编程:从 mutex 到无锁并行 6.并行编程常用框架: 官方文档 ](https://git-scm.com/doc) - [GitHub 官方文档 ](https://docs.github.com/en) 古代: C 语言 近代: C++98 引入 STL 容器库 近现代: C++11 引入了 {} 初始化表达式 近现代: C++11 引入了 range-based for-loop 如果想使用 for_each 这个算法模板呢? 我知道可以用 int id; // 基础类型 • std::vectorarr; // STL 容器 • std::shared_ptr 0 码力 | 96 页 | 16.28 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串的爱恨纠葛 ( 本期 ) 4. 万能的 map 容器全家桶及其妙用举例 5. 函子 functor 与 lambda 表达式知多少 6. 通过实战案例来学习 STL 算法库 7. C++ 标准输入输出流 & 字符串格式化 8. traits 技术,用户自定义迭代器与算法 9. allocator ,内存管理与对象生命周期 ASCII 码 第 1 章 std::format 4. 第三方库提供的 fmt::format ( https://github.com/fmtlib/fmt ) 5. 参考小彭老师在 zeno 里手撸的两个函数(能支持任意 STL 容器的打印) : • https://github.com/zenustech/zeno/blob/master/zeno/include/zeno/utils/to_string.h • https://github ),为什么还要把 allocator 对 象存到 string 对象里,最后还要搞什么空基类优化防止他浪费空间,多此一举? • 因为最近开始流行“有状态分配器”了,侯杰老师显然不知道这一点,在他的 STL 课 里,讲到这部分源码时,还吐槽“为什么多此一举”,幸好小彭老师看出了这一点。 有无空基类优化的对比 _M_dataplus._M_p _M_dataplus 的基类 allocator _M_string_length0 码力 | 162 页 | 40.20 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 01 学 C++ 从 CMake 学起- 课程大纲 • 分为前半段和后半段,前半段主要介绍现代 C++ ,后半段主要介绍并行编程与优化。 1.课程安排与开发环境搭建: cmake 与 git 入门 2.现代 C++ 入门:常用 STL 容器, RAII 内存管理 3.现代 C++ 进阶:模板元编程与函数式编程 4.编译器如何自动优化:从汇编角度看 C++ 5.C++11 起的多线程编程:从 mutex 到无锁并行 6.并行编程常用框架: 3. g-truc/glm - 模仿 GLSL 语法的数学矢量 / 矩阵库(附带一些常用函数,随机数生成等) 4. Tencent/rapidjson - 单纯的 JSON 库,甚至没依赖 STL (可定制性高,工程美学经典) 5. ericniebler/range-v3 - C++20 ranges 库就是受到他启发(完全是头文件组成) 6. fmtlib/fmt - 格式化库,提供0 码力 | 32 页 | 11.40 MB | 1 年前3
C++20: An (Almost) Complete Overviewand std::vector are now constexpr Needed to support constexpr reflection in the future “C++20 STL Features: One Year of Development on GitHub” -- Stephan T. Lavavej Tuesday, September 15 • 13:30Concurrency last count elements subspan(offset, count): returns a subspan [offset, offset+count) “C++20 STL Features: One Year of Development on GitHub” -- Stephan T. Lavavej Tuesday, September 15 • 13:30680 码力 | 85 页 | 512.18 KB | 6 月前3
C++高性能并行编程与优化 - 课件 - 04 从汇编角度看编译器优化- 课程大纲 • 分为前半段和后半段,前半段主要介绍现代 C++ ,后半段主要介绍并行编程与优化。 1.课程安排与开发环境搭建: cmake 与 git 入门 2.现代 C++ 入门:常用 STL 容器, RAII 内存管理 3.现代 C++ 进阶:模板元编程与函数式编程 4.编译器如何自动优化:从汇编角度看 C++ 5.C++11 起的多线程编程:从 mutex 到无锁并行 6.并行编程常用框架: unroll 甚至略微超过了并 行版的 AOS !可见 OpenMP 并非万能膏 药,单线程的程序认真优化后一样打败无脑 并行。 结论: SOA 是针对这个案例最高效的数据排布格式 第 7 章: STL 容器 std::vector :也有指针别名问题 __restrict :能否用于 std::vector ? 没用! 解决方案: pragma omp simd 或 pragma GCC0 码力 | 108 页 | 9.47 MB | 1 年前3
Working with Asynchrony Generically: A Tour of C++ ExecutorsAn extended example3 GOALS FOR THE EXECUTORS PROPOSAL The vision: “An asynchronous analog of the STL” • A full suite of standard async algorithms based on real-world requirements: E.g., then, when_all com/facebookexperimental/libunifex54 SUMMARY FROM PART 1 1. Vision: “An asynchronous analogue of the STL” 2. Some simple examples, intro to senders 3. The lifecycle of an async operation with sender/receiver0 码力 | 121 页 | 7.73 MB | 6 月前3
共 17 条
- 1
- 2













