[Top][All Lists]

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

Re: [lmi] [lmi-commits] master 8ee9eaf 1/7: Don't name unused template p

From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] master 8ee9eaf 1/7: Don't name unused template parameters
Date: Sat, 16 Jan 2021 12:53:44 +0100

On Sat, 16 Jan 2021 04:07:18 -0500 (EST) Greg Chicares 
<gchicares@sbcglobal.net> wrote:

GC> branch: master
GC> commit 8ee9eaf524604021b60b15018ac698529b816d1f
GC> Author: Gregory W. Chicares <gchicares@sbcglobal.net>
GC> Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
GC>     Don't name unused template parameters
GC>     Making up names for unused template parameters serves no purpose, and
GC>     creates a potential for conflict--for example:
GC>       template<typename T> class foo
GC>       {
GC>         template<typename T> friend void bar();
GC>                           ^ shadows 'T'
GC>         template<typename U> friend void baz();
GC>                           ^ shadows 'U' if added later
GC>         template<typename> friend void bar();
GC>                          ^ can never shadow anything

 While I agree that not using useless names like "T" or "U" is better than
using them, I think the best solution could be to use meaningful names for
the template parameters instead. The tradition of calling them "T" and "U"
is well-entrenched in C++ world, but it's hard to justify it otherwise than
by saying that everybody else does it. We don't call all parameters of our
functions "x", "y" and "z", so why should we do it for the types?

 Also, for both variables and types, omitting the names entirely works well
for the simple cases, but can result in something difficult to parse when
things become more complicated, i.e. there are multiple template parameters
or template templates etc.


Attachment: pgp1wxEbRquxS.pgp
Description: PGP signature

reply via email to

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