book: typo and grammar fixes (#185)

This commit is contained in:
Nikhil Garuda
2021-04-18 15:42:26 +05:30
committed by GitHub
parent 45bef893a7
commit 731a219d89
10 changed files with 421 additions and 429 deletions

View File

@@ -9,22 +9,22 @@ order: 10
[TOC]
C++20 seems to be an exciting update.
For example, as early as C++11, the `Concept`,
For example, as early as C++11, the `Concept`,
which was eager to call for high-altitude but ultimately lost, is now on the line.
The C++ Organizing Committee decided to vote to finalize C++20 with many proposals,
The C++ Organizing Committee decided to vote to finalize C++20 with many proposals,
such as **Concepts**/**Module**/**Coroutine**/**Ranges**/ and so on.
In this chapter we'll take a look at some of the important features that
In this chapter, we'll take a look at some of the important features that
C++20 will introduce.
## Concept
Concept is a further enhancement to C++ template programming.
The concept is a further enhancement to C++ template programming.
In simple terms, the concept is a compile-time feature.
It allows the compiler to evaluate template parameters at compile time,
It allows the compiler to evaluate template parameters at compile-time,
greatly enhancing our experience with template programming in C++.
When programming with templates, we often encounter a variety of heinous errors.
This is because we have so far been unable to check and limit template parameters.
For example, the following two lines of code can cause a lot of
For example, the following two lines of code can cause a lot of
almost unreadable compilation errors:
```cpp
@@ -37,12 +37,12 @@ int main() {
}
```
The root cause of this code error is that `std::sort` must provide
a random iterator for the sorting container, otherwise it will not be used,
The root cause of this code error is that `std::sort` must provide
a random iterator for the sorting container, otherwise it will not be used,
and we know that `std::list` does not support random access.
In the conceptual language, the iterator in `std::list` does not satisfy
In the conceptual language, the iterator in `std::list` does not satisfy
the constraint of the concept of random iterators in `std::sort`.
After introducing the concept, we can constrain the template parameters
After introducing the concept, we can constrain the template parameters
like this:
```cpp
@@ -99,4 +99,4 @@ This is still full of charm for a programming language that is already in its th
## Licenses
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](../../LICENSE).
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](../../LICENSE).