How to remove constness of const_iterator?

后端 未结 9 2534
囚心锁ツ
囚心锁ツ 2020-11-27 03:21

As an extension to this question Are const_iterators faster?, I have another question on const_iterators. How to remove constness of a const_iterator

9条回答
  •  不知归路
    2020-11-27 04:15

    This may not be the answer you wanted, but somewhat related.

    I assume you want to change the thing where the iterator points to. The simplest way I do is that const_cast the returned reference instead.

    Something like this

    const_cast(*it);

提交回复
热议问题