LitMy.ru - литература в один клик

C++20 - Get the Details (2023)

  • Добавил: literator
  • Дата: 20-08-2024, 19:58
  • Комментариев: 0
Название: C++20 - Get the Details
Автор: Rainer Grimm
Издательство: Leanpub
Год: 2023-09-13
Страниц: 678
Язык: английский
Формат: pdf (true), epub
Размер: 25.1 MB

C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.

My book C++20 is a tutorial and a reference for the C++20 standard. It teaches you C++20 and provides details of this new, thrilling C++ standard. The exciting factor is mainly due to the big four of C++20.

Concepts change the way we think and program templates. They are semantic categories for the template parameters and enable you to express your intention directly in the type system. If something goes wrong, you get a clear error message.
The new ranges library enables it to perform algorithms directly on the container, compose the algorithm with the pipe symbol, and apply them to infinite data streams.
Thanks to coroutines, asynchronous programming in C++ has become mainstream. Coroutines are the base for cooperative tasks, event loops, infinite data streams, or pipelines.
Modules overcome the restrictions of header files. They promise a lot. For example, the separation of header and source files becomes obsolete as the preprocessor. Ultimately, we have faster built time and an easier way to build packages.

As the C++20 standard is brand-new, many examples can only be compiled and executed with a specific compiler. I use the newest GCC, Clang, and MSVC compilers. When you compile the program, you must specify the applied C++ standard. This means, with GCC or Clang you must provide the flag -std=c++20, and with MSVC /std:c++latest. When using concurrency features, unlike with MSVC, the GCC and Clang compilers require that you link the pthread library using -pthread. If you don’t have an appropriate C++ compiler at your disposal, use an online compiler such as Wandbox or Compiler Explorer. If you use Compiler Explorer with GCC or Clang, you can also execute the program.

Coroutines are generalized functions that can be suspended and resumed later while maintaining their state. Coroutines are a convenient way to write event-driven applications. Event-driven applications can be simulations, games, servers, user interfaces, or even algorithms. Coroutines are also typically used for cooperative multitasking. C++20 does not provide concrete coroutines, but C++20 provides a framework for implementing coroutines. This framework consists of more than 20 functions, and some of which you must implement, some of which you can override. Therefore, you can tailor coroutines to your needs.

Скачать C++20 - Get the Details (2023)












[related-news] [/related-news]
Внимание
Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь.
Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.