mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Code indent 4 spaces instead of tabs
This commit is contained in:
parent
31fec52f4f
commit
2a907f088d
|
@ -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.
|
||||
|
||||
class Jet { // Physics says: e*e < x*x + y*y + z*z
|
||||
|
||||
float fx, fy, fz, fe;
|
||||
public:
|
||||
Jet(float x, float y, float z, float e)
|
||||
|
@ -1006,7 +1007,8 @@ Singletons are basically complicated global objects in disguise.
|
|||
##### Example
|
||||
|
||||
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.
|
||||
|
@ -1906,7 +1908,6 @@ We can refactor:
|
|||
double simpleFunc(double val, int flag1, int flag2)
|
||||
// simpleFunc: takes a value and calculates the expected ASIC output, given the two mode flags.
|
||||
{
|
||||
|
||||
if (flag1 > 0)
|
||||
return func1_muon(val, flag2);
|
||||
if (flag1 == -1)
|
||||
|
@ -9138,7 +9139,7 @@ That would be a leak.
|
|||
void leak(int x) // don't: may leak
|
||||
{
|
||||
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
|
||||
}
|
||||
|
@ -13056,7 +13057,6 @@ If you define a destructor, you should not use the compiler-generated copy or mo
|
|||
HANDLE hnd;
|
||||
// ...
|
||||
public:
|
||||
|
||||
~X() { /* custom stuff, such as closing hnd */ }
|
||||
// suspicious: no mention of copying or moving -- what happens to hnd?
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user