What is the overhead cost of an empty vector?

后端 未结 6 1492
野性不改
野性不改 2020-12-06 04:24

What is the memory overhead of having an empty vector vs having a pointer to a vector?

Option A:

std::vector v;

Option B

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 04:54

    It's completely implementation-dependent and you should neither assume nor rely on the details. For what it's worth it's 20-bytes using VC.

提交回复
热议问题