
8 Feb
2008
8 Feb
'08
12:59 a.m.
When I use copy_range() to assign a range to an existing container an unnecessary temporary object is created then assigned to the target. This can be inefficient, especially if the target is a vector or string which may have a large enough capacity() that no reallocation is required for the assignment. Therefore, I’d like to request a new range algorithm, assign_from_range, that is defined as follows: template<class Sequence, class ForwardRange> inline Sequence &assign_from_range(Sequence &target, const ForwardRange &r) { return target.assign(begin(r), end(r)); } Joe Gottman