std::scoped...or::allocate(3)

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

πŸ’– NAME πŸ’–

okay bestie, this is std::scoped_allocator_adaptor::allocate β€” page title std::scoped...or::allocate(3) β€” from the C++ Standard Libary manual, section 3. The whole point? It uses the outer allocator to allocate uninitialized storage. That's the vibe. πŸ’…

✨ Synopsis ✨

Defined in header <scoped_allocator>.

The source dump got a lil scrambled with the (1) / (2) labels, but they're the two overloads β€” no hint, and with hint β€” and these signatures are exact.
pointer allocate( size_type n );                         (1) (since C++11) (until C++20)
[[nodiscard]] pointer allocate( size_type n );                 (since C++20)
pointer allocate( size_type n, const_void_pointer hint ); (2) (since C++11) (until C++20)
[[nodiscard]] pointer allocate( size_type n, const_void_pointer hint ); (since C++20)

Overload (1) calls std::allocator_traits<OuterAlloc>::allocate(outer_allocator(), n).

Overload (2) additionally provides a memory locality hint, by calling std::allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint).

πŸ“ Parameters πŸ“

  • n β€” the number of objects to allocate storage for. literally how many thingies you're making room for.
  • hint β€” pointer to a nearby memory location. a lil "maybe put it around here" suggestion.

🫢 Return value 🫢

The pointer to the allocated storage. that's your address, bestie. πŸ’–

πŸ‘‘ See also πŸ‘‘

  • allocate allocates uninitialized storage β€” public member function of std::allocator<T>
  • allocate allocates uninitialized storage using the allocator β€” [static] public static member function of std::allocator_traits<Alloc>

kisses and allocator dust πŸ’…βœ¨ β€” source http://cppreference.com, version 2024.06.10, page std::scoped...or::allocate(3).

πŸ“¦ where this page comes from