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
pull/135/head
Jesse Vincent 8 years ago
parent 9129b8e9a7
commit 502bc0b59f
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -608,9 +608,9 @@ namespace mynamespace {
// All declarations are within the namespace scope. // All declarations are within the namespace scope.
// Notice the lack of indentation. // Notice the lack of indentation.
class MyClass { class MyClass {
public: public:
... ...
void Foo(); void Foo();
}; };
} // namespace mynamespace } // namespace mynamespace
@ -770,9 +770,9 @@ void Function2();
<p>instead of</p> <p>instead of</p>
<pre class="badcode">namespace myproject { <pre class="badcode">namespace myproject {
class FooBar { class FooBar {
public: public:
static void Function1(); static void Function1();
static void Function2(); static void Function2();
}; };
} // namespace myproject } // namespace myproject
</pre> </pre>
@ -1199,12 +1199,12 @@ other code, and to document that your class is copyable and/or cheaply movable
if that's an API guarantee.</p> if that's an API guarantee.</p>
<pre class="badcode">class Foo { <pre class="badcode">class Foo {
public: public:
Foo(Foo&amp;&amp; other) : field_(other.field) {} Foo(Foo&amp;&amp; other) : field_(other.field) {}
// Bad, defines only move constructor, but not operator=. // Bad, defines only move constructor, but not operator=.
private: private:
Field field_; Field field_;
}; };
</pre> </pre>
@ -1788,9 +1788,9 @@ string&amp;</code> and overload it with another that
takes <code>const char*</code>.</p> takes <code>const char*</code>.</p>
<pre>class MyClass { <pre>class MyClass {
public: public:
void Analyze(const string &amp;text); void Analyze(const string &amp;text);
void Analyze(const char *text, size_t textlen); void Analyze(const char *text, size_t textlen);
}; };
</pre> </pre>
</div> </div>
@ -3118,10 +3118,10 @@ For example, avoid patterns like:</p>
<pre class="badcode">class WOMBAT_TYPE(Foo) { <pre class="badcode">class WOMBAT_TYPE(Foo) {
// ... // ...
public: public:
EXPAND_PUBLIC_WOMBAT_API(Foo) EXPAND_PUBLIC_WOMBAT_API(Foo)
EXPAND_WOMBAT_COMPARISONS(Foo, ==, &lt;) EXPAND_WOMBAT_COMPARISONS(Foo, ==, &lt;)
}; };
</pre> </pre>
@ -3384,16 +3384,16 @@ that take <code>std::initializer_list&lt;T&gt;</code>, which is automatically
created from <i>braced-init-list</i>:</p> created from <i>braced-init-list</i>:</p>
<pre>class MyType { <pre>class MyType {
public: public:
// std::initializer_list references the underlying init list. // std::initializer_list references the underlying init list.
// It should be passed by value. // It should be passed by value.
MyType(std::initializer_list&lt;int&gt; init_list) { MyType(std::initializer_list&lt;int&gt; init_list) {
for (int i : init_list) append(i); for (int i : init_list) append(i);
} }
MyType&amp; operator=(std::initializer_list&lt;int&gt; init_list) { MyType&amp; operator=(std::initializer_list&lt;int&gt; init_list) {
clear(); clear();
for (int i : init_list) append(i); for (int i : init_list) append(i);
} }
}; };
MyType m{2, 3, 5, 7}; MyType m{2, 3, 5, 7};
</pre> </pre>
@ -3406,9 +3406,9 @@ constructors of data types, even if they do not have
// Calls ordinary constructor as long as MyOtherType has no // Calls ordinary constructor as long as MyOtherType has no
// std::initializer_list constructor. // std::initializer_list constructor.
class MyOtherType { class MyOtherType {
public: public:
explicit MyOtherType(string); explicit MyOtherType(string);
MyOtherType(int, string); MyOtherType(int, string);
}; };
MyOtherType m = {1, "b"}; MyOtherType m = {1, "b"};
// If the constructor is explicit, you can't use the "= {}" form. // 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
<p>Unused parameters that are obvious from context may be omitted:</p> <p>Unused parameters that are obvious from context may be omitted:</p>
<pre>class Foo { <pre>class Foo {
public: public:
Foo(Foo&amp;&amp;); Foo(Foo&amp;&amp;);
Foo(const Foo&amp;); Foo(const Foo&amp;);
Foo&amp; operator=(Foo&amp;&amp;); Foo&amp; operator=(Foo&amp;&amp;);
Foo&amp; operator=(const Foo&amp;); Foo&amp; operator=(const Foo&amp;);
}; };
</pre> </pre>
@ -5221,13 +5221,13 @@ not fit on a single line as you would wrap arguments in a
name in the function definition:</p> name in the function definition:</p>
<pre>class Shape { <pre>class Shape {
public: public:
virtual void Rotate(double radians) = 0; virtual void Rotate(double radians) = 0;
}; };
class Circle : public Shape { class Circle : public Shape {
public: public:
void Rotate(double radians) override; void Rotate(double radians) override;
}; };
void Circle::Rotate(double /*radians*/) {} void Circle::Rotate(double /*radians*/) {}
@ -5782,7 +5782,7 @@ beginning of the line.</p>
<div class="summary"> <div class="summary">
<p>Sections in <code>public</code>, <code>protected</code> and <p>Sections in <code>public</code>, <code>protected</code> and
<code>private</code> order, each indented one space.</p> <code>private</code> order, each indented two spaces.</p>
</div> </div>
<div class="stylebody"> <div class="stylebody">
@ -5793,23 +5793,23 @@ Comments</a> for a discussion of what comments are
needed) is:</p> needed) is:</p>
<pre>class MyClass : public OtherClass { <pre>class MyClass : public OtherClass {
public: // Note the 1 space indent! public: // Note the 1 space indent!
MyClass(); // Regular 2 space indent. MyClass(); // Regular 2 space indent.
explicit MyClass(int var); explicit MyClass(int var);
~MyClass() {} ~MyClass() {}
void SomeFunction(); void SomeFunction();
void SomeFunctionThatDoesNothing() { void SomeFunctionThatDoesNothing() {
} }
void set_some_var(int var) { some_var_ = var; } void set_some_var(int var) { some_var_ = var; }
int some_var() const { return some_var_; } int some_var() const { return some_var_; }
private: private:
bool SomeInternalFunction(); bool SomeInternalFunction();
int some_var_; int some_var_;
int some_other_var_; int some_other_var_;
}; };
</pre> </pre>
@ -5821,7 +5821,7 @@ needed) is:</p>
<li>The <code>public:</code>, <code>protected:</code>, <li>The <code>public:</code>, <code>protected:</code>,
and <code>private:</code> keywords should be indented and <code>private:</code> keywords should be indented
one space.</li> two spaces.</li>
<li>Except for the first instance, these keywords <li>Except for the first instance, these keywords
should be preceded by a blank line. This rule is 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. // Spaces around the colon in inheritance and initializer lists.
class Foo : public Bar { class Foo : public Bar {
public: public:
// For inline function implementations, put spaces between the braces // For inline function implementations, put spaces between the braces
// and the implementation itself. // and the implementation itself.
Foo(int b) : Bar(), baz_(b) {} // No spaces inside empty braces. Foo(int b) : Bar(), baz_(b) {} // No spaces inside empty braces.
void Reset() { baz_ = 0; } // Spaces separating braces from implementation. void Reset() { baz_ = 0; } // Spaces separating braces from implementation.
... ...
</pre> </pre>
<p>Adding trailing whitespace can cause extra work for <p>Adding trailing whitespace can cause extra work for

Loading…
Cancel
Save