Does reserving capacity incur two allocations or just one?
Posted
by FredOverflow
on Stack Overflow
See other posts from Stack Overflow
or by FredOverflow
Published on 2010-05-01T00:27:08Z
Indexed on
2010/05/01
0:37 UTC
Read the original article
Hit count: 577
std::vector<T> vec; // line #1
vec.reserve(100); // line #2
I am wondering if line #1 triggers a small allocation (say, memory for 10 Ts), or if the first allocation happens on line #2. Does the standard say anything about that?
© Stack Overflow or respective owner