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

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.

主站蜘蛛池模板: 大理市| 丽水市| 荥阳市| 枞阳县| 五莲县| 岳西县| 长葛市| 海城市| 布尔津县| 宜良县| 克东县| 鹤山市| 长武县| 清苑县| 乐安县| 阆中市| 航空| 托克逊县| 武胜县| 怀化市| 明水县| 中宁县| 宁蒗| 镇雄县| 祁门县| 木里| 博罗县| 嘉定区| 花莲市| 大足县| 南投市| 阳信县| 大理市| 湖北省| 金塔县| 名山县| 全州县| 博客| 嘉荫县| 永修县| 闽侯县|