What is the overhead cost of an empty vector?

As for the question as asked: It depends on the implementation. With MSVC 7.1 this:

std:: cout << sizeof(std::vector<int>) << std::endl;

gives me 16 (bytes). (3 pointers: begin, end, and end of capacity, plus an allocator)

However it should be noted that the pointer-to-vector gives it a larger overhead:

  • in both time and space in the non-empty case
  • in complexity in all cases.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)