This benefits from the optimizations in std::_Destroy which avoid doing any work when using std::allocator.
libstdc++-v3/ChangeLog: * include/std/stacktrace (basic_stacktrace::_M_impl::_M_resize): Use std::_Destroy to destroy removed elements. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/std/stacktrace | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index 2c0f6ba10a9..f94a424e4cf 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -601,8 +601,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void _M_resize(size_type __n, allocator_type& __alloc) noexcept { - for (size_type __i = __n; __i < _M_size; ++__i) - _AllocTraits::destroy(__alloc, &_M_frames[__i]); + std::_Destroy(_M_frames + __n, _M_frames + _M_size, __alloc); _M_size = __n; } -- 2.47.0