From 89c0f481941dfe22c77281f916865f00f8807810 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 19 Apr 2018 10:36:04 +0200 Subject: Clarify namespaces in coding style. --- CODING_STYLE.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'CODING_STYLE.md') diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 3244466b..f36503d0 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -49,21 +49,28 @@ cout << "some very long string that contains completely irrelevant text that tal ## 1. Namespaces 1. No `using namespace` declarations in header files. -2. All symbols should be declared in a namespace except for final applications. -3. Use anonymous namespaces for helpers whose scope is a cpp file only. -4. Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore. +2. Use `using namespace std;` in cpp files, but avoid importing namespaces from boost and others. +3. All symbols should be declared in a namespace except for final applications. +4. Use anonymous namespaces for helpers whose scope is a cpp file only. +5. Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore. -Yes: +Only in the header: ```cpp #include +namespace myNamespace +{ std::tuple meanAndSigma(std::vector const& _v); +} ``` -No: +Only in the cpp file: ```cpp #include using namespace std; -tuple meanAndSigma(vector const& _v); +tuple myNamespace::meanAndSigma(vector const& _v) +{ + // ... +} ``` ## 2. Preprocessor -- cgit v1.2.3