This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C++ std::vector minimum capacity

Hello!

I have recently noticed that when you have a non empty std::vector it has a minimum capacity of 32 elements. No matter how big the elements are. So I was wondering if this can be set to a different value. On windows the vector capacity grows nicely from 1 onwards.

Example:

struct BigStruct
{
    char k;
    int i[100];
};

void minSizeTest()
{
    std::vector<int> vec(10, 1337); // vec.size() == 10, vec.capacity() == 32

    std::vector<BigStruct> vBig(10); // same as above! 32*sizeof(BigStruct) is a lot for my microprocessor :)
}