beautiful_c_plus_plus_-_30_core_guidelines_for_writing_clean_safe_and_fast_code_table_of_contents

Beautiful C++ - 30 Core Guidelines for Writing Clean, Safe, and Fast Code Table of Contents

Return to Beautiful C++

Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code

Contents

List of Selected C++ Core Guidelines

Acknowledgments

About the Authors

Section 1 Bikeshedding is bad

Chapter 1.2 F.51: Where there is a choice, prefer default arguments over overloading

Chapter 1.3 C.45: Don’t define a default constructor that only initializes data members; use in-class member initializers instead

Chapter 1.4 C.131: Avoid trivial getters and setters

Chapter 1.5 ES.10: Declare one name (only) per declaration

Chapter 1.6 NR.2: Don’t insist to have only a single return-statement in a function

Section 2 Don’t hurt yourself

Chapter 2.1 P.11: Encapsulate messy constructs, rather than spreading through the code

Chapter 2.2 I.23: Keep the number of function arguments low

Chapter 2.3 I.26: If you want a cross-compiler ABI, use a C-style subset

Chapter 2.4 C.47: Define and initialize member variables in the order of member declaration

Chapter 2.5 CP.3: Minimize explicit sharing of writable data

Chapter 2.6 T.120: Use template metaprogramming only when you really need to

Section 3 Stop using that

Chapter 3.1 I.11: Never transfer ownership by a raw pointer (T*) or reference (T&)

Chapter 3.2 I.3: Avoid singletons

Chapter 3.3 C.90: Rely on constructors and assignment operators, not memset and memcpy

Chapter 3.4 ES.50: Don’t cast away const

Chapter 3.5 E.28: Avoid error handling based on global state (e.g. errno)

Chapter 3.6 SF.7: Don’t write using namespace at global scope in a header file

Section 4 Use this new thing properly

Chapter 4.1 F.21: To return multiple “out” values, prefer returning a struct or tuple

Chapter 4.2 Enum.3: Prefer class enums over “plain” enums

Chapter 4.3 ES.5: Keep scopes small

Chapter 4.4 Con.5: Use constexpr for values that can be computed at compile time

Chapter 4.5 T.1: Use templates to raise the level of abstraction of code

Chapter 4.6 T.10: Specify concepts for all template arguments

Section 5 Write code well by default

Chapter 5.1 P.4: Ideally, a program should be statically type safe

Chapter 5.2 P.10: Prefer immutable data to mutable data

Chapter 5.3 I.30: Encapsulate rule violations

Chapter 5.4 ES.22: Don’t declare a variable until you have a value to initialize it with

Chapter 5.5 Per.7: Design to enable optimization

Chapter 5.6 E.6: Use RAII to prevent leaks

Envoi

Afterword

Fair Use Sources


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


beautiful_c_plus_plus_-_30_core_guidelines_for_writing_clean_safe_and_fast_code_table_of_contents.txt · Last modified: 2024/04/28 03:32 (external edit)