1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
19 typedef size_t size_type;
20 typedef ptrdiff_t difference_type;
21 typedef void* pointer;
22 typedef const void* const_pointer;
23 typedef void value_type;
28 typedef allocator<U> allocator;
35 inline allocator(CompAllocator* pAlloc);
38 inline allocator(const allocator<U>& alloc);
40 inline allocator(const allocator& alloc);
43 inline allocator& operator=(const allocator<U>& alloc);
46 CompAllocator* m_pAlloc;
48 friend class allocator;
51 allocator<void>::allocator(CompAllocator* pAlloc)
56 allocator<void>::allocator(const allocator& alloc)
57 : m_pAlloc(alloc.m_pAlloc)
62 allocator<void>::allocator(const allocator<U>& alloc)
63 : m_pAlloc(alloc.m_pAlloc)
68 allocator<void>& allocator<void>::operator=(const allocator<U>& alloc)
70 m_pAlloc = alloc.m_pAlloc;
78 typedef size_t size_type;
79 typedef ptrdiff_t difference_type;
82 typedef const T* const_pointer;
83 typedef const T& const_reference;
89 allocator(CompAllocator* pAlloc);
92 allocator(const allocator<U>& alloc);
94 allocator(const allocator& alloc);
97 allocator& operator=(const allocator<U>& alloc);
99 pointer address(reference val);
100 const_pointer address(const_reference val) const;
101 pointer allocate(size_type count, allocator<void>::const_pointer hint = nullptr);
102 void construct(pointer ptr, const_reference val);
103 void deallocate(pointer ptr, size_type size);
104 void destroy(pointer ptr);
105 size_type max_size() const;
106 template <typename U>
109 typedef allocator<U> allocator;
113 CompAllocator* m_pAlloc;
114 template <typename U>
115 friend class allocator;
118 } // end of namespace jitstd
124 template <typename T>
125 allocator<T>::allocator(CompAllocator* pAlloc)
130 template <typename T>
131 template <typename U>
132 allocator<T>::allocator(const allocator<U>& alloc)
133 : m_pAlloc(alloc.m_pAlloc)
137 template <typename T>
138 allocator<T>::allocator(const allocator<T>& alloc)
139 : m_pAlloc(alloc.m_pAlloc)
143 template <typename T>
144 template <typename U>
145 allocator<T>& allocator<T>::operator=(const allocator<U>& alloc)
147 m_pAlloc = alloc.m_pAlloc;
151 template <typename T>
152 typename allocator<T>::pointer allocator<T>::address(reference val)
157 template <typename T>
158 typename allocator<T>::const_pointer allocator<T>::address(const_reference val) const
163 template <typename T>
164 T* allocator<T>::allocate(size_type count, allocator<void>::const_pointer hint)
166 return (pointer) m_pAlloc->Alloc(sizeof(value_type) * count);
169 template <typename T>
170 void allocator<T>::construct(pointer ptr, const_reference val)
172 new (ptr, placement_t()) value_type(val);
175 template <typename T>
176 void allocator<T>::deallocate(pointer ptr, size_type size)
178 // m_pAlloc->Free(ptr);
181 template <typename T>
182 void allocator<T>::destroy(pointer ptr)
187 template <typename T>
188 typename allocator<T>::size_type allocator<T>::max_size() const
190 return (size_type) -1;
193 } // end of namespace jitstd