News for hackers. Stuff that matters.
Re:Clang vs. GCC – code coverage checking by nly on Saturday April 02, 2016 @02:42PM (#11412700)
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.
Re:Clang vs. GCC – code coverage checking by nly on Saturday April 02, 2016 @02:50PM (#11412736)
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.
Re:Clang vs. GCC – code coverage checking by pavanky on Saturday April 02, 2016 @06:32PM (#11413843)
Yeah that's what I was thinking.