You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,12 @@ I'm not very picky about how you should contribute, but I ask that the following
9
9
* Proper spelling and grammar.
10
10
* If it's a language or library feature that you can write code with, please provide an
11
11
example of its usage. An optimal submission would also include a short real-world use case for the feature.
12
-
* Make sure the feature is in the correct C++ version.
12
+
* Keep additions/deletions of content consistent with the cheatsheet's goals (see below).
13
+
14
+
#### Instructions
15
+
* Make sure the feature is in the correct C++ version file (i.e. CPP11.md, etc.).
13
16
* Make sure you've added the feature to the table of contents.
14
-
* Make sure you have also added the feature to the separate major C++ readme files (i.e. CPP11.md, CPP14.md, etc.).
15
-
* Keep additions/deletions of content consistent with the cheatsheet's goals.
17
+
* Note: Please don't make changes to README.md itself -- the changes in the individual markdown files are all added to the README automatically.
16
18
17
19
## Goals
18
20
My goal for this cheatsheet is to prefer conciseness over absolute completeness. Examples of features should be minimal: if an example is overly complicated, large, or is more of an obscure usage of the feature then it will most likely be rejected in review. The reason for this goal is to teach users what the most popular uses of these features will be, and for a more thorough investigation, to learn about those from external C++ resources.
See also: [`decltype (C++11)`](README.md#decltype).
126
126
127
127
### Relaxing constraints on constexpr functions
128
128
In C++11, `constexpr` function bodies could only contain a very limited set of syntaxes, including (but not limited to): `typedef`s, `using`s, and a single `return` statement. In C++14, the set of allowable syntaxes expands greatly to include the most common syntax such as `if` statements, multiple `return`s, loops, etc.
@@ -198,7 +198,7 @@ The compiler is free to call `new T{}`, then `function_that_throws()`, and so on
Copy file name to clipboardExpand all lines: CPP17.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -180,7 +180,7 @@ namespace A::B::C {
180
180
```
181
181
182
182
### Structured bindings
183
-
A proposal for de-structuring initialization, that would allow writing `auto [ x, y, z ] = expr;` where the type of `expr` was a tuple-like object, whose elements would be bound to the variables `x`, `y`, and `z` (which this construct declares). _Tuple-like objects_ include `std::tuple`, `std::pair`, `std::array`, and aggregate structures.
183
+
A proposal for de-structuring initialization, that would allow writing `auto [ x, y, z ] = expr;` where the type of `expr` was a tuple-like object, whose elements would be bound to the variables `x`, `y`, and `z` (which this construct declares). _Tuple-like objects_ include [`std::tuple`](README.md#tuples), `std::pair`, [`std::array`](README.md#stdarray), and aggregate structures.
Copy file name to clipboardExpand all lines: README.md
+18-14
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# C++20/17/14/11
2
2
3
3
## Overview
4
-
Many of these descriptions and examples are taken from various resources (see [Acknowledgements](#acknowledgements) section) and summarized in my own words.
4
+
5
5
6
6
C++20 includes the following new language features:
7
7
-[coroutines](#coroutines)
@@ -33,6 +33,7 @@ C++20 includes the following new library features:
33
33
-[std::midpoint](#stdmidpoint)
34
34
-[std::to_array](#stdto_array)
35
35
36
+
36
37
C++17 includes the following new language features:
37
38
-[template argument deduction for class templates](#template-argument-deduction-for-class-templates)
38
39
-[declaring non-type template parameters with auto](#declaring-non-type-template-parameters-with-auto)
@@ -61,6 +62,7 @@ C++17 includes the following new library features:
61
62
-[splicing for maps and sets](#splicing-for-maps-and-sets)
62
63
-[parallel algorithms](#parallel-algorithms)
63
64
65
+
64
66
C++14 includes the following new language features:
The class template `std::variant` represents a type-safe `union`. An instance of `std::variant` at any given time holds a value of one of its alternative types (it's also possible for it to be valueless).
In C++11, `constexpr` function bodies could only contain a very limited set of syntaxes, including (but not limited to): `typedef`s, `using`s, and a single `return` statement. In C++14, the set of allowable syntaxes expands greatly to include the most common syntax such as `if` statements, multiple `return`s, loops, etc.
@@ -1258,7 +1263,6 @@ C++14 introduces the `[[deprecated]]` attribute to indicate that a unit (functio
1258
1263
```c++
1259
1264
[[deprecated]]
1260
1265
voidold_method();
1261
-
1262
1266
[[deprecated("Use new_method instead")]]
1263
1267
voidlegacy_method();
1264
1268
```
@@ -1305,7 +1309,7 @@ The compiler is free to call `new T{}`, then `function_that_throws()`, and so on
C++11 introduces new smart pointers: `std::unique_ptr`, `std::shared_ptr`, `std::weak_ptr`. `std::auto_ptr` now becomes deprecated and then eventually removed in C++17.
2060
2063
2061
-
`std::unique_ptr` is a non-copyable, movable pointer that manages its own heap-allocated memory. **Note: Prefer using the `std::make_X` helper functions as opposed to using constructors. See the sections for [std::make_unique](#stdmake_unique) and [std::make_shared](#stdmake_shared).**
2064
+
`std::unique_ptr` is a non-copyable, movable pointer that manages its own heap-allocated memory. **Note: Prefer using the `std::make_X` helper functions as opposed to using constructors. See the sections for [std::make_unique](https://github.com/AnthonyCalandra/modern-cpp-features/blob/master/CPP14.md#stdmake_unique) and [std::make_shared](#stdmake_shared).**
@@ -2221,16 +2224,17 @@ auto a = CountTwos(vec); // 2
2221
2224
auto b = CountTwos(arr); // 1
2222
2225
```
2223
2226
2227
+
2228
+
2224
2229
## Acknowledgements
2225
2230
* [cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features.
2226
2231
* [C++ Rvalue References Explained](http://thbecker.net/articles/rvalue_references/section_01.html) - a great introduction I used to understand rvalue references, perfect forwarding, and move semantics.
2227
2232
* [clang](http://clang.llvm.org/cxx_status.html) and [gcc](https://gcc.gnu.org/projects/cxx-status.html)'s standards support pages. Also included here are the proposals for language/library features that I used to help find a description of, what it's meant to fix, and some examples.
2228
2233
* [Compiler explorer](https://godbolt.org/)
2229
-
* [Scott Meyers' Effective Modern C++](https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996) - highly recommended book!
2234
+
* [Scott Meyers' Effective Modern C++](https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996) - highly recommended series of books!
2230
2235
* [Jason Turner's C++ Weekly](https://www.youtube.com/channel/UCxHAlbZQNFU2LgEtiqd2Maw) - nice collection of C++-related videos.
2231
2236
* [What can I do with a moved-from object?](http://stackoverflow.com/questions/7027523/what-can-i-do-with-a-moved-from-object)
2232
2237
* [What are some uses of decltype(auto)?](http://stackoverflow.com/questions/24109737/what-are-some-uses-of-decltypeauto)
*[cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features.
11
+
*[C++ Rvalue References Explained](http://thbecker.net/articles/rvalue_references/section_01.html) - a great introduction I used to understand rvalue references, perfect forwarding, and move semantics.
12
+
*[clang](http://clang.llvm.org/cxx_status.html) and [gcc](https://gcc.gnu.org/projects/cxx-status.html)'s standards support pages. Also included here are the proposals for language/library features that I used to help find a description of, what it's meant to fix, and some examples.
13
+
*[Compiler explorer](https://godbolt.org/)
14
+
*[Scott Meyers' Effective Modern C++](https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996) - highly recommended series of books!
15
+
*[Jason Turner's C++ Weekly](https://www.youtube.com/channel/UCxHAlbZQNFU2LgEtiqd2Maw) - nice collection of C++-related videos.
16
+
*[What can I do with a moved-from object?](http://stackoverflow.com/questions/7027523/what-can-i-do-with-a-moved-from-object)
17
+
*[What are some uses of decltype(auto)?](http://stackoverflow.com/questions/24109737/what-are-some-uses-of-decltypeauto)
0 commit comments