659
edits
Carandraug (talk | contribs) (→Other C++ features: add section for auto) |
Carandraug (talk | contribs) (→Formatting: add section about namespace) |
||
Line 20: | Line 20: | ||
readability in the widest range of environments. This is inherited from | readability in the widest range of environments. This is inherited from | ||
the [https://www.gnu.org/prep/standards/standards.html#Formatting GNU Coding Standards]. | the [https://www.gnu.org/prep/standards/standards.html#Formatting GNU Coding Standards]. | ||
=== Namespace === | |||
All code should be in the octave namespace (this is an ongoing project, we | |||
are still moving existing classes into namespaces but all new classes | |||
should go somewhere into octave::). There is 1 extra level for namespaces | |||
inside octave to be used with care, we don't want too many namespaces. | |||
Ask before creating a new namespace. | |||
* Do not indent namespace; | |||
* Define namespace on the .cc files; | |||
* Do not use "using X" directives; | |||
* Do not declare anything on the std namespace; | |||
{{Code|namespace style on a .h file|<pre> | |||
// Note lack of indentation | |||
namespace octave | |||
{ | |||
namespace math | |||
{ | |||
class foo | |||
{ | |||
public: | |||
foo (...); | |||
}; | |||
} | |||
} | |||
</pre>}} | |||
{{Code|namespace style on a .cc file|<pre> | |||
// Note lack of indentation, and that functions are not defined | |||
// as "octave::math::foo:foo" | |||
namespace octave | |||
{ | |||
namespace math | |||
{ | |||
foo::foo (...) | |||
{ | |||
...; | |||
} | |||
}; | |||
} | |||
} | |||
</pre>}} | |||
== Header Files == | == Header Files == |