#include <vector>
#include <iostream>
typedef struct {
   unsigned short a;
   unsigned short b;
   unsigned long  c;
}T;
int main(int,char**)
{
    std::vector<T> v;
    v.resize(256);
    std::cout << "a=" << v[0].a << " b=" << v[0].b << " c=" << v[0].c << "\n";
    return 0;
}
What will be v[0].a (and b and c)?
I am starting looking at the draft N4659 Working Draft, Standard for Programming
Language C++ searching for vector::resize:
26.3.11.3 vector capacity [vector.capacity] (at clause 13)
void resize(size_type sz);Effects: If
sz < size(), erases the lastsize() - szelements from the sequence. Otherwise, appendssz - size()default-inserted elements to the sequence.
from there I need to know what default-inserted means and I arrive at:
26.2.1 General container requirements [container.requirements.general] (at clause 15.2)
— An element of
Xis default-inserted if it is initialized by evaluation of the expression
allocator_traits<A>::construct(m, p)where
pis the address of the uninitialized storage for the element allocated withinX.
Now, I need to know what happen inside construct, I found this note
26.2.1 General container requirements [container.requirements.general] (at the end of clause 15)
[ Note: A container calls
allocator_traits<A>::construct(m, p, args)to construct an element atpusingargs, withm == get_allocator(). The default construct in allocator will call::new((void*)p) T(args), but specialized allocators may choose a different definition. — end note ]
Am I fine? Does my snippet use a specialized allocators? I think that at the end my snippet will call new T() and now, according to https://stackoverflow.com/a/8280207 I think a, b and c, will be 0, am I correct?