Skip to content

Commit a786c4a

Browse files
committed
Merge pull request isocpp#69 from octoploid/master
Remove invalid characters
2 parents c333f52 + 207b8b5 commit a786c4a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

CppCoreGuidelines.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ In fact, C++98's standard library already used this convenient feature, because
23292329
For example, given a `set<string> myset`, consider:
23302330

23312331
// C++98
2332-
result = myset.insert( “Hello” );
2332+
result = myset.insert( “Hello” );
23332333
if (result.second) do_something_with( result.first ); // workaround
23342334

23352335
With C++11 we can write this, putting the results directly in existing local variables:
@@ -2338,7 +2338,7 @@ With C++11 we can write this, putting the results directly in existing local var
23382338
Someothertype success; // used these variables for some other purpose
23392339

23402340
tie( iter, success ) = myset.insert( “Hello” ); // normal return value
2341-
if (success) do_something_with( iter );
2341+
if (success) do_something_with( iter );
23422342

23432343
**Exception**: For types like `string` and `vector` that carry additional capacity, it can sometimes be useful to treat it as in/out instead by using the "caller-allocated out" pattern, which is to pass an output-only object by reference to non-`const` so that when the callee writes to it the object can reuse any capacity or other resources that it already contains. This technique can dramatically reduce the number of allocations in a loop that repeatedly calls other functions to get string values, by using a single string object for the entire loop.
23442344

@@ -2599,7 +2599,7 @@ For passthrough functions that pass in parameters (by ordinary reference or by p
25992599
stage encryptor ([] (buffer& b){ encrypt(b); });
26002600
stage compressor ([&](buffer& b){ compress(b); encryptor.process(b); });
26012601
stage decorator ([&](buffer& b){ decorate(b); compressor.process(b); });
2602-
for (auto& b : bufs) { decorator.process(b); }
2602+
for (auto& b : bufs) { decorator.process(b); }
26032603
} // automatically blocks waiting for pipeline to finish
26042604

26052605
**Enforcement**: ???
@@ -6993,17 +6993,17 @@ The definition of `a2` is C but not C++ and is considered a security risk
69936993

69946994
widget x; // should be const, but:
69956995
for(auto i=2; i <= N; ++i) { // this could be some
6996-
x += some_obj.do_something_with(i); // arbitrarily long code
6997-
} // needed to initialize x
6996+
x += some_obj.do_something_with(i); // arbitrarily long code
6997+
} // needed to initialize x
69986998
// from here, x should be const, but we can’t say so in code in this style
69996999

70007000
**Example; good**:
70017001

70027002
const widget x = [&]{
70037003
widget val; // asume that widget has a default constructor
7004-
for(auto i=2; i <= N; ++i) { // this could be some
7004+
for(auto i=2; i <= N; ++i) { // this could be some
70057005
val += some_obj.do_something_with(i);// arbitrarily long code
7006-
} // needed to initialize x
7006+
} // needed to initialize x
70077007
return val;
70087008
}();
70097009

0 commit comments

Comments
 (0)