Is it safe to remove const via const_cast and invoke a non-const function that does not modify the resulting object?

后端 未结 3 901
悲&欢浪女
悲&欢浪女 2020-12-06 07:03

I know that casting away const-ness should be done with care, and any attempt to remove const-ness from an initially const object foll

3条回答
  •  再見小時候
    2020-12-06 07:20

    This particular example happens to be safe (have well defined behavior) because there is no write to an object which is declared const.

提交回复
热议问题