lmi
[Top][All Lists]
Advanced

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

Re: [lmi] [low priority] How to deal with variable shadowing warnings?


From: Vadim Zeitlin
Subject: Re: [lmi] [low priority] How to deal with variable shadowing warnings?
Date: Sun, 27 Mar 2016 22:44:05 +0200

On Sun, 27 Mar 2016 13:06:42 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2016-02-10 04:26, Vadim Zeitlin wrote:
GC> > On Mon, 8 Feb 2016 03:25:06 +0000 Greg Chicares <address@hidden> wrote:
GC> > 
GC> > GC> On 02/08/2016 12:54 AM, Vadim Zeitlin wrote:
GC> > GC> > 
GC> > GC> >  The latest version of MSVC compiler (MSVS 2015 a.k.a. VC 14) 
enables the
GC> > GC> > warnings about variables hiding other names in the same scope by 
default
GC> 
GC> 
https://github.com/vadz/lmi/commit/ebbf323183e5dda08a86b7f6b38107bb1d3fd744.patch
GC> 
GC> -    ledger_map_t::const_iterator i = l_map_rep.begin();
GC> -    for(;i != l_map_rep.end(); i++)
GC> +    using lmci = ledger_map_t::const_iterator;
GC> +    for(lmci i = l_map_rep.begin();i != l_map_rep.end(); i++)
GC> 
GC> The order of typdef declarations never made much sense to me:
GC>   typedef int new_type;
GC> reads like
GC>   let 2 = a; // backwards!
GC> I'm glad to see that C++11 finally got this right.
GC> 
GC> Of course we should prefer this new syntax in brand-new modules. And I'd be
GC> happy to replace all old typedefs with 'using' because it's more readable.
GC> But I rewrote this one with 'typedef' because I don't want to introduce
GC> random inconsistency.

 Yes, I hesitated about using "using" here but decided it wasn't worth
asking about it separately (just as I didn't really ask about using "auto"
in another patch) and that you would undoubtedly remark upon it when/if you
applied this patch, so for once things went exactly as planned :-) I don't
think I'm using C++11 "using" in any other patches and I will, of course,
avoid it in any upcoming ones, but replacing "typedef" with "using" is one
of the top items in my list for the C++11 transition, just after "for each"
loops and using "auto" (and maybe using "nullptr").

 Anyhow, thanks for commenting on this!
VZ

reply via email to

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