8#ifndef ADOBE_MEMORY_HPP
9#define ADOBE_MEMORY_HPP
11#include <adobe/config.hpp>
36 bool operator()(
const T* x)
const throw() {
return x == NULL; }
42 bool operator()(
const T* x)
const throw() {
return x == NULL; }
68template <
typename X,
class Traits>
71template <
typename ptrT>
171#ifndef NO_DOCUMENTATION
178namespace implementation {
180struct adobe_static_assert;
182struct adobe_static_assert<true> {};
201template <
typename X,
class Traits = ptr_traits<X>>
203 struct clear_type {};
204 operator int()
const;
215 template <typename Y>
219 template <typename Y>
234 operator
bool() const throw() {
return (pointer_m != NULL); }
252 template <
typename Y>
struct error_on_const_auto_type;
253 template <
typename Y>
struct error_on_const_auto_type<
auto_resource<Y, typename
traits_type::template rebind<Y>::other> const>
257 auto_resource(Y& rhs,
typename error_on_const_auto_type<Y>::type = 0);
265template <
typename X,
class Traits>
268template <
typename X,
class Traits>
271template <
typename X,
class Traits>
274 auto_resource<Y,
typename traits_type::template rebind<Y>::other>
const& x)
throw()
278template <
typename X,
class Traits>
284template <
typename X,
class Traits>
287 auto_resource<Y,
typename traits_type::template rebind<Y>::other> x)
throw() {
292template <
typename X,
class Traits>
294 traits_type::delete_ptr(pointer_m);
299template <
typename X,
class Traits>
307template <
typename X,
class Traits>
313template <
typename X,
class Traits>
320template <
typename X,
class Traits>
322 if (pointer_m != p) {
323 traits_type::delete_ptr(pointer_m);
330template <
typename X,
class Traits>
346template <
class T,
class... Args>
348 return ::new (
static_cast<void*
>(p)) T(std::forward<Args>(args)...);
351template <
typename T,
typename U>
352[[deprecated(
"Use adobe::construct_at(p, x)")]]
constexpr auto construct(T* p, U&& x) {
357[[deprecated(
"Use adobe::construct_at(p)")]]
constexpr auto construct(T* p) {
388inline namespace version_1 {
394 void* (*new_)(std::size_t);
430 template <
typename U>
436 template <
typename U>
448 throw std::bad_alloc();
449 pointer result =
static_cast<pointer>(new_delete_m->new_(n *
sizeof(T)));
451 throw std::bad_alloc();
460 return x.new_delete_m == y.new_delete_m;
464 return x.new_delete_m != y.new_delete_m;
508 T&
get() {
return *
static_cast<T*
>(storage()); }
509 const T&
get()
const {
return *
static_cast<const T*
>(storage()); }
514 enum { word_size = 16 };
517 storage_t[((
sizeof(T) + (word_size - 1)) / word_size) * (word_size /
sizeof(
double))];
519 void* storage() {
return &data_m; }
520 const void* storage()
const {
return &data_m; }
523 static_assert(
sizeof(T) <=
sizeof(storage_t));
The template class auto_resource< X, Traits > provides similar functionality to unique_ptr for resour...
traits_type::element_type element_type
void reset(pointer_type p=0)
traits_type::pointer_type pointer_type
auto_resource(pointer_type p=0)
auto_resource & operator=(auto_resource &)
friend bool operator!=(const capture_allocator &, const capture_allocator &)
const void * const_pointer
friend bool operator==(const capture_allocator &, const capture_allocator &)
capture_allocator(const capture_allocator &)=default
capture_allocator(const capture_allocator< U > &x)
void deallocate(pointer p, size_type)
friend bool operator!=(const capture_allocator &x, const capture_allocator &y)
pointer address(reference x) const
void construct(pointer p, const T &x)
const_pointer address(const_reference x) const
capture_allocator & operator=(const capture_allocator &)=default
const new_delete_t * new_delete() const
size_type max_size() const
friend bool operator==(const capture_allocator &x, const capture_allocator &y)
std::ptrdiff_t difference_type
pointer allocate(size_type n, capture_allocator< void >::const_pointer=0)
const U & const_reference
capture_allocator(capture_allocator &&) noexcept=default
const new_delete_t local_new_delete_g
constexpr auto construct(T *p, U &&x)
F uninitialized_move(I f, I l, F r)
Similar to std::uninitialized_copy but with move semantics.
T * construct_at(T *p, Args &&... args)
aligned_storage & operator=(aligned_storage x)
aligned_storage(const aligned_storage &x)
friend void swap(aligned_storage &x, aligned_storage &y)
aligned_storage(aligned_storage &&x)
void operator()(const T *x) const
void operator()(const T *x) const
bool operator()(const T *x) const
bool operator()(const T *x) const
adobe::ptr_traits< U > other
static void delete_ptr(pointer_type x)
static bool empty_ptr(const_pointer_type x)
const pointer_type const_pointer_type
adobe::ptr_traits< U > other
static void delete_ptr(pointer_type x)
static bool empty_ptr(const_pointer_type x)
const T * const_pointer_type
capture_allocator< U > other
capture_allocator< U > other