https://google.github.io/styleguide/cppguide.html#Namespaces
+.. code-block:: c++
+
+ namespace n1 {
+ void f();
+ }
+
+ // becomes
+
+ namespace n1 {
+ void f();
+ } // namespace n1
+
+
Options
-------
Looks for local ``Twine`` variables which are prone to use after frees and
should be generally avoided.
+
+.. code-block:: c++
+
+ static Twine Moo = Twine("bark") + "bah";
+
+ // becomes
+
+ static std::string Moo = (Twine("bark") + "bah").str();
Associative containers implements some of the algorithms as methods which
should be preferred to the algorithms in the algorithm header. The methods
can take advanatage of the order of the elements.
+
+.. code-block:: c++
+
+ std::set<int> s;
+ auto it = std::find(s.begin(), s.end(), 43);
+
+ // becomes
+
+ auto it = s.find(43);
+
+.. code-block:: c++
+
+ std::set<int> s;
+ auto c = std::count(s.begin(), s.end(), 43);
+
+ // becomes
+
+ auto c = s.count(43);
Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
turned on.
+
+.. code-block:: c++
+
+ void a(int i) {}
+
+ // becomes
+
+ void a(int /*i*/) {}
+
+
+.. code-block:: c++
+
+ static void staticFunctionA(int i);
+ static void staticFunctionA(int i) {}
+
+ // becomes
+
+ static void staticFunctionA()
+ static void staticFunctionA() {}
For example, warns on ``::sin(0.f)``, because this funciton's parameter is a
double. You probably meant to call ``std::sin(0.f)`` (in C++), or ``sinf(0.f)``
(in C).
+
+.. code-block:: c++
+
+ float a;
+ asin(a);
+
+ // becomes
+
+ float a;
+ std::asin(a);
// Initializing string with empty string literal is unnecessary.
std::string a = "";
std::string b("");
+
+ // becomes
+
+ std::string a;
+ std::string b;
Replace ``delete <unique_ptr>.release()`` with ``<unique_ptr> = nullptr``.
The latter is shorter, simpler and does not require use of raw pointer APIs.
+
+.. code-block:: c++
+
+ delete P.release();
+
+ // becomes
+
+ P = nullptr;