mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 10:04:35 +03:00
committed by
Anthony Calandra
parent
bfebe0936c
commit
aa50febf56
12
CPP17.md
12
CPP17.md
@@ -28,6 +28,7 @@ C++17 includes the following new library features:
|
|||||||
- [std::filesystem](#stdfilesystem)
|
- [std::filesystem](#stdfilesystem)
|
||||||
- [std::byte](#stdbyte)
|
- [std::byte](#stdbyte)
|
||||||
- [splicing for maps and sets](#splicing-for-maps-and-sets)
|
- [splicing for maps and sets](#splicing-for-maps-and-sets)
|
||||||
|
- [parallel algorithms](#parallel-algorithms)
|
||||||
|
|
||||||
## C++17 Language Features
|
## C++17 Language Features
|
||||||
|
|
||||||
@@ -394,6 +395,17 @@ m.insert(std::move(e));
|
|||||||
// m == { { 1, "one" }, { 3, "three" }, { 4, "two" } }
|
// m == { { 1, "one" }, { 3, "three" }, { 4, "two" } }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Parallel algorithms
|
||||||
|
Many of the STL algorithms, such as the `copy`, `find` and `sort` methods, started to support the *parallel execution policies*: `seq`, `par` and `par_unseq` which translate to "sequentially", "parallel" and "parallel unsequenced".
|
||||||
|
|
||||||
|
```c++
|
||||||
|
std::vector<int> longVector;
|
||||||
|
// Find element using parallel execution policy
|
||||||
|
auto result1 = std::find(std::execution::par, std::begin(longVector), std::end(longVector), 2);
|
||||||
|
// Sort elements using sequential execution policy
|
||||||
|
auto result2 = std::sort(std::execution::seq, std::begin(longVector), std::end(longVector));
|
||||||
|
```
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
* [cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features.
|
* [cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features.
|
||||||
* [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.
|
* [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
README.md
12
README.md
@@ -30,6 +30,7 @@ C++17 includes the following new library features:
|
|||||||
- [std::filesystem](#stdfilesystem)
|
- [std::filesystem](#stdfilesystem)
|
||||||
- [std::byte](#stdbyte)
|
- [std::byte](#stdbyte)
|
||||||
- [splicing for maps and sets](#splicing-for-maps-and-sets)
|
- [splicing for maps and sets](#splicing-for-maps-and-sets)
|
||||||
|
- [parallel algorithms](#parallel-algorithms)
|
||||||
|
|
||||||
C++14 includes the following new language features:
|
C++14 includes the following new language features:
|
||||||
- [binary literals](#binary-literals)
|
- [binary literals](#binary-literals)
|
||||||
@@ -453,6 +454,17 @@ m.insert(std::move(e));
|
|||||||
// m == { { 1, "one" }, { 3, "three" }, { 4, "two" } }
|
// m == { { 1, "one" }, { 3, "three" }, { 4, "two" } }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Parallel algorithms
|
||||||
|
Many of the STL algorithms, such as the `copy`, `find` and `sort` methods, started to support the *parallel execution policies*: `seq`, `par` and `par_unseq` which translate to "sequentially", "parallel" and "parallel unsequenced".
|
||||||
|
|
||||||
|
```c++
|
||||||
|
std::vector<int> longVector;
|
||||||
|
// Find element using parallel execution policy
|
||||||
|
auto result1 = std::find(std::execution::par, std::begin(longVector), std::end(longVector), 2);
|
||||||
|
// Sort elements using sequential execution policy
|
||||||
|
auto result2 = std::sort(std::execution::seq, std::begin(longVector), std::end(longVector));
|
||||||
|
```
|
||||||
|
|
||||||
## C++14 Language Features
|
## C++14 Language Features
|
||||||
|
|
||||||
### Binary literals
|
### Binary literals
|
||||||
|
|||||||
Reference in New Issue
Block a user