Count constructors

The next two constructors allow the user of the API to set the minimum size of the vector as follows:

    container(
size_type count,
const T &value,
const Allocator &alloc = Allocator()
) :
m_v(count, value, alloc)
{
std::cout << "3 ";
}

explicit container(
size_type count,
const Allocator &alloc = Allocator()
) :
m_v(count, alloc)
{
std::cout << "4 ";
}

The first constructor will create the vector of count elements, all initialized with a value of value, while the second creates the elements with their default values (for example, a vector of integers would be initialized to zero).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset