# std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>::destroy

> C++ Atlas: `cppatlas.com/w/cpp/memory/scoped_allocator_adaptor/destroy` | Source: https://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor/destroy | Domain: Memory management | Standards: C++11, C++20

Uses the outer allocator to call the destructor of the object pointed to by p, by calling

## Official Specification Summary (cppreference)

```cpp
// Defined in header <scoped_allocator>

template< class T >
void destroy( T* p ); // (since C++11)
```

Uses the outer allocator to call the destructor of the object pointed to by `p`, by calling

`std::allocator_traits<OUTERMOST>::destroy(OUTERMOST(*this), p)`

where OUTERMOST is the type that would be returned by calling `this->outer_allocator()`, and then calling the `outer_allocator()` member function recursively on the result of this call until reaching the type that has no such member function.

### Parameters

- `p` - pointer to the object that is going to be destroyed

### Return value

(none)

### See also

- [`destroy`](https://en.cppreference.com/w/cpp/memory/allocator_traits/destroy) [static]: destructs an object stored in the allocated storage (function template)
- [`destroy`](https://en.cppreference.com/w/cpp/memory/allocator/destroy) (until C++20): destructs an object in allocated storage (public member function of `std::allocator<T>`)

---
Attribution: content from https://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor/destroy (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.