Effective STL 27 convert a container's con_iterators to iterators

来源:互联网 发布:哈尔滨飞扬软件 编辑:程序博客网 时间:2024/06/03 18:21

use distance and advance to convert a container’s const_iterators to iterators.
both of which are declared in <iterator>

typedef deque<int> IntDeque;typedef IntDeque::iterator Iter;typedef IntDeque::const_iterator ConstIter;IntDeque d;ConstIter ci;...Iter i(d.begin());// figure the distance between i and ci (as const_iterators),// then move i that distanceadvance(i, distance<ConstIter>(i, ci));