mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge PR 425
This commit is contained in:
parent
8a8d0c5980
commit
d33cfd97dd
|
@ -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
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
// ...
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user