因此,从const X*投射到X*也是合法的.So, casting from const X* to X* is also legal.最后,它说(尽管有注释):Lastly, it says (albeit in a note): [dcl.type.cv] 告诉我们:幸运的是,我们的this指向非const对象,因此强制转换并通过新的非const指针修改该对象不会触发未定义的行为.Luckily, our this is pointing to a non-const object, so casting it and then modifying this object through the new non-const pointer doesn't trigger undefined behaviour. 抱歉. 这篇关于如果实际对象不是const,则具有写操作的const_cast(this)是否具有未定义的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 10:05