[#BloombergLP-bslma-ConstructionUtil_ConstructionTrait]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::ConstructionUtil&lowbar;ConstructionTrait
:relfileprefix: ../../
:mrdocs:

Metafunction yielding one of the following three `value` constants&colon;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TARGET&lowbar;TYPE,
    class ALLOCATOR&gt;
struct ConstructionUtil&lowbar;ConstructionTrait;
----

== Description

&colon; e&lowbar;USES&lowbar;ALLOCATOR&lowbar;ARG&lowbar;T&lowbar;TRAITS `TARGET&lowbar;TYPE` supports an allocator as&colon; its second constructor argument, after&colon; `bsl&colon;&colon;allocator&lowbar;arg`&period;&colon;&colon; e&lowbar;USES&lowbar;ALLOCATOR&lowbar;TRAITS `TARGET&lowbar;TYPE` supports an allocator as&colon; its last constructor argument&period;&colon;&colon; e&lowbar;NIL&lowbar;TRAITS `TARGET&lowbar;TYPE` does not support an&colon; allocator and&sol;or `ALLOCATOR` is `void&ast;`&colon; `int`, or any other non&hyphen;allocator&colon; scalar&period; The allocator argument to&colon; `construct` will be ignored&period;

`ALLOCATOR` is compatible with an AA `TARGET&lowbar;TYPE` if `ALLOCATOR` is convertible to the allocator type expected by `TARGET&lowbar;TYPE`&apos;s constructors&period; There are three special cases of incompatible `ALLOCATOR` types&colon;

1&period; If `TARGET&lowbar;TYPE` expects an allocator of type `bslma&colon;&colon;Allocator &ast;` this metafunction yields either `e&lowbar;USES&lowbar;ALLOCATOR&lowbar;ARG&lowbar;T&lowbar;TRAITS` or `e&lowbar;USES&lowbar;ALLOCATOR&lowbar;TRAITS`, even if `ALLOCATOR` is not compatible with `TARGET&lowbar;TYPE`&period; The `construct` method will attempt to extract the `bslma&colon;&colon;Allocator &ast;` from the allocator using its `mechanism` accessor&period; If there is no `mechanism` accessor, compilation will fail&period; 2&period; Otherwise, if `bslma&colon;&colon;UsesBslmaAllocator&lt;TARGET&lowbar;TYPE&gt;&colon;&colon;value` is `true`, this metafunction yields either `e&lowbar;USES&lowbar;ALLOCATOR&lowbar;ARG&lowbar;T&lowbar;TRAITS` or `e&lowbar;USES&lowbar;ALLOCATOR&lowbar;TRAITS`, even if `ALLOCATOR` is not compatible with `TARGET&lowbar;TYPE`, resulting in a compilation error within `construct`&period; 3&period; Otherwise, if `ALLOCATOR` is incompatible with `TARGET&lowbar;TYPE`, then `ALLOCATOR` is ignored and this metafunction yields `e&lowbar;NIL&lowbar;TRAITS`, as though `TARGET&lowbar;TYPE` were not AA&period;

The first two special cases allow mixing and matching between `bsl&colon;&colon;allocator` and `bslma&colon;&colon;Allocator &ast;` in both directions, but will fail for other allocator types&period; The failure is desirable to prevent code accidentally passing an incorrect allocator type&period;

The third special case is inconsistent with the other two so as to allow third&hyphen;party classes that use third&hyphen;party allocators to be treated as non&hyphen;AA within containers that use BDE allocators&period;

This metafunction also yields a `type` of &apos;bsl&colon;&colon;integral&lowbar;constant&lt;value, int&gt;&apos;&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/ConstructionUtil_ConstructionTrait/type.adoc[`type`] 
| Integral constant indicating how `TARGET&lowbar;TYPE` uses `ALLOCATOR`&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/ConstructionUtil_ConstructionTrait/_04enum.adoc[`Unnamed enum`] 
| Construction&hyphen;trait enumerator for how `TARGET&lowbar;TYPE` uses `ALLOCATOR`&period;
|===



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