std::make_o...ng_allocator(3)
π¦ std::make_obj_using_allocator(3) β the C++ Standard Library bestie page π
okay so bestie, we're talking <std::make_obj_using_allocator> today β it lives in the C++ Standard Library, and honestly? she's giving allocator-aware-construction main character energy and I'm obsessed β¨
β¨ NAME β¨
std::make_obj_using_allocator β literally just std::make_obj_using_allocator, no notes, that's her name, periodt π
πΈ SYNOPSIS πΈ
Defined in header <memory> β don't forget her, she lives there π
template< class T, class Alloc, class... Args >
constexpr T make_obj_using_allocator( const Alloc& alloc, Args&&... args );
lowkey important: she's since C++20 ποΈβ¨
So what does she do? She creates an object of the given type T by means of uses-allocator construction π«Ά that's the whole vibe.
She's equivalent to this exact thing right here β no cap, character for character:
return std::make_from_tuple<T>(
std::uses_allocator_construction_args<T>(alloc, std::forward<Args>(args)...)
);
like the way that she just forwards everything into uses_allocator_construction_args and hands it to make_from_tuple? iconic. ate. no crumbs. π₯
π PARAMETERS π
allocβ the allocator to use π§ (she's the one doing the allocating, obviously)argsβ the arguments to pass toT's constructor π (they get forwarded, as one does)
π RETURN VALUE π
The newly-created object of type T. that's it. that's the return value. she made you a T and she's proud of it πβ¨
π EXCEPTIONS π
ngl, she may throw any exception thrown by the constructor of T β which typically includes std::bad_alloc π so like, be aware, bestie. constructor goes brrr, exceptions come out. fr fr.
π EXAMPLE π
This section is incomplete Reason: no example
yeah... there's no example yet π she's a work in progress, and honestly? relatable. the docs said "no example" and we respect the honesty π
β SEE ALSO β
uses_allocator_construction_args(C++20)β prepares the argument list matching the flavor of uses-allocator construction required by the given type (function template) π β she's the setup queen, she preps the args so you don't have touninitialized_construct_using_allocator(C++20)β creates an object of the given type at specified memory location by means of uses-allocator construction (function template) π¦ β same energy but she builds in place, at a memory location you pick
π§ CATEGORY π§
- Todo no example πΈ (yes, that's the actual category, and that's the actual todo, and honestly? we stan a transparent queen)
and that's the page, bestie! π no example yet, but all the allocator-aware construction facts are here and they're slaying.
made with love for [cppreference.com](http://cppreference.com), version 2024.06.10 πβ¨ β catch you in the next manpage, mwah! π π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms