From 502bc0b59fc158f27b2608d32b844520e9a8a61d Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 3 Jun 2017 00:51:47 -0700 Subject: [PATCH] switch from one space indent to two space indent before public: and private: This matches what astyle does, so it's one less thing to stress about --- doc/CODING_STYLE.html | 132 +++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/doc/CODING_STYLE.html b/doc/CODING_STYLE.html index c2bb4616..14362fcd 100644 --- a/doc/CODING_STYLE.html +++ b/doc/CODING_STYLE.html @@ -608,9 +608,9 @@ namespace mynamespace { // All declarations are within the namespace scope. // Notice the lack of indentation. class MyClass { - public: - ... - void Foo(); + public: + ... + void Foo(); }; } // namespace mynamespace @@ -770,9 +770,9 @@ void Function2();

instead of

namespace myproject {
 class FooBar {
- public:
-  static void Function1();
-  static void Function2();
+  public:
+   static void Function1();
+   static void Function2();
 };
 }  // namespace myproject
 
@@ -1199,12 +1199,12 @@ other code, and to document that your class is copyable and/or cheaply movable if that's an API guarantee.

class Foo {
- public:
-  Foo(Foo&& other) : field_(other.field) {}
-  // Bad, defines only move constructor, but not operator=.
-
- private:
-  Field field_;
+  public:
+   Foo(Foo&& other) : field_(other.field) {}
+   // Bad, defines only move constructor, but not operator=.
+ 
+  private:
+   Field field_;
 };
 
@@ -1788,9 +1788,9 @@ string& and overload it with another that takes const char*.

class MyClass {
- public:
-  void Analyze(const string &text);
-  void Analyze(const char *text, size_t textlen);
+  public:
+   void Analyze(const string &text);
+   void Analyze(const char *text, size_t textlen);
 };
 
@@ -3118,10 +3118,10 @@ For example, avoid patterns like:

class WOMBAT_TYPE(Foo) {
   // ...
 
- public:
-  EXPAND_PUBLIC_WOMBAT_API(Foo)
-
-  EXPAND_WOMBAT_COMPARISONS(Foo, ==, <)
+  public:
+   EXPAND_PUBLIC_WOMBAT_API(Foo)
+ 
+   EXPAND_WOMBAT_COMPARISONS(Foo, ==, <)
 };
 
@@ -3384,16 +3384,16 @@ that take std::initializer_list<T>, which is automatically created from braced-init-list:

class MyType {
- public:
-  // std::initializer_list references the underlying init list.
-  // It should be passed by value.
-  MyType(std::initializer_list<int> init_list) {
-    for (int i : init_list) append(i);
-  }
-  MyType& operator=(std::initializer_list<int> init_list) {
-    clear();
-    for (int i : init_list) append(i);
-  }
+  public:
+   // std::initializer_list references the underlying init list.
+   // It should be passed by value.
+   MyType(std::initializer_list<int> init_list) {
+     for (int i : init_list) append(i);
+   }
+   MyType& operator=(std::initializer_list<int> init_list) {
+     clear();
+     for (int i : init_list) append(i);
+   }
 };
 MyType m{2, 3, 5, 7};
 
@@ -3406,9 +3406,9 @@ constructors of data types, even if they do not have // Calls ordinary constructor as long as MyOtherType has no // std::initializer_list constructor. class MyOtherType { - public: - explicit MyOtherType(string); - MyOtherType(int, string); + public: + explicit MyOtherType(string); + MyOtherType(int, string); }; MyOtherType m = {1, "b"}; // If the constructor is explicit, you can't use the "= {}" form. @@ -5209,11 +5209,11 @@ not fit on a single line as you would wrap arguments in a

Unused parameters that are obvious from context may be omitted:

class Foo {
- public:
-  Foo(Foo&&);
-  Foo(const Foo&);
-  Foo& operator=(Foo&&);
-  Foo& operator=(const Foo&);
+  public:
+   Foo(Foo&&);
+   Foo(const Foo&);
+   Foo& operator=(Foo&&);
+   Foo& operator=(const Foo&);
 };
 
@@ -5221,13 +5221,13 @@ not fit on a single line as you would wrap arguments in a name in the function definition:

class Shape {
- public:
-  virtual void Rotate(double radians) = 0;
+  public:
+   virtual void Rotate(double radians) = 0;
 };
 
 class Circle : public Shape {
- public:
-  void Rotate(double radians) override;
+  public:
+   void Rotate(double radians) override;
 };
 
 void Circle::Rotate(double /*radians*/) {}
@@ -5782,7 +5782,7 @@ beginning of the line.

Sections in public, protected and -private order, each indented one space.

+private order, each indented two spaces.

@@ -5793,23 +5793,23 @@ Comments for a discussion of what comments are needed) is:

class MyClass : public OtherClass {
- public:      // Note the 1 space indent!
-  MyClass();  // Regular 2 space indent.
-  explicit MyClass(int var);
-  ~MyClass() {}
-
-  void SomeFunction();
-  void SomeFunctionThatDoesNothing() {
-  }
-
-  void set_some_var(int var) { some_var_ = var; }
-  int some_var() const { return some_var_; }
-
- private:
-  bool SomeInternalFunction();
-
-  int some_var_;
-  int some_other_var_;
+  public:      // Note the 1 space indent!
+   MyClass();  // Regular 2 space indent.
+   explicit MyClass(int var);
+   ~MyClass() {}
+ 
+   void SomeFunction();
+   void SomeFunctionThatDoesNothing() {
+   }
+ 
+   void set_some_var(int var) { some_var_ = var; }
+   int some_var() const { return some_var_; }
+ 
+  private:
+   bool SomeInternalFunction();
+ 
+   int some_var_;
+   int some_other_var_;
 };
 
@@ -5821,7 +5821,7 @@ needed) is:

  • The public:, protected:, and private: keywords should be indented - one space.
  • + two spaces.
  • Except for the first instance, these keywords should be preceded by a blank line. This rule is @@ -5942,12 +5942,12 @@ int x[] = {0}; // Spaces around the colon in inheritance and initializer lists. class Foo : public Bar { - public: - // For inline function implementations, put spaces between the braces - // and the implementation itself. - Foo(int b) : Bar(), baz_(b) {} // No spaces inside empty braces. - void Reset() { baz_ = 0; } // Spaces separating braces from implementation. - ... + public: + // For inline function implementations, put spaces between the braces + // and the implementation itself. + Foo(int b) : Bar(), baz_(b) {} // No spaces inside empty braces. + void Reset() { baz_ = 0; } // Spaces separating braces from implementation. + ...
  • Adding trailing whitespace can cause extra work for