[#bsl-allocator_traits-0ae-allocate-02]
= xref:bsl.adoc[bsl]::xref:bsl/allocator_traits-0ae.adoc[allocator&lowbar;traits&lt;std::allocator&lt;ALLOCATOR&lowbar;TYPE&gt;&gt;]::allocate
:relfileprefix: ../../
:mrdocs:

Allocate memory&period;

== Synopses

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

Allocate memory&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
static
pointer
xref:bsl/allocator_traits-0ae/allocate-07.adoc[allocate](
    &lowbar;Alloc& &lowbar;&lowbar;a,
    size&lowbar;type &lowbar;&lowbar;n);
----

[.small]#xref:bsl/allocator_traits-0ae/allocate-07.adoc[_» more&period;&period;&period;_]#

Allocate memory&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
static
pointer
xref:bsl/allocator_traits-0ae/allocate-01.adoc[allocate](
    &lowbar;Alloc& &lowbar;&lowbar;a,
    size&lowbar;type &lowbar;&lowbar;n,
    const&lowbar;void&lowbar;pointer &lowbar;&lowbar;hint);
----

[.small]#xref:bsl/allocator_traits-0ae/allocate-01.adoc[_» more&period;&period;&period;_]#

== Return Value

Memory of suitable size and alignment for _n_ objects of type `value&lowbar;type`

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *&lowbar;&lowbar;a*
| An allocator&period;
| *&lowbar;&lowbar;n*
| The number of objects to allocate space for&period;
| *&lowbar;&lowbar;hint*
| Aid to locality&period;
|===


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