Comparing pointers using <, >, <=, >= operators in C++ is safe only when both pointers point to the elements of the same array (or the memory location past the last element of that array). When pointers point to items of the different arrays, or to different objects, the result is unspecified.
To compare arbitrary pointers it is necessary to use template specializations of std::greater, std::less, std::greater_equal, std::less_equal. In this case they will yield a total order.
§ 20.8.5/8: "For templates greater, less, greater_equal, and less_equal, the specializations for any pointer type yield a total order, even if the built-in operators <, >, <=, >= do not."
https://github.com/ispringteam/FastSignals/blob/5c05334245ba0391994788ce8a9cca32ac335fa9/libfastsignals/src/function_detail.cpp#L82-L88
Comparing pointers using
<
,>
,<=
,>=
operators in C++ is safe only when both pointers point to the elements of the same array (or the memory location past the last element of that array). When pointers point to items of the different arrays, or to different objects, the result is unspecified.To compare arbitrary pointers it is necessary to use template specializations of
std::greater
,std::less
,std::greater_equal
,std::less_equal
. In this case they will yield a total order.§ 20.8.5/8: "For templates greater, less, greater_equal, and less_equal, the specializations for any pointer type yield a total order, even if the built-in operators <, >, <=, >= do not."