24#ifndef STATELESS_ALLOCATOR_INCLUDED
25#define STATELESS_ALLOCATOR_INCLUDED
91template <
class T,
class ALLOC_FUN,
class DEALLOC_FUN = My_free_functor>
120 if (
n == 0)
return nullptr;
121 if (
n >
max_size())
throw std::bad_alloc();
124 if (
p ==
nullptr)
throw std::bad_alloc();
130 template <
class U,
class... Args>
132 assert(
p !=
nullptr);
134 ::new ((
void *)
p)
U(std::forward<Args>(args)...);
141 assert(
p !=
nullptr);
150 return std::numeric_limits<size_t>::max() /
sizeof(T);
159template <
class T,
class ALLOC_FUN,
class DEALLOC_FUN>
165template <
class T,
class ALLOC_FUN,
class DEALLOC_FUN>
Stateless_allocator is a C++ STL memory allocator skeleton based on Malloc_allocator,...
Definition: stateless_allocator.h:92
ptrdiff_t difference_type
Definition: stateless_allocator.h:96
T * pointer
Definition: stateless_allocator.h:98
Stateless_allocator(const Stateless_allocator_type< U > &)
Definition: stateless_allocator.h:114
size_t size_type
Definition: stateless_allocator.h:95
T value_type
Definition: stateless_allocator.h:94
void construct(U *p, Args &&... args)
Definition: stateless_allocator.h:131
pointer address(reference r) const
Definition: stateless_allocator.h:110
const_pointer address(const_reference r) const
Definition: stateless_allocator.h:111
void deallocate(pointer p, size_type n)
Definition: stateless_allocator.h:128
Stateless_allocator & operator=(const Stateless_allocator_type< U > &)
Definition: stateless_allocator.h:117
const T & const_reference
Definition: stateless_allocator.h:102
const T * const_pointer
Definition: stateless_allocator.h:99
void destroy(pointer p)
Definition: stateless_allocator.h:140
Stateless_allocator()=default
pointer allocate(size_type n, const_pointer hint=nullptr)
Definition: stateless_allocator.h:119
T & reference
Definition: stateless_allocator.h:101
size_type max_size() const
Definition: stateless_allocator.h:149
const char * p
Definition: ctype-mb.cc:1235
#define U
Definition: ctype-tis620.cc:74
Header for compiler-dependent features.
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
bool operator==(const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &, const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &)
Definition: stateless_allocator.h:160
bool operator!=(const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &, const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &)
Definition: stateless_allocator.h:166
Functor struct which invokes my_free.
Definition: stateless_allocator.h:39
void operator()(void *p, size_t) const
Definition: stateless_allocator.cc:28
Definition: stateless_allocator.h:154
Stateless_allocator< U, ALLOC_FUN, DEALLOC_FUN > other
Definition: stateless_allocator.h:155
int n
Definition: xcom_base.cc:509