News for hackers. Stuff that matters.
Re:How We Beat C++ STL Binary Search by lhecker on Tuesday August 11, 2015 @05:34PM (#10044575)
Just a nitpick: Assigning a negative value to an unsigned integer is perfectly safe and well defined (i.e. integer overflow for unsigned integers is well defined in the C++ spec).

Using -1 for size_t is sometimes even prefered to assign it's maximum value, since there is no cross-platform #define for it (most use either SIZE_T_MAX or SIZE_MAX).

In fact llvm's libc++ uses it for it's std::numeric_limits implementation and for std::string's npos.

Re:How We Beat C++ STL Binary Search by Joky on Tuesday August 11, 2015 @07:28PM (#10045077)
I believe there is a standard cross-platform maximum value, and you mention it in your last sentence: std::numeric_limits!
Re:How We Beat C++ STL Binary Search by lhecker on Wednesday August 12, 2015 @09:14AM (#10047498)
Uhm... Using "-1" to assign the maximum value is in fact as standard and cross-platform as using std::numeric_limits, which was basically my entire point.

The difference between those is only "textual solution" VS "mathematical solution" and thus a matter of personal preference.

Re:How We Beat C++ STL Binary Search by arbre on Tuesday August 11, 2015 @11:41PM (#10045909)
~0u ?