0

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?

MM.
  • 4,224
  • 5
  • 37
  • 74
  • Oops. There's your reason not to use implementation details in an interface. If you are lucky (depending on the element type of the vector, e.g.) you might be able to forge a hybrid using Boost Intrusive using the vector as backing. (This requires you to alter the element type with hooks for Boost Intrusive though.) – sehe Apr 17 '14 at 17:31
  • On the implementation details in an interface - I couldn't agree with you more. – MM. Apr 17 '14 at 17:57

1 Answers1

1

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.

ecatmur
  • 152,476
  • 27
  • 293
  • 366