I want to use a Windows HANDLE
(a thread handle) as key in a std::map
. For this, I need a less-than operator that is well-defined for the type HANDLE
.
Pointer types T*
can be used as keys for std::map
only if the comparator std::less<T*>
is specified, because the builtin operator<(T*, T*)
(and henceforth std::less<>
) does not provide a total order.
Implementationwise, we know that HANDLE
is actually typedefed as a pointer type. Therefore, std::less<HANDLE>
looks like a safe bet. But I consider it just an implementation detail that HANDLE
is implemented as a pointer type. (And by inspecting actual HANDLE
values in the debugger, it can be clearly seen that they are not genuine pointer values.)
Are there any formal guarantees that can be derived from the C++ standard and the Windows API documentation that would allow me to use HANDLE
as a key in std::map
?