std::make_o...ng_allocator(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ¦‹ 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 to T'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 to
  • uninitialized_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