1,072
edits
m (→references) |
m (→Namespace) |
||
Line 155: | Line 155: | ||
=== Namespace === | === Namespace === | ||
All code should be in the octave namespace | All code should be in the {{codeline|octave}} namespace or in a namespace below it. | ||
Namespaces should start and stop using the special macros {{codeline|OCTAVE_BEGIN_NAMESPACE(XXX)}} and {{codeline|OCTAVE_END_NAMESPACE(XXX)}}. There is no indentation of code that is placed into namespaces using these macros. | |||
{{Code|namespace | Example | ||
{{Code|Use of namespace macros|<syntaxhighlight lang="cpp"> | |||
OCTAVE_BEGIN_NAMESPACE(octave) | |||
OCTAVE_BEGIN_NAMESPACE(math) | |||
template <typename T> | |||
void | |||
umfpack_report_control (const double *Control); | |||
OCTAVE_END_NAMESPACE(math) | |||
OCTAVE_END_NAMESPACE(octave) | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
{{Code|namespace | If bare namespace directives must be used, as occasionally is required in Qt code, then the code within the namespace should be indented. | ||
// Note indentation and that functions are not defined | |||
{{Code|bare namespace usage|<syntaxhighlight lang="cpp"> | |||
// Note indentation and that functions are not defined as "octave::math::foo:foo" | |||
namespace octave | namespace octave | ||
{ | { | ||
Line 195: | Line 189: | ||
} | } | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
==== Other Guidelines ==== | |||
* Do not use {{codeline|using XXX;}} directives | |||
* Do not declare anything on the {{codeline|std::}} namespace | |||
== Naming == | == Naming == |
edits