Embracing Modern C++ Safely

Book description

Maximize Reward and Minimize Risk with Modern C++

Embracing Modern C++ Safely shows you how to make effective use of the new and enhanced language features of modern C++ without falling victim to their potential pitfalls.

Based on their years of experience with large, mission-critical projects, four leading C++ authorities divide C++11/14 language features into three categories: Safe, Conditionally Safe, and Unsafe. Safe features offer compelling value, are easy to use productively, and are relatively difficult to misuse. Conditionally Safe features offer significant value but come with risks that require significant expertise and familiarity before use. Unsafe features have an especially poor risk/reward ratio, are easy to misuse, and are beneficial in only the most specialized circumstances.

This book distills the C++ community's years of experience applying C++11 and C++14 features and will help you make effective and safe design decisions that reflect real-world, economic engineering tradeoffs in large-scale, diverse software development environments. The authors use examples derived from real code bases to illustrate every finding objectively and to illuminate key issues. Each feature identifies the sound use cases, hidden pitfalls, and shortcomings of that language feature. After reading this book, you will

  • Understand what each C++11/14 feature does and where it works best

  • Recognize how to work around show-stopping pitfalls and annoying corner cases

  • Know which features demand additional training, experience, and peer review

  • Gain insights for preparing coding standards and style guides that suit your organization's needs

  • Be equipped to introduce modern C++ incrementally and judiciously into established code bases

Seasoned C++ developers, team leads, and technical managers who want to improve productivity, code quality, and maintainability will find the insights in this modular, meticulously organized reference indispensable.

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Pearson’s Commitment to Diversity, Equity, and Inclusion
  7. Dedication Page
  8. Contents
  9. Foreword by Shawn Edwards
  10. Foreword by Andrei Alexandrescu
  11. Acknowledgments
  12. About the Authors
  13. Chapter 0. Introduction
    1. What Makes This Book Different
    2. Scope for the First Edition
    3. The EMC++S Guiding Principles
    4. What Do We Mean by Safely?
    5. A Safe Feature
    6. A Conditionally Safe Feature
    7. An Unsafe Feature
    8. Modern C++ Feature Catalog
    9. How to Use This Book
  14. Chapter 1. Safe Features
    1. 1.1 C++11
      1. Attribute Syntax
      2. Consecutive >s
      3. decltype
      4. Defaulted Functions
      5. Delegating Ctors
      6. Deleted Functions
      7. explicit Operators
      8. Function static ’11
      9. Local Types ’11
      10. long long
      11. noreturn
      12. nullptr
      13. override
      14. Raw String Literals
      15. static_assert
      16. Trailing Return
      17. Unicode Literals
      18. using Aliases
      19. Aggregate Init ’14
      20. Binary Literals
    2. 1.2 C++14
      1. deprecated
      2. Digit Separators
      3. Variable Templates
  15. Chapter 2. Conditionally Safe Features
    1. 2.1 C++11
      1. alignas
      2. alignof
      3. auto Variables
      4. Braced Init
      5. constexpr Functions
      6. constexpr Variables
      7. Default Member Init
      8. enum class
      9. extern template
      10. Forwarding References
      11. Generalized PODs ’11
      12. Inheriting Constructors
      13. initializer_list
      14. Lambdas
      15. noexcept Operator
      16. Opaque enums
      17. Range for
      18. Rvalue References
      19. Underlying Type ’11
      20. User-Defined Literals
      21. Variadic Templates
    2. 2.2 C++14
      1. constexpr Functions ’14
      2. Generic Lambdas
      3. Lambda Init-Captures
  16. Chapter 3. Unsafe Features
    1. 3.1 C++11
      1. carries_dependency
      2. final
      3. friend ’11
      4. inline namespace
      5. noexcept Specifier
      6. Ref-Qualifiers
      7. union ’11
    2. 3.2 C++14
      1. auto Return
      2. decltype(auto)
  17. Afterword: Looking Back and Looking Forward
  18. Glossary
  19. Bibliography
  20. Index
  21. Code Snippets

Product information

  • Title: Embracing Modern C++ Safely
  • Author(s): John Lakos, Vittorio Romeo, Rostislav Khlebnikov, Alisdair Meredith
  • Release date: December 2021
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780137380411