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

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.

主站蜘蛛池模板: 马公市| 景东| 景德镇市| 疏附县| 吉林市| 老河口市| 盐源县| 桂平市| 宁南县| 仙居县| 平定县| 古蔺县| 天等县| 新绛县| 大足县| 天门市| 景东| 宜都市| 昌江| 卢氏县| 肥乡县| 濮阳市| 基隆市| 余姚市| 上高县| 新田县| 抚松县| 隆安县| 通渭县| 中宁县| 循化| 永修县| 珠海市| 仪征市| 临猗县| 庆阳市| 西乡县| 靖西县| 六盘水市| 石泉县| 桐梓县|