thrust::mr::allocator
Defined in thrust/mr/allocator.h
- 
template<typename T, class MR>
 class allocator : private thrust::mr::validator<MR>
- An - mr::allocatoris a template that fulfills the C++ requirements for Allocators, allowing to use the NPA-based memory resources where an Allocator is required. Unlike memory resources, but like other allocators,- mr::allocatoris typed and bound to allocate object of a specific type, however it can be freely rebound to other types.- Template Parameters
- T – the type that will be allocated by this allocator. 
- MR – the upstream memory resource to use for memory allocation. Must derive from - thrust::mr::memory_resourceand must be- final(in C++11 and beyond).
 
 - Public Types - 
using pointer = typename thrust::detail::pointer_traits<void_pointer>::template rebind<T>::other
- The pointer type allocated by this allocator. Equivaled to the pointer type of - MRrebound to- T.
 - 
using const_pointer = typename thrust::detail::pointer_traits<void_pointer>::template rebind<const T>::other
- The pointer to const type. Equivalent to a pointer type of - MRrebound to- const T.
 - 
using reference = typename thrust::detail::pointer_traits<pointer>::reference
- The reference to the type allocated by this allocator. Supports smart references. 
 - 
using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference
- The const reference to the type allocated by this allocator. Supports smart references. 
 - 
using difference_type = typename thrust::detail::pointer_traits<pointer>::difference_type
- The difference type between pointers allocated by this allocator. 
 - 
using propagate_on_container_copy_assignment = detail::true_type
- Specifies that the allocator shall be propagated on container copy assignment. 
 - 
using propagate_on_container_move_assignment = detail::true_type
- Specifies that the allocator shall be propagated on container move assignment. 
 - 
using propagate_on_container_swap = detail::true_type
- Specifies that the allocator shall be propagated on container swap. 
 - Public Functions - 
inline size_type max_size() const
- Calculates the maximum number of elements allocated by this allocator. - Returns
- the maximum value of - std::size_t, divided by the size of- T.
 
 - 
inline allocator(MR *resource)
- Constructor. - Parameters
- resource – the resource to be used to allocate raw memory. 
 
 - 
template<typename U>
 inline allocator(const allocator<U, MR> &other)
- Copy constructor. Copies the resource pointer. 
 - 
inline pointer allocate(size_type n)
- Allocates objects of type - T.- Parameters
- n – number of elements to allocate 
- Returns
- a pointer to the newly allocated storage. 
 
 - 
template<typename U>
 struct rebind
- The - rebindmetafunction provides the type of an- allocatorinstantiated with another type.- Template Parameters
- U – the other type to use for instantiation.