23#ifndef STATELESS_ALLOCATOR_INCLUDED
24#define STATELESS_ALLOCATOR_INCLUDED
90template <
class T,
class ALLOC_FUN,
class DEALLOC_FUN = My_free_functor>
119 if (
n == 0)
return nullptr;
120 if (
n >
max_size())
throw std::bad_alloc();
123 if (
p ==
nullptr)
throw std::bad_alloc();
129 template <
class U,
class... Args>
131 assert(
p !=
nullptr);
133 ::new ((
void *)
p)
U(std::forward<Args>(args)...);
140 assert(
p !=
nullptr);
149 return std::numeric_limits<size_t>::max() /
sizeof(T);
158template <
class T,
class ALLOC_FUN,
class DEALLOC_FUN>
164template <
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:91
ptrdiff_t difference_type
Definition: stateless_allocator.h:95
T * pointer
Definition: stateless_allocator.h:97
Stateless_allocator(const Stateless_allocator_type< U > &)
Definition: stateless_allocator.h:113
size_t size_type
Definition: stateless_allocator.h:94
T value_type
Definition: stateless_allocator.h:93
void construct(U *p, Args &&... args)
Definition: stateless_allocator.h:130
pointer address(reference r) const
Definition: stateless_allocator.h:109
const_pointer address(const_reference r) const
Definition: stateless_allocator.h:110
void deallocate(pointer p, size_type n)
Definition: stateless_allocator.h:127
Stateless_allocator & operator=(const Stateless_allocator_type< U > &)
Definition: stateless_allocator.h:116
const T & const_reference
Definition: stateless_allocator.h:101
const T * const_pointer
Definition: stateless_allocator.h:98
void destroy(pointer p)
Definition: stateless_allocator.h:139
Stateless_allocator()=default
pointer allocate(size_type n, const_pointer hint=nullptr)
Definition: stateless_allocator.h:118
T & reference
Definition: stateless_allocator.h:100
size_type max_size() const
Definition: stateless_allocator.h:148
const char * p
Definition: ctype-mb.cc:1234
#define U
Definition: ctype-tis620.cc:73
Header for compiler-dependent features.
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
bool operator==(const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &, const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &)
Definition: stateless_allocator.h:159
bool operator!=(const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &, const Stateless_allocator< T, ALLOC_FUN, DEALLOC_FUN > &)
Definition: stateless_allocator.h:165
Functor struct which invokes my_free.
Definition: stateless_allocator.h:38
void operator()(void *p, size_t) const
Definition: stateless_allocator.cc:27
Definition: stateless_allocator.h:153
Stateless_allocator< U, ALLOC_FUN, DEALLOC_FUN > other
Definition: stateless_allocator.h:154
int n
Definition: xcom_base.cc:508