4 ms·
char8_t* is allowed to alias char* not because of any special property of char8_t, but because char is allowed to alias any other type (including char8_t).
by moonchild 5y ago
char8_t* is allowed to alias char* not because of any special property of char8_t, but because char is allowed to alias any other type (including char8_t).
- Kranar 5y agoAs you said, char* can alias any other type, but that does not allow any other type to alias char*. reinterpret_cast<char*>(T*); // Perfectly fine. reinterpret_cast<T*>(char*); // Undefined behavior. Otherwise it would be trivial for any type to alias any other type: reinterpret_cast<T*>(reinterpret_cast<char*>(U*));