官术网_书友最值得收藏!

1 Learning Modern Core Language Features

The C++ language has gone through a major transformation in the past decade with the development and release of C++11 and then, later, with its newer versions: C++14, C++17, and C++20. These new standards have introduced new concepts, simplified and extended existing syntax and semantics, and overall transformed the way we write code. C++11 looks like a new language, and code written using the new standards is called modern C++ code.

The recipes included in this chapter are as follows:

  • Using auto whenever possible
  • Creating type aliases and alias templates
  • Understanding uniform initialization
  • Understanding the various forms of non-static member initialization
  • Controlling and querying object alignment
  • Using scoped enumerations
  • Using override and final for virtual methods
  • Using range-based for loops to iterate on a range
  • Enabling range-based for loops for custom types
  • Using explicit constructors and conversion operators to avoid implicit conversion
  • Using unnamed namespaces instead of static globals
  • Using inline namespaces for symbol versioning
  • Using structured bindings to handle multi-return values
  • Simplifying code with class template argument deduction

Let's start by learning about automatic type deduction.

主站蜘蛛池模板: 恩施市| 太保市| 五原县| 镇巴县| 淮安市| 安陆市| 小金县| 威信县| 湖州市| 梅河口市| 潼南县| 都匀市| 玉溪市| 万宁市| 桂阳县| 拉萨市| 宜良县| 商城县| 静乐县| 平安县| 德阳市| 依安县| 易门县| 壤塘县| 尖扎县| 阳曲县| 罗平县| 专栏| 永吉县| 建德市| 重庆市| 新昌县| 顺昌县| 白玉县| 府谷县| 赤城县| 德安县| 遂平县| 闽侯县| 青海省| 肃宁县|