C++ Memory Model: from C++11 to C++23Memory Model C++11 – C++23About Me: alex.dathskovsky@speedata.io www.linkedin.com/in/alexdathskovsky https://www.cppnext.comAlex Dathskovsky | alex.dathskovsky@speedata.io | www.linkedin.com/in/a dathskovsky@speedata.io | www.linkedin.com/in/alexdathskovsky Synchronization Tools ● Static: from C++11 static variables initialization is magicAlex Dathskovsky | alex.dathskovsky@speedata.io | www.linkedin0 码力 | 112 页 | 5.17 MB | 6 月前3
Modern C++ Tutorial: C++11/14/17/20 On the FlyModern C++ Tutorial: C++11/14/17/20 On the Fly Changkun Ou (hi[at]changkun.de) Last update: May 7, 2023 Notice The content in this PDF file may outdated, please check our website or GitHub repository advent of C++98 to the official finalization of C++11, it has continued to stay relevant. C++14/17 is an important complement and optimization for C++11, and C++20 brings this language to the door of modernization are not using the same language while reading modern C++ code. Modern C++ (this book refers to C++11/14/17/20) introduces many features into traditional C++ which bring the entire language to a new0 码力 | 92 页 | 1.79 MB | 1 年前3
现代C++ 教程:高速上手C++11/14/17/20现代 C++ 教程:高速上手 C++11/14/17/20 欧长坤 (hi[at]changkun.de) 最后更新 2023 年 5 月 7 日- ff6ee89 注意 此 PDF 的内容可能过期,请检查本书网站以及 GitHub 仓库以获取最新内容。 版权声明 本书系欧长坤著,采用“知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 (CC BY-NC-ND)”进 行许可 . . . . . . . . . . . . . 83 6 序言 序言 引言 C++ 是一个用户群体相当大的语言。从 C++98 的出现到 C++11 的正式定稿经历了长达十年多之 久的积累。C++14/17 则是作为对 C++11 的重要补充和优化,C++20 则将这门语言领进了现代化的大 门,所有这些新标准中扩充的特性,给 C++ 这门语言注入了新的活力。那些还在坚持使用传统 C++ 特性均称之为传统 C++)而未接触过现代 C++ 的 C++ 程序员在 见到诸如 Lambda 表达式这类全新特性时,甚至会流露出『学的不是同一门语言』的惊叹之情。 现代 C++ (本书中均指 C++11/14/17/20) 为传统 C++ 注入的大量特性使得整个 C++ 变得更加 像一门现代化的语言。现代 C++ 不仅仅增强了 C++ 语言自身的可用性,auto 关键字语义的修改使得我 们更0 码力 | 83 页 | 2.42 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 05 C++11 开始的多线程编程C++11 开始的多线程编 程 by 彭于斌( @archibate ) 往期录播: https://www.bilibili.com/video/BV1fa411r7zp 课程 PPT 和代码: https://github.com/parallel101/course 高性能并行编程与优化 - 课程大纲 • 分为前半段和后半段,前半段主要介绍现代 C++ ,后半段主要介绍并行编程与优化。 GitHub ) CUDA Toolkit 10.0 以上( GPU 专题) 温馨提示: 1. 会用到第二讲( RAII 与智能指针)里的知识 2. 课件中一部分代码是基于 C++17 的 个人认为, C++11 中很多特性, 其实可以看做是为了支持多线程而 顺带引入的……如 chrono 、移动 、 lambda 、 RAII…… 第 0 章:时间 C 语言如何处理时间: time.h • long ,没有类型区分,导致很容易弄错单位,混淆时间点和时间段。 • 比如 t0 * 3 ,乘法对时间点而言根本是个无意义的计算,然而 C 语言把他们看做一样的 long 类型,从而容易让程序员犯错。 C++11 引入的时间标准库: std::chrono • 利用 C++ 强类型的特点,明确区分时间点与时间段,明确区分不同的时间单位。 • 时间点例子: 2022 年 1 月 8 日 13 点 07 分0 码力 | 79 页 | 14.11 MB | 1 年前3
Modern C++ Iterators++p) { std::cout << *p << '\n'; } 30 40 50 60 70 10 20 pos begin() end() c v i d e e ++ C++98/C++11 arr: ©2023 by josuttis.com 6 C++ Iterators: Generalization of Pointers that Iterate • Iterate arr+4; ++p) { std::cout << *p << '\n'; } 30 40 50 60 70 10 20 pos begin() end() c v i d e e ++ C++11 p: arr: Nico Josuttis Modern C++ 2023-10-03 @CppCon 3©2023 by josuttis.com 7 C++ Half-Open Range arr; p < arr+4; ++p) { std::cout << *p << '\n'; } 30 40 50 60 70 10 20 pos begin() end() ++ C++11 auto pos = v.end(); // OK std::cout << *pos; // Undefined Behavior p: arr: ©2023 by josuttis.com0 码力 | 24 页 | 1.93 MB | 6 月前3
Google C++ Style Guidefirst parameter have default values. The explicit keyword can be applied to a constructor or (since C++11) a conversion operator, to ensure that it can only be used when the destination type is explicit at at the point of use, e.g. with a cast. This applies not only to implicit conversions, but to C++11’s list initialization syntax: class Foo { explicit Foo(int x, double y); ... }; void Func(Foo f); Func({42 type appears before the function name. For example: int foo(int x); The new form, introduced in C++11, uses the auto keyword before the function name and a trailing return type after the argument list0 码力 | 83 页 | 238.71 KB | 1 年前3
cppcon 2021 safety guidelines for C parallel and concurrencyUL4600 Object Tracking ● RISC-V Datacenter/Cloud Computing Chair ● http://wongmichael.com/about ● C++11 book in Chinese: https://www.amazon.cn/dp/B00ETOV2OQ We build GPU compilers for some of the most ++: checkable rules • Common Weakness Enumeration: a mix Many Safety Critical APIs • Safe but not C++11/14/17/20 • Joint Strike Fighter Air Vehicle C++ Coding Standards for the System Development and the reference despite its age • For automated static analysis tools • Aimed for embedded domains • C++11/14/17/20 but not safe • High Integrity C++ Coding Standard Version 4.0, Programming Research Ltd0 码力 | 52 页 | 3.14 MB | 6 月前3
Cooperative C++ Evolution30 years syntax… #2 ? “bubble of new code” that doesn’t exist today What if we could do “C++11 feels like a new language” again, for the whole language?5 Major improvement via directed evolution enum language type C++11: extended enum and added enum class Can specify underlying type, enumerators are scoped, no implicit conversion .29 C: Special enum language type C++11: extended enum and class + only valid values Automates what we already teach today30 C: Special enum language type C++11: extended enum and added enum class Can specify underlying type, enumerators are scoped, no implicit0 码力 | 85 页 | 5.73 MB | 6 月前3
Back to Basics: Concurrencyodwyer@gmail.com Arthur O’Dwyer 2020-09-18Outline ● What is a data race and how do we fix it? [3–12] ● C++11 mutex and RAII lock types [13–23] Questions? ● condition_variable [24–28] ● Static initialization sleep(200ms); Is this a legal optimization for a C++ compiler to perform? Prior to C++11, the answer was “no idea.” The C++11 answer is unambiguously “yes.” No other thread is allowed to look at the variable thread In C++03 pthreads, you’d create a new thread by calling a third-party library function. In C++11, the standard library “owns” the notion of creating new threads. To create a thread, you create a0 码力 | 58 页 | 333.56 KB | 6 月前3
Back to Basics: Smart Pointersresource during a copy operation std::unique_ptr C++11 ▪ Owns the resource exclusively ▪ Can not be copied ▪ Deals with non-copy objects std::shared_ptr C++11 ▪ Shares a resource ▪ Supports an reference resource and manages it ▪ Deletes the resource if the reference counter becomes 0 std::weak_ptr C++11 ▪ Borrows the resource ▪ Helps to break cyclic references ▪ Doesn't change the reference counter Available Since new 2.93 s C++98 std::unique_ptr 2.96 s C++11 std::make_unique 2.84 s C++14 std::shared_ptr 6.00 s C++11 std::make_shared 3.40 s C++11 19Smart Pointer ▪ Further information: ▪ std::unique_ptr0 码力 | 30 页 | 625.43 KB | 6 月前3
共 281 条
- 1
- 2
- 3
- 4
- 5
- 6
- 29













