Re:Clang vs. GCC – code coverage checking
by feylikurds on Saturday April 02, 2016 @02:04PM
(#11412515)
Dear God, now I remember why I do not program in C++ anymore (Go and C# all the way!). That pre-11 code looked awful. If networking was nicer, I might actually start considering recoding some of my projects in C++.
[ Parent
| on HN ]
Re:Clang vs. GCC – code coverage checking
by dave2000 on Saturday April 02, 2016 @04:45PM
(#11413338)
If you have £40 or so, and a few evenings free, get the C++11 version of the Stroustrup programming language book and see what's changed. Modern C++ looks entirely different to older C++. Templates still a bit scary, so learn them or ignore them.
Re:Clang vs. GCC – code coverage checking
by feylikurds on Saturday April 02, 2016 @06:19PM
(#11413788)
Yes, but are there still tons of boilerplate? Or is there a 11/14/17 library that incredibly decreases the amount of code needed? For example a HTTP listener with routing?
It's hard to say what he was trying to accomplish, but he probably could have written something like this.
auto index = std::distance (begin(replicas),
std::find(begin(replicas), end(replicas), my_ip));
return (replicas.size() == index ? -1 : index);
Re:Clang vs. GCC – code coverage checking
by pavanky on Saturday April 02, 2016 @02:47PM
(#11412725)
That's a bit harder to read isn't it? I think finding the location in first line and using distance in the ternary operator makes it more readable.
Like this?
auto it = std::find(begin(replicas), end(replicas), my_ip);
return (end(replicas) == it ? -1 : std::distance(begin(replicas), it));
Yeah, i'll go with that.