Skip to content

Commit c4698f2

Browse files
committed
Consistently use simple function name for meaningless functions
1 parent e910836 commit c4698f2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

CppCoreGuidelines.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ The second version leaves the reader guessing and opens more possibilities for u
371371

372372
##### Example
373373

374-
void do_something(vector<string>& v)
374+
void f(vector<string>& v)
375375
{
376376
string val;
377377
cin >> val;
@@ -388,7 +388,7 @@ The second version leaves the reader guessing and opens more possibilities for u
388388
That loop is a restricted form of `std::find`.
389389
A much clearer expression of intent would be:
390390

391-
void do_something(vector<string>& v)
391+
void f(vector<string>& v)
392392
{
393393
string val;
394394
cin >> val;
@@ -2308,13 +2308,13 @@ When copying is cheap, nothing beats the simplicity and safety of copying, and f
23082308

23092309
##### Example
23102310

2311-
void fct(const string& s); // OK: pass by reference to const; always cheap
2311+
void f1(const string& s); // OK: pass by reference to const; always cheap
23122312

2313-
void fct2(string s); // bad: potentially expensive
2313+
void f2(string s); // bad: potentially expensive
23142314

2315-
void fct(int x); // OK: Unbeatable
2315+
void f3(int x); // OK: Unbeatable
23162316

2317-
void fct2(const int& x); // bad: overhead on access in fct2()
2317+
void f4(const int& x); // bad: overhead on access in f4()
23182318

23192319
For advanced uses (only), where you really need to optimize for rvalues passed to "input-only" parameters:
23202320

@@ -7259,7 +7259,7 @@ The members of a scoped object are themselves scoped and the scoped object's con
72597259

72607260
The following example is inefficient (because it has unnecessary allocation and deallocation), vulnerable to exception throws and returns in the `...` part (leading to leaks), and verbose:
72617261

7262-
void some_function(int n)
7262+
void f(int n)
72637263
{
72647264
auto p = new Gadget{n};
72657265
// ...
@@ -7268,7 +7268,7 @@ The following example is inefficient (because it has unnecessary allocation and
72687268

72697269
Instead, use a local variable:
72707270

7271-
void some_function(int n)
7271+
void f(int n)
72727272
{
72737273
Gadget g{n};
72747274
// ...
@@ -10971,7 +10971,7 @@ In such cases, "crashing" is simply leaving error handling to the next level of
1097110971

1097210972
##### Example
1097310973

10974-
void do_something(int n)
10974+
void f(int n)
1097510975
{
1097610976
// ...
1097710977
p = static_cast<X*>(malloc(n,X));
@@ -10981,7 +10981,7 @@ In such cases, "crashing" is simply leaving error handling to the next level of
1098110981

1098210982
Most systems cannot handle memory exhaustion gracefully anyway. This is roughly equivalent to
1098310983

10984-
void do_something(Int n)
10984+
void f(Int n)
1098510985
{
1098610986
// ...
1098710987
p = new X[n]; // throw if memory is exhausted (by default, terminate)

0 commit comments

Comments
 (0)