mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject git commit: Update the Mesos Style Guide with C++11 and naming notes.
Date Mon, 13 Oct 2014 04:59:58 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 880c5a362 -> 0b092b1b0


Update the Mesos Style Guide with C++11 and naming notes.

Explicitly prohibit the use of namespace aliases. Give examples of
preferable way of using auto.

Review: https://reviews.apache.org/r/25622


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0b092b1b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0b092b1b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0b092b1b

Branch: refs/heads/master
Commit: 0b092b1b010d5a98616aa41a14ddc35a6217f2a1
Parents: 880c5a3
Author: Alexander Rukletsov <alex@mesosphere.io>
Authored: Sun Oct 12 21:59:36 2014 -0700
Committer: Benjamin Hindman <benjamin.hindman@gmail.com>
Committed: Sun Oct 12 21:59:36 2014 -0700

----------------------------------------------------------------------
 docs/mesos-c++-style-guide.md | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0b092b1b/docs/mesos-c++-style-guide.md
----------------------------------------------------------------------
diff --git a/docs/mesos-c++-style-guide.md b/docs/mesos-c++-style-guide.md
index 59a39df..f50354c 100644
--- a/docs/mesos-c++-style-guide.md
+++ b/docs/mesos-c++-style-guide.md
@@ -16,7 +16,10 @@ The Mesos codebase follows the [Google C++ Style Guide](http://google-styleguide
 
 ### Function Names
 * We use [lowerCamelCase](http://en.wikipedia.org/wiki/CamelCase#Variations_and_synonyms)
for function names (Google uses mixed case for regular functions; and their accessors and
mutators match the name of the variable).
-* Leave spaces around overloaded operators.  e.g. `operator + (...);` rather than `operator+(...);`
+* Leave spaces around overloaded operators, e.g. `operator + (...);` rather than `operator+(...);`
+
+### Namespace Names
+* We do not use namespace aliases.
 
 ## Strings
 * Strings used in log and error messages should end without a period.
@@ -84,9 +87,24 @@ Try&lt;Duration&gt; failoverTimeout =
 * Elements inside classes (member variables and functions) should not be spaced apart by
more than 1 blank line.
 
 ## C++11
+
 We still support older compilers. The whitelist of supported C++11 features is:
+
 * Static assertions.
 * Multiple right angle brackets.
-* Type inference (`auto` and `decltype`).
+* Type inference (`auto` and `decltype`). The main goal is to increase code readability.
Here are several examples:
+
+<pre>
+// 1: OK.
+const auto& i = values.find(keys.front());
+// Compare with
+const typename map::iterator& i = values.find(keys.front());
+
+// 2: Don't use.
+auto authorizer = LocalAuthorizer::create(acls);
+// Compare with
+Try<Owned<LocalAuthorizer>> authorizer = LocalAuthorizer::create();
+</pre>
+
 * Rvalue references.
 * Variadic templates.


Mime
View raw message