|
|
## Useful links
|
|
|
|
|
|
- [Cpp guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#p1-express-ideas-directly-in-code)
|
|
|
- [CppCon](https://www.youtube.com/@CppCon) Interesting talks for advanced use of Cpp
|
|
|
|
|
|
## Guidelines
|
|
|
This page presents some guidelines for modern C++: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
|
|
|
|
|
|
Here are some interesting key points (don't hesitate to add them):
|
|
|
|
|
|
### P. Philosophy
|
|
|
|
|
|
- [**P1.Express ideas directly in code**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#p1-express-ideas-directly-in-code) Code with clear intent (meaningful variable name, structure, ...) is better than comments (because sometimes people don't read comment)
|
|
|
- [**P.6: What cannot be checked at compile time should be checkable at run time**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#p6-what-cannot-be-checked-at-compile-time-should-be-checkable-at-run-time)
|
|
|
- [**P8 Don’t leak any resources**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#p8-dont-leak-any-resources) Prefer RAII when possible.
|
|
|
|
|
|
### I. Interfaces
|
|
|
|
|
|
- [**I.2: Avoid non-const global variables**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i2-avoid-non-const-global-variables)
|
|
|
- [**I.3: Avoid singletons**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i3-avoid-singletons)
|
|
|
- [**I.10: Use exceptions to signal a failure to perform a required task**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i10-use-exceptions-to-signal-a-failure-to-perform-a-required-task)
|
|
|
- [**I.11: Never transfer ownership by a raw pointer (T\*) or reference (T&)**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i11-never-transfer-ownership-by-a-raw-pointer-t-or-reference-t)
|
|
|
- [**I.13: Do not pass an array as a single pointer**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i13-do-not-pass-an-array-as-a-single-pointer)
|
|
|
- [**I.23: Keep the number of function arguments low**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i23-keep-the-number-of-function-arguments-low)
|
|
|
- [**I.25: Prefer empty abstract classes as interfaces to class hierarchies**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#i25-prefer-empty-abstract-classes-as-interfaces-to-class-hierarchies)
|
|
|
|
|
|
### F. Functions
|
|
|
|
|
|
- [**F.3: Keep functions short and simple**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f3-keep-functions-short-and-simple)
|
|
|
- [**F.7: For general use, take T\* or T& arguments rather than smart pointers**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f7-for-general-use-take-t-or-t-arguments-rather-than-smart-pointers)
|
|
|
- [**F.11: Use an unnamed lambda if you need a simple function object in one place only**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f11-use-an-unnamed-lambda-if-you-need-a-simple-function-object-in-one-place-only)
|
|
|
- [**F.21: To return multiple “out” values, prefer returning a struct or tuple**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f21-to-return-multiple-out-values-prefer-returning-a-struct-or-tuple)
|
|
|
- [**F.51: Where there is a choice, prefer default arguments over overloading**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f51-where-there-is-a-choice-prefer-default-arguments-over-overloading)
|
|
|
- [**F.56: Avoid unnecessary condition nesting**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f56-avoid-unnecessary-condition-nesting)
|
|
|
|
|
|
### C. Classes
|
|
|
|
|
|
- [**C.2: Use class if the class has an invariant; use struct if the data members can vary independently**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently)
|
|
|
- [**C.5: Place helper functions in the same namespace as the class they support**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c5-place-helper-functions-in-the-same-namespace-as-the-class-they-support)-
|
|
|
- [**C.9: Minimize exposure of members**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c9-minimize-exposure-of-members)
|
|
|
- [**C.30: Define a destructor if a class needs an explicit action at object destruction**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c30-define-a-destructor-if-a-class-needs-an-explicit-action-at-object-destruction)
|
|
|
- [**C.35: A base class destructor should be either public and virtual, or protected and non-virtual**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-non-virtual)
|
|
|
- [**C.36: A destructor must not fail**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c36-a-destructor-must-not-fail)
|
|
|
- [**C.37: Make destructors noexcept**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c37-make-destructors-noexcept)
|
|
|
- [**C.41: A constructor should create a fully initialized object**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c41-a-constructor-should-create-a-fully-initialized-object)
|
|
|
- [**C.42: If a constructor cannot construct a valid object, throw an exception**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c42-if-a-constructor-cannot-construct-a-valid-object-throw-an-exception)
|
|
|
- [**C.45: Don’t define a default constructor that only initializes data members; use in-class member initializers instead**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c45-dont-define-a-default-constructor-that-only-initializes-data-members-use-in-class-member-initializers-instead)
|
|
|
- [**C.48: Prefer in-class initializers to member initializers in constructors for constant initializers**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers)
|
|
|
- [**C.49: Prefer initialization to assignment in constructors**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c49-prefer-initialization-to-assignment-in-constructors)
|
|
|
- [**C.67: A polymorphic class should suppress public copy/move**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c67-a-polymorphic-class-should-suppress-public-copymove)
|
|
|
- [**C.131: Avoid trivial getters and setters**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c131-avoid-trivial-getters-and-setters) |
|
|
\ No newline at end of file |