lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Switch to using C++11 uniform initialization in the ctor initi


From: Vadim Zeitlin
Subject: Re: [lmi] Switch to using C++11 uniform initialization in the ctor initializer lists?
Date: Fri, 24 Aug 2018 15:20:17 +0200

On Fri, 24 Aug 2018 01:15:42 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2018-08-24 00:23, Vadim Zeitlin wrote:
GC> [...]
GC> >   https://github.com/vadz/lmi/compare/uniform-init?expand=1
GC> > 
GC> >  With these changes the code compiles and the unit tests pass. I've also
GC> > manually looked at all occurrences of vector-typed members followed by "{"
GC> > (actually " *{") in the code and confirmed that they were correct (i.e.
GC> > used either default or copy ctors) and that () were used for everything
GC> > else. But, again, I could have missed something, so I plan on redoing this
GC> > tomorrow -- unless you beat me to it. 
GC> 
GC> What do you mean by "redoing" in the last sentence?

 Re-reading the changes in a different way. I admit I find it almost
hopeless though, there are just too many of them and my eyes started to
glaze over when I was at about 10% mark...

GC> If you mean starting with a clean copy of HEAD and repeating all the
GC> work, then it would probably make more sense for me to be the one to do
GC> that.

 On one hand, I think this is going to be pretty wasteful -- i.e. what
would have been the point of me doing it if you're going to redo it anyhow?
OTOH it could well be simpler for you to do it like this rather than
checking my changes. And, especially if you can resist the temptation to
also change the alignment, you should normally arrive at the same end
result, so we could just compare your and my versions to find any possible
troublesome points.

 But, thinking more about it, I really do think that it's enough to check
that my changes left any classes with ctors taking std::initializer_list
unaffected. And there are relatively few members of such classes (mostly
vectors and strings and a couple of deques) in lmi code and I did check
each of them individually already. So maybe you could just redo this: it
would take much less time than redoing all the changes (trust me, I did
both and so can compare).


GC> BTW, I can change any ctor-initializer pretty easily with something
GC> like
GC>   s/(\(.*\))/{\1}

 This is not optimal as there are ctor initializers involving expressions
with parentheses in them. I used two "s" commands, one for the leading "("
and one for the last ")" on a line and this worked for almost all cases
except the couple which had several initializers on one line. I also
recommend doing both "nmap" and "vmap" mappings to this command to allow
applying it quickly.

GC> but do you have a good technique for finding all ctr-initializers?

 I only looked for "^ *: *[A-Za-z0-9_]+_( *\(|$)", i.e. just the first
one, and then examined all the subsequent initializers manually. I.e. I did
a "git grep" for the regex above (which is why it uses extended, and not
Vim, syntax) and then just kept hitting Ctrl-N (my mapping for ":cn<CR>"),
"<n>V" where "n" is the number of lines with initializers (you don't need
to count them manually if you have "set relativenumber" option on) and
pressing the key bound to my mapping with "s" commands. If there was only a
single initializer, I pressed the same key directly, which is why I bound
it both normal and visual modes.

 Hope this helps,
VZ


reply via email to

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