https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110057
--- Comment #16 from user202729 <user202729 at protonmail dot com> --- (In reply to Jonathan Wakely from comment #14) > So something like this, and then use it in containers instead of > _Alloc_traits::destroy > > template<typename _Tp, typename _Allocator> > _GLIBCXX20_CONSTEXPR > void > _Destroy_static_type(_Tp* __p, _Allocator& __alloc) > { > #if __cplusplus >= 201103L > if constexpr (__allocator_traits_base::__has_destroy<_Allocator, _Tp>) > allocator_traits<_Allocator>::destroy(__alloc, __p); > else > #endif > __p->_Tp::~_Tp(); > } That sound like a good idea, thanks. I thought about this some time earlier (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115413#c3) but I did not know how to check the implementation of `destroy()`. Nevertheless, this does not handle the case of devirtualization in vector access (e.g. `v[0].f()` where v is a vector and method f is virtual). What do you think? Apart from that, being do you think it is common for the user to override `destroy()` (in a template specialization) but still call the destructor inside it? In that case the proposal would not optimize that case.