std::generator<Ref,V,Allocator>::promise_type::operator new

From cppreference.com
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (C++20)
Dynamic memory management
Program utilities
Coroutine support (C++20)
Variadic functions
Debugging support
(C++26)
Three-way comparison
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)

 
Coroutine support
Coroutine traits
Coroutine handle
No-op coroutines
Trivial awaitables
Range generators
(C++23)
 
Ranges library
Range access
Range conversions
(C++23)

Range primitives



Dangling iterator handling
Range concepts
Views

Range factories
Range adaptors
Range generators
Range adaptor objects
Range adaptor closure objects
Helper items
(until C++23)(C++23)


 
 
void* operator new( std::size_t size )

    requires std::same_as<Allocator, void> ||

             std::default_initializable<Allocator>;
(1) (since C++23)
template< class Alloc, class... Args >

    requires std::same_as<Allocator, void> ||
             std::convertible_to<const Alloc&, Allocator>
void* operator new( std::size_t size, std::allocator_arg_t,

                    const Alloc& alloc, const Args&... );
(2) (since C++23)
template< class This, class Alloc, class... Args >

    requires std::same_as<Allocator, void> ||
             std::convertible_to<const Alloc&, Allocator>
void* operator new( std::size_t size, const This&, std::allocator_arg_t,

                    const Alloc& alloc, const Args&... );
(3) (since C++23)

Allocates size bytes of uninitialized storage using default or user-provided allocator.

Let A be

  • Allocator, if it is not void,
  • Alloc for (2,3), or
  • std::allocator<void> otherwise.

Let B be std::allocator_traits<A>::template rebind_alloc<U> where U is an unspecified type whose size and alignment are both __STDCPP_DEFAULT_NEW_ALIGNMENT__.

Initializes an allocator b of type B with:

1) A(),
2,3) A(alloc).

Uses b to allocate storage for the smallest array of U sufficient to provide storage for a coroutine state of size size, and unspecified additional state necessary to ensure that operator delete can later deallocate this memory block with an allocator equal to b.

Note: std::allocator_traits<B>::pointer must be of a pointer type, otherwise the behavior is undefined.

Parameters

size - the size of the storage to allocate
alloc - a user provided allocator of type Alloc

Return value

A pointer to the allocated storage.

Exceptions

1-3) May throw.