Skip to content

Code style: Do not indent namespace #2917

Open
@glebm

Description

@glebm

Indenting the contents of namespace { ... } is rather uncommon.
Can we stop doing this in all new code?

Examples:

GCC Coding Conventions, https://gcc.gnu.org/codingconventions.html#Namespace_Form:

Definitions within the body of a namespace are not indented.

LLVM Coding Standards, https://llvm.org/docs/CodingStandards.html#namespace-indentation:

In general, we strive to reduce indentation wherever possible. [...] To facilitate this and avoid some insanely deep nesting on occasion, don’t indent namespaces.

Google C++ Style Guide, https://google.github.io/styleguide/cppguide.html#Namespace_Formatting:

The contents of namespaces are not indented.


On a more general note, can we simply configure clang-format and use it for all the code to get consistent formatting?

Humans are pretty bad at consistent formatting. Currently the formatting is all over the place, making code hard to read. Using clang-format will free us from having to worry about formatting at all.

We can use the Google C++ clang-format style (which IMO is pretty good).
We can configure clang-format and run it on all existing code, now that there are no huge outstanding PRs.

@mgreter @xzyfer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions