8#ifndef ADOBE_MEMORY_HPP
9#define ADOBE_MEMORY_HPP
39 bool operator()(
const T* x)
const throw() {
return x == NULL; }
45 bool operator()(
const T* x)
const throw() {
return x == NULL; }
71template <
typename X,
class Traits>
74template <
typename ptrT>
174#ifndef NO_DOCUMENTATION
181namespace implementation {
183struct adobe_static_assert;
185struct adobe_static_assert<true> {};
204template <
typename X,
class Traits = ptr_traits<X>>
206 struct clear_type {};
207 operator int()
const;
218 template <typename Y>
222 template <typename Y>
237 operator
bool() const throw() {
return (pointer_m != NULL); }
255 template <
typename Y>
struct error_on_const_auto_type;
256 template <
typename Y>
struct error_on_const_auto_type<
auto_resource<Y, typename
traits_type::template rebind<Y>::other> const>
260 auto_resource(Y& rhs,
typename error_on_const_auto_type<Y>::type = 0);
268template <
typename X,
class Traits>
271template <
typename X,
class Traits>
274template <
typename X,
class Traits>
277 auto_resource<Y,
typename traits_type::template rebind<Y>::other>
const& x)
throw()
281template <
typename X,
class Traits>
287template <
typename X,
class Traits>
290 auto_resource<Y,
typename traits_type::template rebind<Y>::other> x)
throw() {
295template <
typename X,
class Traits>
297 traits_type::delete_ptr(pointer_m);
302template <
typename X,
class Traits>
310template <
typename X,
class Traits>
316template <
typename X,
class Traits>
323template <
typename X,
class Traits>
325 if (pointer_m != p) {
326 traits_type::delete_ptr(pointer_m);
333template <
typename X,
class Traits>
349template <
class T,
class... Args>
351 return ::new (
static_cast<void*
>(p)) T(std::forward<Args>(args)...);
354template <
typename T,
typename U>
355[[deprecated(
"Use adobe::construct_at(p, x)")]]
constexpr auto construct(T* p, U&& x) {
360[[deprecated(
"Use adobe::construct_at(p)")]]
constexpr auto construct(T* p) {
391inline namespace version_1 {
397 void* (*new_)(std::size_t);
433 template <
typename U>
439 template <
typename U>
451 throw std::bad_alloc();
452 pointer result =
static_cast<pointer>(new_delete_m->new_(n *
sizeof(T)));
454 throw std::bad_alloc();
463 return x.new_delete_m == y.new_delete_m;
467 return x.new_delete_m != y.new_delete_m;
511 T&
get() {
return *
static_cast<T*
>(storage()); }
512 const T&
get()
const {
return *
static_cast<const T*
>(storage()); }
517 enum { word_size = 16 };
520 storage_t[((
sizeof(T) + (word_size - 1)) / word_size) * (word_size /
sizeof(
double))];
522 void* storage() {
return &data_m; }
523 const void* storage()
const {
return &data_m; }
526 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