The Evil Within the Comparison Functions (C,C++,C#)
software.intel.com
The Evil Within the Comparison Functions (C,C++,C#)
1–2 of 2 posts
Re: The Evil Within the Comparison Functions (C,C++,C#)
#2This is why you should use clever language features such as macros (C) and pointers to member data (C++). If your code looks like this, there's no scope for accidentally comparing two fields in the same object, or comparing different fields in the two different objects:
return less_helper(pt1, pt2)(&pt::x)(&pt::y);
with pt::x and pt::y being integers, this ends up the same size as the open-coded version on the clang versions I tested, but two instructions longer on the gcc versions I tested, because gcc does not succeed in eliminating a needless comparison of yIS the last one.