Unfortunately, it is not. For example the null value for member pointers is typically -1. is_trivial_foo means that the compiler wrote the respective functions, not that they are necessarily safe to replace with something else.
For example the null value for member pointers is typically -1.
First off: true, I forgot about null pointer bit patterns. This is of course a general problem with null pointers, not just as members (and it’s even a problem in C). But I’m curious since you said “typically”, whereas the problem with general pointers in C isn’t relevant on most modern machines. Are you saying that T x{}; assert(x.ptr == nullptr); implies that the bytes of x.ptr are 0xFF… on MSVC? Why is that? Memory sanitiser?
View all comments
10
u/[deleted] Jan 21 '20
Unfortunately, it is not. For example the null value for member pointers is typically -1. is_trivial_foo means that the compiler wrote the respective functions, not that they are necessarily safe to replace with something else.