Add and plumb unsafe_{to,from}_uintptr<T> casts
These encapsulate the wildly powerful reinterpret_cast<> operator where one side is a uintptr_t and the other is a native pointer. In both cases we require the pointer type to be explicitly given.
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
4ad99d7392
commit
26324e8bfc
@@ -212,7 +212,7 @@ int main(int argc, char** argv)
|
||||
//
|
||||
// Note: We cannot use the check or assert macros here because they depend on
|
||||
// `MessageBuilder` working. They are safe to use in any other test.
|
||||
void* fakeptr = reinterpret_cast<void*>(static_cast<uintptr_t>(0x42));
|
||||
void* fakeptr = unsafe_from_uintptr<void>(static_cast<uintptr_t>(0x42));
|
||||
MessageBuilder<1024> b{
|
||||
"testing pointer {} size_t {} message, {} world, null is {}, -123456 is "
|
||||
"{}, 1234567 is {}",
|
||||
|
||||
Reference in New Issue
Block a user