diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-25 04:26:58 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-25 04:26:58 +0200 |
commit | e67ac2a3c464b9bbcb1e4c8c217aed935bde3836 (patch) | |
tree | a01f7e6cae696dceb2ca0a77de9ae347b0d93124 | |
parent | ce22517f30193f79011f4345b365301a9e6183f5 (diff) |
Add section on modernization to C++ style guide
-rw-r--r-- | cxx-style.txt | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cxx-style.txt b/cxx-style.txt index 64af573..ec2b24e 100644 --- a/cxx-style.txt +++ b/cxx-style.txt @@ -6,7 +6,13 @@ better) "clever" code that tries to avoid extra copies, allocations, etc. See also the note on small value optimization. -1. Almost never auto +1. Modernization + +- use override +- consider constexpr for inline functions (e.g., enum class bitmask operators) +- consider noexcept + +2. Almost never auto Using auto instead of the actual type often makes code harder to understand. You may (but don't have to) use auto when (a) the type is spelled out on the @@ -18,7 +24,7 @@ Examples of the latter are lambda initializations, iterator initializations (e.g, from begin()), and some cases of pair initialization (e.g, from container's insert()). -2. Almost never brace-initialization +3. Almost never brace-initialization We only use brace-initialization syntax when initializing an aggregate or a container. We can also use it for an aggregate-like initialization of an @@ -47,7 +53,7 @@ struct foo string s = string (123, 's'); }; -3. Many performance-critical standard types are "small object optimized" +4. Many performance-critical standard types are "small object optimized" For example, across all the implementations that we care, std::string can hold at least 15 characters without allocation. Similarly, std::function can hold a |