FreeBSD Manual Pages
std::alloca...ts::allocate(3) C++ Standard Libarystd::alloca...ts::allocate(3) NAME std::allocator_traits::allocate - std::allocator_traits::allocate Synopsis Defined in header <memory> static pointer allocate( Alloc& a, size_type n (since C++11) ); (until C++20) [[nodiscard]] static constexpr pointer allocate( (since C++20) Alloc& a, size_type n ); static pointer allocate( Alloc& a, size_type n, (since C++11) const_void_pointer hint (1) (until C++20) ); [[nodiscard]] static constexpr pointer allocate( (2) Alloc& a, size_type n, (since C++20) const_void_pointer hint ); Uses the allocator a to allocate n * sizeof(Alloc::value_type) bytes of uninitialized storage. An array of type Alloc::value_type[n] is cre- ated in the storage, but none of its elements are constructed. 1) Calls a.allocate(n). 2) Additionally passes memory locality hint hint. Calls a.allo- cate(n, hint) if possible. If not possible (e.g. a has no two-argument member func- tion allocate), calls a.allocate(n). Parameters a - allocator to use n - the number of objects to allocate storage for hint - pointer to a nearby memory location Return value The pointer returned by the call to a.allocate(n). Notes Alloc::allocate was not required to create array object until P0593R6, which made using non-default allocator for std::vector and some other contain- ers not well-defined according to a strict reading of the core language specification. After calling allocate and before construction of elements, pointer arithmetic of Alloc::value_type* is well-defined within the allocated array, but the behavior is undefined if elements are accessed. Example This section is incomplete Reason: no example See also allocate allocates uninitialized storage (public member function of std::allocator<T>) Category: * Todo no example http://cppreference.com 2024.06.10 std::alloca...ts::allocate(3)
NAME | Synopsis | Parameters | Return value | Notes | Example | See also | Category:
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::allocator_traits::allocate&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>
