const_cast new_type (expression) - Serbipunk/notes GitHub Wiki

Returns a value of type new_type.

只有4种情况可以使用const_cast()

  1. multilevel pointers to the same type (may be converted between each other), regardless of CV-qualifier at each level (CV = const & volatile易挥发的,易变化的)· 两个指向同一类型的可能多级的指针可以互相转换,无关乎每个层级的 cv 限定符。

  2. C++17 同一类型左值->右值

  3. C++17 多层数据曾元

  4. nullptr -> 新类型空指针