diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index eab67ce..71ef50b 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1067,7 +1067,7 @@ So, if a suitable library exists for your application domain, use it. ##### Example - std::sort(begin(v),end(v),std::greater<>()); + std::sort(begin(v), end(v), std::greater<>()); Unless you are an expert in sorting algorithms and have plenty of time, this is more likely to be correct and to run faster than anything you write for a specific application. @@ -9105,7 +9105,7 @@ Readability. Minimize resource retention. Note: C++17 also adds `if` and `switch` initializer statements. These require C++17 support. - map mymap; + map mymap; if (auto result = mymap.insert(value); result.second) { // insert succeeded, and result is valid for this block @@ -9508,7 +9508,7 @@ Assuming that there is a logical connection between `i` and `j`, that connection Obviously, what we really would like is a construct that initialized n variables from a `tuple`. For example: - auto [i,j] = make_related_widgets(cond); // C++17, not C++14 + auto [i, j] = make_related_widgets(cond); // C++17, not C++14 Today, we might approximate that using `tie()`: @@ -12494,8 +12494,7 @@ Thread creation is expensive. // process } - void - (istream& is) + void master(istream& is) { for (Message m; is >> m; ) run_list.push_back(new thread(worker, m)); @@ -16574,10 +16573,10 @@ Doing so takes away an `#include`r's ability to effectively disambiguate and to // user.cpp #include "bad.h" - bool copy( /*... some parameters ...*/); // some function that happens to be named copy + bool copy(/*... some parameters ...*/); // some function that happens to be named copy int main() { - copy( /*...*/ ); // now overloads local ::copy and std::copy, could be ambiguous + copy(/*...*/); // now overloads local ::copy and std::copy, could be ambiguous } ##### Enforcement