[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 84cd25c 1/2: Remove stray spaces in templ

From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master 84cd25c 1/2: Remove stray spaces in template declarations and specializations
Date: Fri, 3 Mar 2017 15:42:15 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-03-03 14:42, Vadim Zeitlin wrote:
> On Thu,  2 Mar 2017 12:32:54 -0500 (EST) Greg Chicares <address@hidden> wrote:
> GC> branch: master
> GC> commit 84cd25cef0de311cc51d8034279673fc027e8e6c
> GC> Author: Gregory W. Chicares <address@hidden>
> GC> Commit: Gregory W. Chicares <address@hidden>
> GC> 
> GC>     Remove stray spaces in template declarations and specializations
> GC>     
> GC>     Removed space in '> >': C++ no longer requires it.
> GC>     
> GC>     Regularized spacing in template parameters lists. Generally, lmi has
> GC>     a space after the comma only in declarations:
> GC>       template<typename T, typename U> // space after comma
> GC>     but not in instantiations [not systematically changed in this commit]:
> GC>       std::pair<T,U>                   // no space after comma
> GC>     or in specializations:
> GC>       template<> struct foo<T,U>       // no space after comma
>  I'm really confused by this, why have two different rules for very similar
> things? AFAIK lmi uses the same convention for spaces after commas in the
> parameter lists in the function declarations and definitions (there is
> always a space after comma), why do it differently here?
>  Besides, subjectively, I find "std::map<int,int>" less readable, IMHO
> separating the 2 template arguments helps just as much as separating
> function arguments with spaces.
>  Could you please reconsider this (and revert
> ba9c81247a467ed242d821e47b17c6acc8b5c738)?

I'm in the middle of removing lmi's "uncopyable" class, and it's a large
change with some subtleties, so I'm not able to consider this or some of
your other suggestions until that work is done. But let me give the
rationale from the guidelines I followed here (copyrighted, but a short
quote is fair use):

C++ Coding Guidelines
Copyright © 2001 David Abrahams and Nathan Myers

"Omit spaces in template instantiations. Spaces are allowed between arguments
to template declarations. Unnecessary spaces in type names weaken their
recognizability as a syntactic unit. Instantiations with names that are too
unwieldy in this form should be typedef'ed."

Thus, they'd write
  template<typename A, typename B> class C{};
  std::pair<A,B> a_b_pair;
The difference between that and
  std::make_pair(a0, b0);
is that 'std::pair<A,B>' is a type, and I'm inclined to accept their
suggestion that omitting spaces makes it easier to recognize as a
single syntactic unit.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]