31 #ifndef _MALLOC_ALLOCATOR_H
32 #define _MALLOC_ALLOCATOR_H 1
39 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
54 template<
typename _Tp>
58 typedef size_t size_type;
59 typedef ptrdiff_t difference_type;
61 typedef const _Tp* const_pointer;
62 typedef _Tp& reference;
63 typedef const _Tp& const_reference;
64 typedef _Tp value_type;
66 template<
typename _Tp1>
74 template<
typename _Tp1>
76 _GLIBCXX_USE_NOEXCEPT { }
81 address(reference __x)
const _GLIBCXX_NOEXCEPT
85 address(const_reference __x)
const _GLIBCXX_NOEXCEPT
91 allocate(size_type __n,
const void* = 0)
93 if (__n > this->max_size())
94 std::__throw_bad_alloc();
96 pointer __ret =
static_cast<_Tp*
>(std::malloc(__n *
sizeof(_Tp)));
98 std::__throw_bad_alloc();
104 deallocate(pointer __p, size_type)
105 { std::free(static_cast<void*>(__p)); }
108 max_size()
const _GLIBCXX_USE_NOEXCEPT
109 {
return size_t(-1) /
sizeof(_Tp); }
111 #ifdef __GXX_EXPERIMENTAL_CXX0X__
112 template<
typename _Up,
typename... _Args>
114 construct(_Up* __p, _Args&&... __args)
115 { ::new((
void *)__p) _Up(std::forward<_Args>(__args)...); }
117 template<
typename _Up>
119 destroy(_Up* __p) { __p->~_Up(); }
124 construct(pointer __p,
const _Tp& __val)
125 { ::new((
void *)__p) value_type(__val); }
128 destroy(pointer __p) { __p->~_Tp(); }
132 template<
typename _Tp>
137 template<
typename _Tp>
139 operator!=(
const malloc_allocator<_Tp>&,
const malloc_allocator<_Tp>&)
142 _GLIBCXX_END_NAMESPACE_VERSION
An allocator that uses malloc.This is precisely the allocator defined in the C++ Standard.
_Tp * __addressof(_Tp &__r) _GLIBCXX_NOEXCEPT
Same as C++11 std::addressof.