yuenshome / yuenshome.github.io

https://yuenshome.github.io
MIT License
81 stars 15 forks source link

c++ - reinterpret_cast casts away qualifiers #61

Closed ysh329 closed 5 years ago

ysh329 commented 5 years ago

reinterpret_cast can't cast away cv-qualifiers

So you can use reinterpret_cast and const_cast together.

Dialog *dialog = const_cast<Dialog*>(reinterpret_cast<const Dialog *>(data));

ref: c++ - reinterpret_cast casts away qualifiers - Stack Overflow https://stackoverflow.com/questions/27995692/reinterpret-cast-casts-away-qualifiers