Finally, we will also add a constructor that takes an initializer list, as follows:
container(
std::initializer_list<T> init,
const Allocator &alloc = Allocator()
) :
m_v(init, alloc)
{
std::sort(m_v.begin(), m_v.end(), compare_type());
std::cout << "8 ";
}
As shown in the preceding code, the initializer list could provide the initial elements for the std::vector in any order. As a result, we must sort the list after the vector is initialized.