X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=doc%2FCodingStyle;h=b537f19b3bab5182612860666d571527f9217112;hp=b352710414545d00f52bd8b1a9a29ee668e3b0d0;hb=69815a366be5ca81185386d94268d7e7dcce94e3;hpb=ce9cbdcfa48cf413e0191fcf03a477d659f810b4 diff --git a/doc/CodingStyle b/doc/CodingStyle index b3527104..b537f19b 100644 --- a/doc/CodingStyle +++ b/doc/CodingStyle @@ -27,7 +27,7 @@ please try to follow these rules. It will make our (and your) lives easier. :-) ---------------------- Any code in GiNaC should comply to the C++ standard, as defined by ISO/IEC -14882:1998(E). Don't use compiler-specific language extensions unless they +14882:2011(E). Don't use compiler-specific language extensions unless they are surrounded by appropriate "#ifdef"s, and you also provide a compliant version of the code in question for other compilers. @@ -63,8 +63,7 @@ same column on the screen, to make it look more tidy and clear. Here is an example that features both indentation and alignment: -class person -{ +class person { string name; // person's full name int age; // age in years }; @@ -94,8 +93,7 @@ that we had done both indentation and alignment with Tabs, with a tab-size of 8: |-------|-------|-------|-------|-------|-------|------- <- tab stops -class person -{ +class person { ::::::::string name;::::// person's full name ::::::::int age;::::::::// age in years }; @@ -103,8 +101,7 @@ class person Now somebody who prefers a tab-size of 4 looks at the code: |---|---|---|---|---|---|---|---|---|---|---|---|---|--- <- tab stops -class person -{ +class person { ::::string name;::::// person's full name ::::int age;::::// age in years }; @@ -132,8 +129,7 @@ This is how our class definition should be entered using this scheme (remember, ':' are Tabs, '.' are Spaces): |-------|-------|-------|-------|-------|-------|------- <- tab stops -class person -{ +class person { ::::::::string name;..// person's full name ::::::::int age;......// age in years }; @@ -142,8 +138,7 @@ class person tab-size, and it still looks good: |---|---|---|---|---|---|---|---|---|---|---|---|---|--- <- tab stops -class person -{ +class person { ::::string name;..// person's full name ::::int age;......// age in years }; @@ -213,12 +208,10 @@ after (or before, in the case of postfix '++' and '--') unary operators: x = -(y + z) / 2; There are no spaces around the '<' and '>' used to designate template -parameters. Unfortunately, a design flaw in C++ requires putting a space -between two consecutive closing '>'s. We suggest that in this case you also -put a space after the opening '<': +parameters: vector vi; - vector< list > vli; + vector> vli; '*' and '&' in the declaration of pointer-to and reference-to variables have a space before, but not after them: @@ -238,7 +231,7 @@ whitespace. One word: K&R, also known as "One True Brace Style", suitably extended for C++. The opening brace goes at the end of the line, except for function -bodies and classes. Really short functions can be written in one single line. +bodies. Really short functions can be written in one single line. if (a == b) { // do something @@ -284,8 +277,7 @@ bodies and classes. Really short functions can be written in one single line. // catchall } - class foo - { + class foo { public: foo(int i) : x(i) {