From 0f127603282018d4a6a7ab16cbcadd7bfe815c82 Mon Sep 17 00:00:00 2001 From: ArvindReddySheelam Date: Fri, 19 Jul 2024 15:52:13 +0530 Subject: [PATCH 1/4] clarifying case senstivity in include order --- cppguide.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cppguide.html b/cppguide.html index 7c87799ed..b7b6151f8 100644 --- a/cppguide.html +++ b/cppguide.html @@ -399,8 +399,9 @@

Names and Order of Includes

Include headers in the following order: Related header, C system headers, C++ standard library headers, other libraries' headers, your project's -headers.

- +headers.\b +The includes should be ordered alphabetically. This ordering should be case-sensitive, meaningthat uppercase and lowercase letters are considered different

+

All of a project's header files should be listed as descendants of the project's source @@ -6020,4 +6021,4 @@

Windows Code

- \ No newline at end of file + From e6355408e90469273b6d8fb16c759efa9c98f22f Mon Sep 17 00:00:00 2001 From: ArvindReddySheelam Date: Fri, 19 Jul 2024 16:12:17 +0530 Subject: [PATCH 2/4] clarifying case sensitivity in include order --- cppguide.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cppguide.html b/cppguide.html index b7b6151f8..75693aee9 100644 --- a/cppguide.html +++ b/cppguide.html @@ -400,7 +400,8 @@

Names and Order of Includes

C++ standard library headers, other libraries' headers, your project's headers.\b -The includes should be ordered alphabetically. This ordering should be case-sensitive, meaningthat uppercase and lowercase letters are considered different

+i +The includes should be ordered alphabetically. This ordering should be case-sensitive, meaningthat uppercase and lowercase letters are considered to be different

All of a project's header files should be From a164d25b365454775e2b6a37abed83a4a8b75d18 Mon Sep 17 00:00:00 2001 From: ArvindReddySheelam Date: Fri, 19 Jul 2024 16:39:37 +0530 Subject: [PATCH 3/4] clarifying case sensitivity in include oreder --- cppguide.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cppguide.html b/cppguide.html index 75693aee9..273d5d767 100644 --- a/cppguide.html +++ b/cppguide.html @@ -399,10 +399,8 @@

Names and Order of Includes

Include headers in the following order: Related header, C system headers, C++ standard library headers, other libraries' headers, your project's -headers.\b -i -The includes should be ordered alphabetically. This ordering should be case-sensitive, meaningthat uppercase and lowercase letters are considered to be different

- +headers. +The includes should be ordered alphabetically. This ordering should be case-sensitive, meaningthat uppercase and lowercase letters are considered to be different

All of a project's header files should be listed as descendants of the project's source From 0a054fc2b1dfe418783a79cd345b7a966fa66430 Mon Sep 17 00:00:00 2001 From: ArvindReddySheelam Date: Sun, 28 Jul 2024 20:18:26 +0530 Subject: [PATCH 4/4] Clarifying the usage of 'using namespace' directives and 'using' declarationsin the NameSpace Section --- cppguide.html | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/cppguide.html b/cppguide.html index 273d5d767..7fcb1fc55 100644 --- a/cppguide.html +++ b/cppguide.html @@ -498,7 +498,6 @@

Names and Order of Includes

#include <string> #include <vector> - #include "base/basictypes.h" #include "foo/server/bar.h" #include "third_party/absl/flags/flag.h" @@ -526,12 +525,34 @@

Namespaces

With few exceptions, place code in a namespace. Namespaces should have unique names based on the project name, and possibly -its path. Do not use using-directives (e.g., -using namespace foo). Do not use +its path. Do not use using-namespacedirectives (e.g., +using namespace foo;). Do not use inline namespaces. For unnamed namespaces, see Internal Linkage. +

+

Using Declaration:

+

Using declaration are allowed and can be used to refer to specific symbol from a namespace. For example

+
Using ::foo::bar;
+ +

Additional Note With an Example:

+ +
Using NameSpace Directives:
+

Using namespace directives brings the all the specified symbols/built-in-types from the specified NameSpace into the whatever current scope you are in, which leads to naming conflict and confusion(ambiguity). Therefore, they should be avoided.

+ +

Example:

+
//Avoid This Practice: 
+using namespace std;
+std::cout,std::endl or somethinglike std::string st = "Hello";
+ +
Using Declarations:
+

Using Declarations allow you to bring namespace into current scope. This practice helps in avoiding the ambiguity(confusion) and which eventually keeps the code clear and manageable.

+

Example to Use:

+
//Accepted 
+  using namespace std;
+  cout,abs() or string str = "Hello,World";
+

Namespaces subdivide the global scope into distinct, named scopes, and so are useful for preventing name collisions in the global scope.