Merge pull request #287 from tkruse/space-4

Code indent 4 spaces instead of tabs
This commit is contained in:
Gabriel Dos Reis
2015-10-05 04:56:29 -07:00

View File

@@ -744,6 +744,7 @@ Excess checking can be costly.
There are cases where checking early is dumb because you may not ever need the value, or may only need part of the value that is more easily checked than the whole. There are cases where checking early is dumb because you may not ever need the value, or may only need part of the value that is more easily checked than the whole.
class Jet { // Physics says: e*e < x*x + y*y + z*z class Jet { // Physics says: e*e < x*x + y*y + z*z
float fx, fy, fz, fe; float fx, fy, fz, fe;
public: public:
Jet(float x, float y, float z, float e) Jet(float x, float y, float z, float e)
@@ -1006,7 +1007,8 @@ Singletons are basically complicated global objects in disguise.
##### Example ##### Example
class Singleton { class Singleton {
// ... lots of stuff to ensure that only one Singleton object is created, that it is initialized properly, etc. // ... lots of stuff to ensure that only one Singleton object is created,
// that it is initialized properly, etc.
}; };
There are many variants of the singleton idea. There are many variants of the singleton idea.
@@ -1906,7 +1908,6 @@ We can refactor:
double simpleFunc(double val, int flag1, int flag2) double simpleFunc(double val, int flag1, int flag2)
// simpleFunc: takes a value and calculates the expected ASIC output, given the two mode flags. // simpleFunc: takes a value and calculates the expected ASIC output, given the two mode flags.
{ {
if (flag1 > 0) if (flag1 > 0)
return func1_muon(val, flag2); return func1_muon(val, flag2);
if (flag1 == -1) if (flag1 == -1)
@@ -2672,7 +2673,6 @@ After the return from a function its local objects no longer exist:
int* p = f(); int* p = f();
int z = *p; // read from abandoned stack frame (bad) int z = *p; // read from abandoned stack frame (bad)
g(p); // pass pointer to abandoned stack frame to function (bad) g(p); // pass pointer to abandoned stack frame to function (bad)
} }
Here on one popular implementation I got the output: Here on one popular implementation I got the output:
@@ -6006,7 +6006,7 @@ Here, we ignore such cases.
* [R.33: Take a `unique_ptr<widget>&` parameter to express that a function reseats the`widget`](#Rr-reseat) * [R.33: Take a `unique_ptr<widget>&` parameter to express that a function reseats the`widget`](#Rr-reseat)
* [R.34: Take a `shared_ptr<widget>` parameter to express that a function is part owner](#Rr-sharedptrparam-owner) * [R.34: Take a `shared_ptr<widget>` parameter to express that a function is part owner](#Rr-sharedptrparam-owner)
* [R.35: Take a `shared_ptr<widget>&` parameter to express that a function might reseat the shared pointer](#Rr-sharedptrparam) * [R.35: Take a `shared_ptr<widget>&` parameter to express that a function might reseat the shared pointer](#Rr-sharedptrparam)
* [R.36: Take a `const shared_ptr<widget>&` parameter to express that it might retain a reference count to the object ???](#Rr-sharedptrparam-const&) * [R.36: Take a `const shared_ptr<widget>&` parameter to express that it might retain a reference count to the object ???](#Rr-sharedptrparam-const)
* [R.37: Do not pass a pointer or reference obtained from an aliased smart pointer](#Rr-smartptrget) * [R.37: Do not pass a pointer or reference obtained from an aliased smart pointer](#Rr-smartptrget)
### <a name="Rr-raii"></a> Rule R.1: Manage resources automatically using resource handles and RAII (resource acquisition is initialization) ### <a name="Rr-raii"></a> Rule R.1: Manage resources automatically using resource handles and RAII (resource acquisition is initialization)
@@ -6730,7 +6730,7 @@ This makes the function's reseating explicit.
* (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr<T>` by value or by reference to `const` and does not copy or move it to another `Shared_ptr` on at least one code path. Suggest taking a `T*` or `T&` instead. * (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr<T>` by value or by reference to `const` and does not copy or move it to another `Shared_ptr` on at least one code path. Suggest taking a `T*` or `T&` instead.
* (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr<T>` by rvalue reference. Suggesting taking it by value instead. * (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr<T>` by rvalue reference. Suggesting taking it by value instead.
### <a name="Rr-sharedptrparam-const&"></a> R.36: Take a `const shared_ptr<widget>&` parameter to express that it might retain a reference count to the object ??? ### <a name="Rr-sharedptrparam-const"></a> R.36: Take a `const shared_ptr<widget>&` parameter to express that it might retain a reference count to the object ???
##### Reason ##### Reason
@@ -9138,7 +9138,7 @@ That would be a leak.
void leak(int x) // don't: may leak void leak(int x) // don't: may leak
{ {
auto p = new int{7}; auto p = new int{7};
if (x < 0) throw Get_me_out_of_here{}; // may leak *p if (x < 0) throw Get_me_out_of_here{} // may leak *p
// ... // ...
delete p; // we may never get here delete p; // we may never get here
} }
@@ -9990,7 +9990,7 @@ Specifying semantics is a powerful design tool.
{a - b} -> T; {a - b} -> T;
{a * b} -> T; {a * b} -> T;
{a / b} -> T; {a / b} -> T;
}; }
##### Note ##### Note
@@ -13056,7 +13056,6 @@ If you define a destructor, you should not use the compiler-generated copy or mo
HANDLE hnd; HANDLE hnd;
// ... // ...
public: public:
~X() { /* custom stuff, such as closing hnd */ } ~X() { /* custom stuff, such as closing hnd */ }
// suspicious: no mention of copying or moving -- what happens to hnd? // suspicious: no mention of copying or moving -- what happens to hnd?
}; };