@@ -7,10 +7,11 @@ Use clang-format tool to format your changes, see [CONTRIBUTING](CONTRIBUTING.md
77
88## Namespaces
99
10- 1 . No " using namespace" declarations in header files.
10+ 1 . No ` using namespace ` declarations in header files.
11112 . All symbols should be declared in a namespace except for final applications.
12123 . Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore.
1313
14+ ``` cpp
1415 // WRONG:
1516 #include < cassert>
1617 using namespace std ;
@@ -19,15 +20,15 @@ Use clang-format tool to format your changes, see [CONTRIBUTING](CONTRIBUTING.md
1920 // CORRECT:
2021 #include <cassert>
2122 std::tuple<float, float> meanAndSigma(std::vector<float> const& _v);
22-
23+ ```
2324
2425## Preprocessor
2526
26271. File comment is always at top, and includes:
2728 - Copyright.
2829 - License.
2930
30- 2 . Never use #ifdef/ #define/ #endif file guards. Prefer #pragma once as first line below file comment.
31+ 2. Never use ` #ifdef`/` #define`/` #endif` file guards. Prefer #pragma once as first line below file comment.
31323. Prefer static const variable to value macros.
32334. Prefer inline constexpr functions to function macros.
3334
@@ -82,6 +83,7 @@ Prefer exception to bool/int return type.
82838. Don't pass bools: prefer enumerations instead.
83849. Prefer enum class to straight enum.
8485
86+ ```cpp
8587 // WRONG:
8688 const double d = 0;
8789 int i, j;
@@ -103,12 +105,12 @@ Prefer exception to bool/int return type.
103105 std::tuple<float, float> meanAndSigma(std::vector<float> const& _v, Accuracy _a);
104106 auto x = dynamic_cast<Derived*>(base);
105107 for (auto i = x.begin(); i != x.end(); ++i) {}
106-
108+ ```
107109
108110## Structs & classes
109111
1101121 . Structs to be used when all members public and no virtual functions.
111- - In this case, members should be named naturally and not prefixed with 'm _ '
113+ - In this case, members should be named naturally and not prefixed with ` m_ `
1121142 . Classes to be used in all other circumstances.
113115
114116
@@ -118,28 +120,28 @@ Prefer exception to bool/int return type.
1181201 . One member per line only.
1191212 . Private, non-static, non-const fields prefixed with m_ .
1201223 . Avoid public fields, except in structs.
121- 4 . Use override, final and const as much as possible.
123+ 4 . Use ` override ` , ` final ` and ` const ` as much as possible.
1221245 . No implementations with the class declaration, except:
123125 - template or force-inline method (though prefer implementation at bottom of header file).
124126 - one-line implementation (in which case include it in same line as declaration).
125- 6 . For a property ' foo'
126- - Member: m_foo;
127- - Getter: foo(); also: for booleans, isFoo()
128- - Setter: setFoo();
127+ 6 . For a property ` foo `
128+ - Member: ` m_foo ` ;
129+ - Getter: ` foo() ` ; also: for booleans, ` isFoo() `
130+ - Setter: ` setFoo() ` ;
129131
130132
131133## Naming
132134
1331351 . Collection conventions:
134- - ~ s means ` std::vector ` e.g. ` using MyTypes = std::vector<MyType> `
135- - ~ Set means ` std::set ` e.g. ` using MyTypeSet = std::set<MyType> `
136- - ~ Hash means ` std::unordered_set ` e.g. ` using MyTypeHash = std::unordered_set<MyType> `
136+ - ` ...s ` means ` std::vector ` e.g. ` using MyTypes = std::vector<MyType> `
137+ - ` -... Set` means ` std::set ` e.g. ` using MyTypeSet = std::set<MyType> `
138+ - ` ... Hash` means ` std::unordered_set ` e.g. ` using MyTypeHash = std::unordered_set<MyType> `
1371392 . Class conventions:
138- - ~ Face means the interface of some shared concept. (e.g. FooFace might be a pure virtual class.)
140+ - ` ... Face` means the interface of some shared concept. (e.g. ` FooFace ` might be a pure virtual class.)
1391413 . Avoid unpronounceable names:
140142 - If you need to shorten a name favour a pronouncable slice of the original to a scattered set of consonants.
141- - e.g. Manager shortens to Man rather than Mgr.
142- 4 . Avoid prefixes of initials (e.g. DON'T use IMyInterface, CMyImplementation)
143+ - e.g. ` Manager ` shortens to ` Man ` rather than ` Mgr ` .
144+ 4 . Avoid prefixes of initials (e.g. DON'T use ` IMyInterface ` , ` CMyImplementation ` )
1431455 . Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments.
144146 - A dictionary and thesaurus are your friends.
145147 - Spell correctly.
@@ -156,7 +158,10 @@ Prefer exception to bool/int return type.
1561582 . Generally avoid shortening a standard form that already includes all important information:
157159 - e.g. stick to ` shared_ptr<X> ` rather than shortening to ` ptr<X> ` .
1581603 . Where there are exceptions to this (due to excessive use and clear meaning), note the change prominently and use it consistently.
159- - e.g. ` using Guard = std::lock_guard<std::mutex>; ///< Guard is used throughout the codebase since it's clear in meaning and used commonly. `
161+ - e.g.
162+ ``` cpp
163+ using Guard = std::lock_guard<std::mutex>; // /< Guard is used throughout the codebase since it's clear in meaning and used commonly.
164+ ```
1601654 . In general expressions should be roughly as important/semantically meaningful as the space they occupy.
161166
162167
0 commit comments