PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::obj::standard_alloc_policy< T > Class Template Reference

The allocation policy template for a given type. More...

#include <libpmemobj++/allocator.hpp>

Inheritance diagram for pmem::obj::standard_alloc_policy< T >:

Classes

struct  rebind
 Rebind to a different type. More...
 

Public Types

using value_type = T
 
using pointer = persistent_ptr< value_type >
 
using const_void_pointer = persistent_ptr< const void >
 
using size_type = std::size_t
 
using bool_type = bool
 

Public Member Functions

 standard_alloc_policy ()=default
 Defaulted constructor.
 
 ~standard_alloc_policy ()=default
 Defaulted destructor.
 
 standard_alloc_policy (standard_alloc_policy const &)
 Explicit copy constructor.
 
template<typename U , typename = typename std::enable_if< std::is_convertible<U *, T *>::value>::type>
 standard_alloc_policy (standard_alloc_policy< U > const &)
 Type converting constructor.
 
pointer allocate (size_type cnt, const_void_pointer=0)
 Allocate storage for cnt objects of type T. More...
 
void deallocate (pointer p, size_type=0)
 Deallocates storage pointed to p, which must be a value returned by a previous call to allocate that has not been invalidated by an intervening call to deallocate. More...
 
size_type max_size () const
 The largest value that can meaningfully be passed to allocate(). More...
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename T2 >
bool operator== (standard_alloc_policy< T > const &, standard_alloc_policy< T2 > const &)
 Determines if memory from another allocator can be deallocated from this one. More...
 
template<typename T , typename OtherAllocator >
bool operator== (standard_alloc_policy< T > const &, OtherAllocator const &)
 Determines if memory from another allocator can be deallocated from this one. More...
 

Detailed Description

template<typename T>
class pmem::obj::standard_alloc_policy< T >

The allocation policy template for a given type.

Can be specialized, if necessary, for a given type. Designed to be used with C++ allocators.

Member Function Documentation

◆ allocate()

template<typename T >
pointer pmem::obj::standard_alloc_policy< T >::allocate ( size_type  cnt,
const_void_pointer  = 0 
)
inline

Allocate storage for cnt objects of type T.

Does not construct the objects.

Parameters
[in]cntthe number of objects to allocate memory for.
Exceptions
transaction_scope_errorif called outside of an active transaction.
transaction_out_of_memoryif there is no free memory of requested size.
transaction_alloc_erroron transactional allocation failure.

◆ deallocate()

template<typename T >
void pmem::obj::standard_alloc_policy< T >::deallocate ( pointer  p,
size_type  = 0 
)
inline

Deallocates storage pointed to p, which must be a value returned by a previous call to allocate that has not been invalidated by an intervening call to deallocate.

Parameters
[in]ppointer to the memory to be deallocated.
Exceptions
transaction_scope_errorif called outside of an active transaction.
transaction_free_erroron transactional free failure.

◆ max_size()

template<typename T >
size_type pmem::obj::standard_alloc_policy< T >::max_size ( ) const
inline

The largest value that can meaningfully be passed to allocate().

Returns
largest value that can be passed to allocate.

Friends And Related Function Documentation

◆ operator==() [1/2]

template<typename T , typename OtherAllocator >
bool operator== ( standard_alloc_policy< T > const &  ,
OtherAllocator const &   
)
related

Determines if memory from another allocator can be deallocated from this one.

Returns
false.

◆ operator==() [2/2]

template<typename T , typename T2 >
bool operator== ( standard_alloc_policy< T > const &  ,
standard_alloc_policy< T2 > const &   
)
related

Determines if memory from another allocator can be deallocated from this one.

Returns
true.

The documentation for this class was generated from the following file: