Effective STL 27 convert a container's con

xiaoxiao2021-02-28  57

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 distance advance(i, distance<ConstIter>(i, ci));
转载请注明原文地址: https://www.6miu.com/read-55604.html

最新回复(0)