mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Fix bug in capacity()
See http://stackoverflow.com/q/29727368/2756719; the bit-twiddling version is not equivalent to the original `return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);`; it ends up subtracting, rather than adding, `extra_capacity`.
This commit is contained in:
@@ -1117,7 +1117,7 @@ class stable_vector
|
|||||||
const size_type extra_capacity = (bucket_extra_capacity < node_extra_capacity)
|
const size_type extra_capacity = (bucket_extra_capacity < node_extra_capacity)
|
||||||
? bucket_extra_capacity : node_extra_capacity;
|
? bucket_extra_capacity : node_extra_capacity;
|
||||||
const size_type index_offset =
|
const size_type index_offset =
|
||||||
(ExtraPointers + extra_capacity) & (size_type(0u) - size_type(index_size != 0));
|
(ExtraPointers - extra_capacity) & (size_type(0u) - size_type(index_size != 0));
|
||||||
return index_size - index_offset;
|
return index_size - index_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user