The std::vector that our custom container wraps already provides an efficient implementation of iterators that can be used to work with our container. We will, however, need to forward specific parts of the APIs that std::vector provides to ensure the iterators work properly, including key C++ features, such as range-based for loops.
To start, let's add the last remaining constructor that std::vector provides to our custom container:
template <typename Iter> container( Iter first, Iter last, const Allocator &alloc = Allocator() ) : m_v(first, last, alloc) { std::sort(m_v.begin(), m_v.end(), compare_type()); }
As shown in the preceding code snippet, the iterator type that we are given is not defined. The iterator could come ...