News for hackers. Stuff that matters.
Re:I disagree with Linus Torvalds about C++ (2009) by gpderetta on Thursday December 27, 2018 @07:56AM (#18769174)
Interesting. I do remember inspecting _M_begin and end in the debugger.

I can't be bothered to check the implementation now, but the allocated size must be stored somewhere. My first thought of inferring the capacity as the smallest power of two greater than the used size doesn't work as the vector size can shrink without affecting capacity.

Re:I disagree with Linus Torvalds about C++ (2009) by stochastic_monk on Monday December 31, 2018 @03:32PM (#18796796)
The used size is end - begin; the capacity is stored in addition. That’s why sizeof(std::vector<T>) is 24 on x86-64.