P
persres
Hello,
I want to take subsequence from a vector and store it in a
different vector. I would like to avoid copying. Is there something
available in boost or stl.
Say,
vector<int> v(0,1,2,3,4,5,6,7,8,9,10);
I want vector<int> slice to hold 5,6,7,8.
I should be able to do:
Is there a wrapper class like this -
template<class T>
struct SliceOfVector
{
vector<T>& m_original;
};
SliceOfVector should have all semantics same as vector. May be even
derives from vector<T>.
I should be able to treat SliceOfVector just like a vector, just that
it would be the subsequence specified by m_range of the original
vector.
Am I making sense. Please let me know if you have any suggestions.
I want to take subsequence from a vector and store it in a
different vector. I would like to avoid copying. Is there something
available in boost or stl.
Say,
vector<int> v(0,1,2,3,4,5,6,7,8,9,10);
I want vector<int> slice to hold 5,6,7,8.
I should be able to do:
Is there a wrapper class like this -
template<class T>
struct SliceOfVector
{
pair< vector<T>::iterator , vector<T>::iterator > m_range;SliceOfVector(pair said:
vector<T>& m_original;
};
SliceOfVector should have all semantics same as vector. May be even
derives from vector<T>.
I should be able to treat SliceOfVector just like a vector, just that
it would be the subsequence specified by m_range of the original
vector.
Am I making sense. Please let me know if you have any suggestions.