Boost logo

Boost :

Subject: [boost] [container][stable_vector] What does reserve() do for stable_vector
From: Arindam Mukherjee (arindam.mukerjee_at_[hidden])
Date: 2015-04-19 04:06:00


Consider the following code.

#include <string>
#include <boost/container/stable_vector.hpp>
#include <iostream>

int main()
{
  boost::container::stable_vector<std::string> vec;
  vec.reserve(10);
  std::cout << "capacity = " << vec.capacity() << '\n';
}

On running this (on g++ and Linux), the output is:

capacity = 4294967286 (that's 2^32 - 10)

If replace boost::container::stable_vector with std::vector above, the
output is:

capacity = 10

I know it could as well have been capacity = 20, or capacity = 64 or
whatever but that's still sane behavior. What capacity() returns for
stable_vector seems to be (2^32 - N), N being the requested capacity.
I didn't see such a definition of capacity in the docs:
http://www.boost.org/doc/libs/1_56_0/doc/html/boost/container/stable_vector.html#idp33067968-bb

Thanks,
Arindam


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk