mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
Fix whitespace around operator
This commit is contained in:
@@ -2239,8 +2239,13 @@ Passing a shared smart pointer (e.g., `std::shared_ptr`) implies a run-time cost
|
||||
|
||||
##### Example
|
||||
|
||||
void f(int*); // accepts any int*
|
||||
// accepts any int*
|
||||
void f(int*);
|
||||
|
||||
// can only accept ints for which you want to transfer ownership
|
||||
void g(unique_ptr<int>); // accepts ints to transfer ownership
|
||||
|
||||
// can only accept ints for which you are willing to share ownership
|
||||
void g(shared_ptr<int>); // accepts ints to share ownership
|
||||
|
||||
// doesn’t change ownership, but requires a particular ownership of the caller
|
||||
@@ -2683,10 +2688,13 @@ A `span` represents a range of elements, but how do we manipulate elements of th
|
||||
{
|
||||
// range traversal (guaranteed correct)
|
||||
for (int x : s) cout << x << '\n';
|
||||
|
||||
// C-style traversal (potentially checked)
|
||||
for (int i = 0; i < s.size(); ++i) cout << x << '\n';
|
||||
|
||||
// random access (potentially checked)
|
||||
s[7] = 9;
|
||||
|
||||
// extract pointers (potentially checked)
|
||||
std::sort(&s[0], &s[s.size() / 2]);
|
||||
}
|
||||
@@ -4064,7 +4072,9 @@ If the `Handle` owns the object referred to by `s` it must have a destructor.
|
||||
|
||||
Independently of whether `Handle` owns its `Shape`, we must consider the default copy operations suspect:
|
||||
|
||||
Handle x {*new Circle{p1, 17}}; // causes a leak if the Handle is not a Circle
|
||||
// the Handle had better own the Circle or we have a leak
|
||||
Handle x {*new Circle{p1, 17}};
|
||||
|
||||
Handle y {*new Triangle{p1, p2, p3}};
|
||||
x = y; // the default assignment will try *x.s = *y.s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user