mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
fix mix of tabs and spaces
This commit is contained in:
@@ -5297,17 +5297,17 @@ Note that because of language rules, the covariant return type cannot be a smart
|
|||||||
public:
|
public:
|
||||||
point(int xx, int yy) : x{xx}, y{yy} { }
|
point(int xx, int yy) : x{xx}, y{yy} { }
|
||||||
int get_x() { return x; }
|
int get_x() { return x; }
|
||||||
void set_x(int xx) { x = xx; }
|
void set_x(int xx) { x = xx; }
|
||||||
int get_y() { return y; }
|
int get_y() { return y; }
|
||||||
void set_y(int yy) { y = yy; }
|
void set_y(int yy) { y = yy; }
|
||||||
// no behavioral member functions
|
// no behavioral member functions
|
||||||
};
|
};
|
||||||
|
|
||||||
Consider making such a class a `struct` -- that is, a behaviorless bunch of variables, all public data and no member functions.
|
Consider making such a class a `struct` -- that is, a behaviorless bunch of variables, all public data and no member functions.
|
||||||
|
|
||||||
struct point {
|
struct point {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
@@ -8695,12 +8695,12 @@ make the job of the optimizer much harder. Simple code often optimizes better th
|
|||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
int matrix[rows][cols];
|
int matrix[rows][cols];
|
||||||
|
|
||||||
//bad
|
//bad
|
||||||
for(int c=0; c<cols; ++c)
|
for(int c=0; c<cols; ++c)
|
||||||
for(int r=0; r<rows; ++r)
|
for(int r=0; r<rows; ++r)
|
||||||
sum += matrix[r][c];
|
sum += matrix[r][c];
|
||||||
|
|
||||||
//good
|
//good
|
||||||
for(int r=0; r<rows; ++r)
|
for(int r=0; r<rows; ++r)
|
||||||
for(int c=0; c<cols; ++c)
|
for(int c=0; c<cols; ++c)
|
||||||
@@ -12819,7 +12819,7 @@ Here is an example of the last option:
|
|||||||
|
|
||||||
class B {
|
class B {
|
||||||
public:
|
public:
|
||||||
B() { /* ... */ f(); /*...*/ } // BAD: see Item 49.1
|
B() { /* ... */ f(); /*...*/ } // BAD: see Item 49.1
|
||||||
|
|
||||||
virtual void f() = 0;
|
virtual void f() = 0;
|
||||||
|
|
||||||
@@ -12830,7 +12830,7 @@ Here is an example of the last option:
|
|||||||
protected:
|
protected:
|
||||||
B() { /* ... */ }
|
B() { /* ... */ }
|
||||||
virtual void PostInitialize() // called right after construction
|
virtual void PostInitialize() // called right after construction
|
||||||
{ /* ... */ f(); /*...*/ } // GOOD: virtual dispatch is safe
|
{ /* ... */ f(); /*...*/ } // GOOD: virtual dispatch is safe
|
||||||
public:
|
public:
|
||||||
virtual void f() = 0;
|
virtual void f() = 0;
|
||||||
|
|
||||||
@@ -12842,9 +12842,9 @@ Here is an example of the last option:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class D : public B { /* "¦ */ }; // some derived class
|
class D : public B { /* "¦ */ }; // some derived class
|
||||||
|
|
||||||
shared_ptr<D> p = D::Create<D>(); // creating a D object
|
shared_ptr<D> p = D::Create<D>(); // creating a D object
|
||||||
|
|
||||||
This design requires the following discipline:
|
This design requires the following discipline:
|
||||||
|
|
||||||
@@ -13246,7 +13246,7 @@ Most compilers already warn about simple cases and has the information to do mor
|
|||||||
{
|
{
|
||||||
return ...;
|
return ...;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto v = get_large_vector(); //return by value is ok, most modern compilers will do copy elision
|
auto v = get_large_vector(); //return by value is ok, most modern compilers will do copy elision
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|||||||
Reference in New Issue
Block a user