C++ Logo

STD-DISCUSSION

Advanced search

Subject: [Potential defect] std::vector::push_back reallocation wording
From: Florian Mayer (florian.mayer_at_[hidden])
Date: 2020-06-30 06:52:43


Hi everyone!

I noticed something while reading the standard.

The Remarks for push_back / emplace_back [1] in all the standards from
C++11 to the current draft say

> Remarks: Causes reallocation if the new size is greater than the old
capacity

Logically, this means 'size > capacity IMPLIES rellocation'. By ex falso
quodlibet, this means that rellocations can happen even if size <=
capacity, but it also means that a reallocation HAS to happen if size >
capacity.

I am pretty sure that is not the intention, and it should say "Causes
reallocation *only* if the new size is greater than the old capacity."

Is that correct?

Thanks,
Florian

[1]: http://eel.is/c++draft/vector#modifiers-1.sentence-1



STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups