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

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.

主站蜘蛛池模板: 梓潼县| 柳河县| 丰台区| 陕西省| 开平市| 太仓市| 牡丹江市| 洛隆县| 浦城县| 公主岭市| 揭东县| 河间市| 钟祥市| 安化县| 东乡县| 左贡县| 长汀县| 斗六市| 加查县| 石屏县| 福泉市| 新宾| 商都县| 施甸县| 吉木萨尔县| 灵山县| 社旗县| 邢台县| 普洱| 沈丘县| 萨嘎县| 绥德县| 茶陵县| 宁陵县| 汝阳县| 洛浦县| 阿城市| 县级市| 克山县| 三穗县| 罗定市|