vector<T>::const_iterator first = myVec.begin() + 100000;
vector<T>::const_iterator last = myVec.begin() + 101000;
vector<T> newVec(first, last);
It’s an O(N) operation to construct the new vector, but there isn’t really a better way.
More Related Contents:
- What is the easiest way to initialize a std::vector with hardcoded elements?
- std::vector::resize() vs. std::vector::reserve()
- Is std::vector so much slower than plain arrays?
- How do I erase an element from std::vector by index?
- Alternative to vector
- Why isn’t vector a STL container?
- reduce the capacity of an stl vector
- How to sum up elements of a C++ vector?
- How to avoid memory leaks when using a vector of pointers to dynamically allocated objects in C++?
- C++ Erase vector element by value rather than by position? [duplicate]
- Does vector::erase() on a vector of object pointers destroy the object itself?
- How do I print the elements of a C++ vector in GDB?
- how do you insert the value in a sorted vector?
- What’s faster, iterating an STL vector with vector::iterator or with at()?
- How to use std::sort with a vector of structures and compare function?
- Reorder vector using a vector of indices [duplicate]
- array vs vector vs list
- Cleaning up an STL list/vector of pointers
- How to downsize std::vector?
- C++ convert vector to vector
- What happens if you increment an iterator that is equal to the end iterator of an STL container
- Getting a vector into a function that expects a vector
- std::vector reserve() and push_back() is faster than resize() and array index, why?
- Vector Iterators Incompatible
- Why the libc++ std::vector internally keeps three pointers instead of one pointer and two sizes?
- std::vector capacity after copying
- STL vectors with uninitialized storage?
- “Right” way to deallocate an std::vector object
- C++ template function compiles in header but not implementation
- vector and const