Help:Manual of style

Revision as of 02:46, 14 October 2012 by P12 (Talk | contribs)

This page contains a design guideline that helps to follow consistent style and formatting in this wiki. Note, that the guideline list is neither final nor complete, i.e. new guidelines can be added and the current changed if there's benefit to do that.


Navigation bars

Navigation bars (navbars) are created using {{navbar}} template.

{{mark c++11}} should be used in navbars instead of {{mark since c++11}} to conserve space.

Code formatting


Names are capitalized in the same way as in most of the C++ standard. The documentation of the standard components should follow the following style:

  • function parameters use small_caps style
  • template parameters use CamelCase style

In examles and other documentation, the following additional guidelines apply:

  • custom class names use CamelCase style
  • variable names use small_caps style
  • macro and constant names use ALL_CAPS style

Spacing and indentation

  • K&R indentation style is used (see K&R TBS).
  • Standard constructs, i.e. for, while, if, etc have a space between identifier and opening parentheses, e.g. for (...).
  • There is no space between function name and the parentheses, as well as between the parentheses and the content between them, e.g. fun(...).
  • There is no space between template name and < symbol, as well as between < and > symbols and the template parameters, e.g. tmp<...>.
  • Multiple function or template parameters are separated by space after the comma.
  • There is no space between reference and pointer (& and *) modifiers and the type name (e.g. int& b).
  • If the parameters of a function span several lines, the indentation of all parameters matches the opening parenthesis. The same goes for template parameters.

For example:

#include <vector>
std::vector<int, MyAllocator> v;
int complex_function(int long_param_name,
                     int& another_param_name);
int main(int argc, char** argv)
    if (argc == 2) {

Not all of these rules apply for the detailed feature declarations (those going into {{ddcl list ***}} template), since extra readability is needed. The exceptions include:

  • There is space between the < and > symbols and template parameters for function templates.
  • Class templates have their parameters laid out through several lines.
  • For function parameters, that are templates, there are no spaces between the < and > symbols and the template parameters. Also, there is no space after the comma separating the template parameters.

For example:

Template:ddcl list begin <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td class="t-dcl-nopad">
template <

    class TemplateParam,
    class TemplateParam2

> class TemplateClass;

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class TemplateParam, class TemplateParam2 >

int function_template( MyTemplate<T,Param> my_template_param,

                       int* other_param );

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end