]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Simplify std::vector::vector(from_range_t, const Alloc&)
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 Mar 2025 09:52:35 +0000 (09:52 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 21 Mar 2025 10:28:06 +0000 (10:28 +0000)
commit3e1d760bf49d0e9a89dcfa0450a6d1ae5ceb756e
tree7186bd774fb7ef7ae70a75e53430e97905a75c67
parent3355e44dd2b35488facfec66aad628c5999c89d6
libstdc++: Simplify std::vector::vector(from_range_t, const Alloc&)

Tomasz suggested replacing this constructor with just append_range(rg),
after using a delegating constructor so that the destructor will run if
append_range exits via an exception.

This is slightly less simple than his suggestion, because I want to
avoid the overhead of reserve's slow path and the ASan annotations.
Neither of those is needed for this constructor, because we have no
existing storage to reallocate and no unused capacity to tell ASan
about.

libstdc++-v3/ChangeLog:

* include/bits/stl_vector.h (vector(from_range_t, Alloc)): Use
delegating constructor instead of RAII guards. Use append_range
for unsized input range case.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/bits/stl_vector.h