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

James Dennett jdennett at google.com
Mon Mar 3 00:33:20 PST 2014


On Sat, Mar 1, 2014 at 12:08 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
>
>
> ================
> 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});

Per r202684,  "MSVC 2012 doesn't support std::initializer_list at
all", so ought we instead to say that we can't use
std::initializer_list yet?

-- James




More information about the llvm-commits mailing list