No, it's not possible; vectors are contiguous containers, but even random access indices do not provide data contiguity.
You'll need either to keep indices external to the vector, or recreate the vector as required.
题
I am converting some code in a system that serves the UI with an enumerator. Unfortunately the enumerator has been designed around the std::vector<T>::const_iterator
. That is, it takes a begin and end iterator of type std::vector<T>::const_iterator
.
I would like to convert the underlying container of the data source from a vector to a boost multi index container. This works well, until I have to serve the enumerator.
My question is, is it possible to convert a multi index container index iterator to a std::vector<T>::const_iterator
?
解决方案
No, it's not possible; vectors are contiguous containers, but even random access indices do not provide data contiguity.
You'll need either to keep indices external to the vector, or recreate the vector as required.