[PATCH] Update the coding standards to provide some guidance for a few constructs in C++11

Chandler Carruth chandlerc at gmail.com
Sat Mar 1 00:08:25 PST 2014



================
Comment at: docs/CodingStandards.rst:513
@@ +512,3 @@
+worse, we also have many more uses of braces in an expression context that are
+*not* performing initialization.
+
----------------
James Dennett wrote:
> Meaning lambdas, or...?  (I"m not sure this warrants any editing, but as a reader my first reaction to this was "I wonder what that's talking about".)
Yep, just meaning lambdas.

================
Comment at: docs/CodingStandards.rst:667
@@ +666,3 @@
+(without any type for temporaries) when doing aggregate initialization or
+something notionally equivalent. Examples:
+
----------------
James Dennett wrote:
> Does use of a constructor taking a std::initializer_list<T> parameter count as "notionally equivalent" to aggregate initialization, or is it under the general "Do not use these...if you care that you're calling some *particular* constructor" case?  I could make an argument for either.
> 
> Maybe the easiest way to document that is with an example indicating whether
> std::vector<int> Very SmallPrimes = { 2, 3, 5 };
> is permitted or not.
> 
> (While I do have a preferred answer, I'm not here to lobby for it, just to ask what the intent is.  Lobbying can happen later.  Much later.)
Hmm. I'm a bit torn on this one.

I am OK allowing the variable syntax you give, but I would like to require that if you are creating a temporary, you do something like:

  std::vector<int>({1, 2})

I would also be OK with requiring the same syntax for variable declarations:

  std::vector<int> x({1, 2});


http://llvm-reviews.chandlerc.com/D2905



More information about the llvm-commits mailing list