𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

C++ Core Guidelines Explained: Best Practices for Modern C++

✍ Scribed by Rainer Grimm


Publisher
Addison-Wesley Professional
Year
2022
Tongue
English
Leaves
403
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Table of Contents


Title Page
Table of Contents
Contents
Foreword
Preface
Conventions
Why guidelines?
Pantha rhei
How to read this book?
Acknowledgments
About the Author
Part I. The Guidelines
Chapter 1. Introduction
Target readership
Aim
Non-aims
Enforcement
Structure
Major sections
Distilled
Chapter 2. Philosophy
P.1. Express ideas directly in code
P.2: Write in ISO Standard C++
P.3: Express intent
P.4: Ideally, a program should be statically type safe
P.5: Prefer compile-time checking to run-time checking
P.6: What cannot be checked at compile-time should be checkable at run-time
P.7: Catch run-time errors early
P.8: Don’t leak any resources
P.9: Don’t waste time or space
P.10: Prefer immutable data to mutable data
P.11: Encapsulate messy constructs, rather than spreading through the code
P.12: Use supporting tools as appropriate
P.13: Use support libraries as appropriate
Distilled
Chapter 3. Interfaces
I.2: Avoid non-const global variables
I.3: Avoid singletons
Making good interfaces
I.13: Do not pass an array as a single pointer
I.27: For stable library ABI, consider the Pimpl idiom
Related rules
Distilled
Chapter 4. Functions
Function definitions
Parameter passing: in and out
Parameter passing: ownership semantic
Value return semantics
Other functions
Related rules
Distilled
Chapter 5. Classes and Class Hierarchies
Summary rules
Concrete types
Constructors, assignments, and destructors
Class hierarchies
Overloading and overloaded operators
Unions
Related rules
Distilled
Chapter 6. Enumerations
Enum.1: Prefer enumerations over macros
Enum.2: Use enumerations to represent sets of related named constants
Enum.3: Prefer enum classes over β€œplain” enums
Enum.5: Don’t use ALL_CAPS for enumerators
Enum.6: Avoid unnamed enumerations
Enum.7: Specify the underlying type of an enumeration only when necessary
Enum.8: Specify enumerator values only when necessary
Related Rules
Distilled
Chapter 7. Resource Management
General rules
Allocation and deallocation
Smart pointers
Related Rules
Distilled
Chapter 8. Expressions and Statements
General
Declarations
Expressions
Statements
Arithmetic
Related Rules
Distilled
Chapter 9. Performance
Wrong optimizations
Wrong assumptions
Enable optimization
Related Rules
Distilled
Chapter 10. Concurrency
General guidelines
Concurrency
Parallelism
Message passing
Lock-free programming
Related Rules
Distilled
Chapter 11. Error Handling
Design
Implementation
If you can’t throw
Related Rules
Distilled
Chapter 12. Constants and Immutability
Con.1: By default, make objects immutable
Con.2: By default, make member functions const
Con.3: By default, pass pointers and references to consts
Con.4: Use const to define objects with values that do not change after construction
Con.5: Use constexpr for values that can be computed at compile-time
Distilled
Chapter 13. Templates and Generic Programming
Use
Interfaces
Definition
Hierarchies
Variadic templates
Metaprogramming
Other rules
Related Rules
Distilled
Chapter 14. C-Style Programming
CPL.1: Prefer C++ to C
CPL.2: If you must use C, use the common subset of C and C++, and compile the C code as C++
CPL.3: If you must use C for interfaces, use C+ + in the calling code using such interfaces
Distilled
Chapter 15. Source Files
Interface and implementation files
Namespaces
Distilled
Chapter 16. The Standard Library
Containers
Text
In- and output
Related Rules
Distilled
Part II. Supporting Sections
Chapter 17. Architectural Ideas
A.1: Separate stable code from less stable code
A.2: Express potentially reusable parts as a library
A.4: There should be no cycles among libraries
Chapter 18. Non-Rules and Myths
NR.1: Don’t insist that all declarations should be at the top of a function
NR.2: Don’t insist to have only a single return-statement in a function
NR.3: Don’t avoid exceptions
NR.4: Don’t insist on placing each class declaration in its own source file
NR.5: Don’t use two-phase initialization
NR.6: Don’t place all cleanup actions at the end of a function and goto exit
NR.7: Don’t make all data members protected
Chapter 19. Profiles
Pro.type: Type safety
Pro.bounds: Bounds safety
Pro.lifetime: Lifetime safety
Chapter 20. Guideline Support Library
Views
Ownership pointers
Assertions
Utilities
Part III. Appendix
Appendix A. Enforcing the C++ Core Guidelines
Visual Studio
clang-tidy
Appendix B. Concepts
Appendix C. Contracts


πŸ“œ SIMILAR VOLUMES


C++ Core Guidelines Explained: Best Prac
✍ Rainer Grimm πŸ“‚ Library πŸ“… 2022 πŸ› Addison-Wesley Professional 🌐 English

<p><span>Write More Elegant C++ Programs</span></p><p><span>The official C++ Core Guidelines provide consistent best practices for writing outstanding modern C++ code and improving legacy code, but they're organized as a reference for looking up one specific point at a time, not as a tutorial for wo

C++ Coding Standards: 101 Rules, Guideli
✍ Herb Sutter, Andrei Alexandrescu πŸ“‚ Library πŸ“… 2004 πŸ› Addison-Wesley Professional 🌐 English

Consistent, high-quality coding standards improve software quality, reduce time-to-market, promote teamwork, eliminate time wasted on inconsequential matters, and simplify maintenance. Now, two of the world's most respected C++ experts distill the rich collective experience of the global C++ communi

C++ coding standards: 101 rules, guideli
✍ Sutter, Herb;Alexandrescu, Andrei πŸ“‚ Library πŸ“… 2004;2011 πŸ› Addison-Wesley Professional 🌐 English

Every software development team should have and follow a coding standard.It's even better when what the coding standard requires is actually consistent, reasonable, and correct.Coding standards have many advantages: *They improve code quality. This happens automatically when following agood, simple