When writing several mathematical applications, I was faced with the need to implement a universal utility that can perform a comparison between any two basic arithmetic types. When I started coding, it became clear that this operation is not as simple as it seems, because I need the correct handling of corner cases, especially when types have different accuracy, i.e. The rounding strategy when converting between types becomes important. Consider:
float a1 = 4.8f; int a2 = 4; assert(a2 != (int) a1);
The above can be implemented using properties of type C ++ 0x to automatically select the appropriate algorithm in accordance with the template arguments provided by the comparison function. However, itโs quite difficult, and there are quite a few places where errors can creep, so I donโt think of inventing everything that suits me. Does anyone know a library that correctly implements the above?
user283145
source share