[#bsl-allocator_traits-0108-destroy]
= xref:bsl.adoc[bsl]::xref:bsl/allocator_traits-0108.adoc[allocator&lowbar;traits]::destroy
:relfileprefix: ../../
:mrdocs:

Destroy the `ELEMENT&lowbar;TYPE` object at `elementAddr`&period;

== Synopsis

Declared in `&lt;bslma&lowbar;allocatortraits&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ELEMENT&lowbar;TYPE&gt;
static
void
destroy(
    ALLOCATOR&lowbar;TYPE& basicAllocator,
    ELEMENT&lowbar;TYPE* elementAddr);
----

== Description

Destroy the object of (template parameter) type `ELEMENT&lowbar;TYPE` at the specified `elementAddr`, either by 1) calling the `destroy` method on `basicAllocator` with `elemAddr` as the sole argument if the (template parameter) type `ALLOCATOR&lowbar;TYPE` defines such a method, or 2) calling the destructor directly on `elementAddr` (and ignoring `basicAllocator`) otherwise&period; The behavior is undefined unless `elementAddr` refers to a valid, constructed object&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *basicAllocator*
| allocator used for destruction if it provides `destroy`
| *elementAddr*
| address of the object to destroy
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
