638
edits
(→Namespaces: Update rules per IRC conversation.) |
No edit summary |
||
| Line 344: | Line 344: | ||
Initializer lists can break in one of two ways. The first may be preferable when constructors take few arguments: | Initializer lists can break in one of two ways. The first may be preferable when constructors take few arguments: | ||
class Ninja : public WeaponWeilder, public Camouflagible, | class Ninja : public WeaponWeilder, public Camouflagible, | ||
public Assassinatable, public ShapeShiftable | public Assassinatable, public ShapeShiftable | ||
| Line 352: | Line 353: | ||
ShapeShiftable(MPCost(512)) {} | ShapeShiftable(MPCost(512)) {} | ||
} | } | ||
The other permitted style mitigates longer-identifiers-squishing-text-against-the-right-side-of-the-screen-syndrome by using a half-indented colon: | The other permitted style mitigates longer-identifiers-squishing-text-against-the-right-side-of-the-screen-syndrome by using a half-indented colon: | ||
class Ninja | class Ninja | ||
: public WeaponWeilder, public Camouflagible, public Assassinatable, | : public WeaponWeilder, public Camouflagible, public Assassinatable, | ||
| Line 367: | Line 370: | ||
If the method in question fits on one line and is branch free, do a one liner: | If the method in question fits on one line and is branch free, do a one liner: | ||
class Eater | class Eater | ||
{ | { | ||
void eat(Eaten &other) { other.setConsumed(); } | void eat(Eaten &other) { other.setConsumed(); } | ||
}; | }; | ||
If it's too long, put the type, declarator including formals (unless they overflow), and left brace all on the first line: | If it's too long, put the type, declarator including formals (unless they overflow), and left brace all on the first line: | ||
class Eater | class Eater | ||
{ | { | ||
| Line 380: | Line 386: | ||
} | } | ||
}; | }; | ||
For out-of-line inlines (when the definitions are too unwieldy to place in the class definition) use the inline keyword as an indicator that there's an out-of-line inline definition: | For out-of-line inlines (when the definitions are too unwieldy to place in the class definition) use the inline keyword as an indicator that there's an out-of-line inline definition: | ||
class SpaceGoo | class SpaceGoo | ||
{ | { | ||
| Line 391: | Line 399: | ||
/* ... */ | /* ... */ | ||
} | } | ||
== References == | == References == | ||
edits