mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
Merge PR 425
This commit is contained in:
@@ -3202,7 +3202,6 @@ You need a reason (use cases) for using a hierarchy.
|
||||
|
||||
auto p21 = make_unique<Point2>(1, 2); // make an object on the free store
|
||||
auto p22 = p21.clone(); // make a copy
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -8556,9 +8555,9 @@ A programmer should know and use the basic rules for expressions.
|
||||
|
||||
##### Example
|
||||
|
||||
x = k * y + z; // OK
|
||||
x=k * y + z; // OK
|
||||
|
||||
auto t1 = k * y; // bad: unnecessarily verbose
|
||||
auto t1 = k*y; // bad: unnecessarily verbose
|
||||
x = t1 + z;
|
||||
|
||||
if (0 <= x && x < max) // OK
|
||||
@@ -11188,7 +11187,7 @@ Assume that `Apple` and `Pear` are two kinds of `Fruit`s.
|
||||
void maul(Fruit* p)
|
||||
{
|
||||
*p = Pear{}; // put a Pear into *p
|
||||
p[1] = Pear{}; // put a Pear into p[1]
|
||||
p[1] = Pear{}; // put a Pear into p[2]
|
||||
}
|
||||
|
||||
Apple aa [] = { an_apple, another_apple }; // aa contains Apples (obviously!)
|
||||
@@ -11213,10 +11212,10 @@ Note that `maul()` violates the a `T*` points to an individual object [Rule](#??
|
||||
|
||||
vector<Apple> va = { an_apple, another_apple }; // aa contains Apples (obviously!)
|
||||
|
||||
maul2(va); // error: cannot convert a vector<Apple> to a Fruit*
|
||||
maul2(&va[0]); // you asked for it
|
||||
maul2(aa); // error: cannot convert a vector<Apple> to a Fruit*
|
||||
maul2(&aa[0]); // you asked for it
|
||||
|
||||
Apple& a0 = &va[0]; // a Pear?
|
||||
Apple& a0 = &aa[0]; // a Pear?
|
||||
|
||||
Note that the assignment in `maul2()` violated the no-slicing [Rule](#???).
|
||||
|
||||
@@ -13009,7 +13008,7 @@ This is not evil.
|
||||
|
||||
Some styles distinguishes types from non-types.
|
||||
|
||||
template<typename T>
|
||||
typename<typename T>
|
||||
class Hash_tbl { // maps string to T
|
||||
// ...
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user