[Nfd-dev] C++11 code style

Alex Afanasyev alexander.afanasyev at UCLA.EDU
Sun Nov 2 12:03:57 PST 2014


> On Nov 2, 2014, at 9:20 AM, Junxiao Shi <shijunxiao at email.arizona.edu> wrote:
> 
> Dear folks
> 
> We need to define some new code style rules for C++11 syntax.
> 
> I'd start with three new rules:
> 
> rule x. Range-based for should be in the following form:
> 
> for (auto i : range) {
>   statements;
> }
> 
> 
> rule x. Lambda expression should be in the following form:
> 
> [&capture1, capture2] (Type1 arg1, Type2 arg2)
> {
>   statements;
> }

I prefer different style, which more aligns with the existing code (and is more gnu style):

[&capture1, capture2] (Type1 arg1, Type2 arg2) {
  statements;
}

> 
> If the function body has only one line, and the whole expression can fit in one line, the following form is also acceptable:
> 
> [&capture1, capture2] (Type1 arg1, Type2 arg2) { statement; }

that’s fine too

> 
> rule x. `auto` type should only be used for local variables.

Where else, potentially, it can be used?

> 
> What other rules do we need?
> 
> Yours, Junxiao
> _______________________________________________
> Nfd-dev mailing list
> Nfd-dev at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20141102/29137fbc/attachment.html>


More information about the Nfd-dev mailing list