If I use std::vector's reserve on a newly created vector, is the amount
of memory reserved equal to the requested amount or at least equal to
the requested amount. In other words, if I have
I know that 'a' will have memory for at least 10 int's. Can I be
certain that the amount of memory is for exactly 10 int's?
Re: std::vector reserve
> From n3242:
> "void reserve(size_type n);
> 2 Effects: A directive that informs a vector of a planned change in
> size, so that it can manage the storage
> allocation accordingly. After reserve(), capacity() is greater or equal
> to the argument of reserve if
> reallocation happens; and equal to the previous value of capacity()
> otherwise. Reallocation happens
> at this point if and only if the current capacity is less than the
> argument of reserve(). If an exception
> is thrown other than by the move constructor of a non-CopyInsertable
> type, there are no effects."
> So I guess the answer is that capacity will be *at least* 10 in your
|All times are GMT. The time now is 02:42 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.