Opened 10 years ago
Closed 6 years ago
#7776 closed Bugs (fixed)
vector::assign(Iter first, Iter last) should be implemented more efficiently
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | container |
Version: | Boost 1.52.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
Current implementation of vector::assign(Iter first, Iter last) is same behavior whether Iter is ForwardIterator or not. (First, overwrite to current elements, then erase or insert)
But if Iter is ForwardIterator and capacity() < distance(first, last), it is only necessary to discard old buffer (including its contents) and allocate new buffer which capacity is at least distance(first, last).
Note: according to C++11 specification, value_type need not be MoveInsertable into Container if Iter is ForwardIterator.
Note:
See TracTickets
for help on using tickets.
Reviewing old bugs. Seems like this was fixed in commit:
https://github.com/boostorg/container/commit/f2947c115eca4a8d5da0340e469a87d09588718c
and official at least since Boost 1.56. Thanks for the report.