Usermode/libc++ - Debug in cxa code, list emplace and iterators, general STL fixes
[tpg/acess2.git] / Usermode / Libraries / libc++.so_src / include_exp / allocator
1 /*
2  * Acess2 C++ Library
3  * - By John Hodge (thePowersGang)
4  *
5  * string (header)
6  * - C++'s String type
7  */
8 #ifndef _LIBCXX_ALLOCATOR_
9 #define _LIBCXX_ALLOCATOR_
10
11 #include "_libcxx_helpers.h"
12
13 #include "new"
14 #include "cstddef"
15 #include "utility"
16
17 namespace std {
18
19 template <class T> class allocator
20 {
21 public:
22         typedef T       value_type;
23         typedef T*      pointer;
24         typedef T&      reference;
25         typedef const T* const_pointer;
26         typedef const T&        const_reference;
27         typedef size_t  size_type;
28         typedef ptrdiff_t       difference_type;
29         
30         template <class Type>
31         struct rebind
32         {
33                 typedef allocator<Type> other;
34         };
35         
36         allocator() throw() {
37         }
38         allocator(const allocator& alloc __attribute__((unused))) throw() {
39         }
40         template <class U>
41         allocator(const allocator<U>& alloc) throw() {
42         }
43         ~allocator() throw() {
44         }
45         
46         pointer address(reference x) const {
47                 return &x;
48         }
49         const_pointer address(const_reference x) const {
50                 return &x;
51         }
52         pointer allocate(size_type n, const void* hint=0) {
53                 hint = hint;
54                 return static_cast<pointer>( ::operator new (n * sizeof(value_type)) );
55         }
56         void deallocate(pointer p, size_type n) {
57                 n=n;
58                 ::operator delete(p);
59         }
60         size_type max_size() {
61                 return ((size_type)-1) / sizeof(value_type);
62         }
63         void construct( pointer p, const_reference val ) {
64                 new ((void*)p) value_type (val);
65         }
66         // C++11
67         #if _CXX11_AVAIL
68         template<class U, class... Args>
69         void construct( U* p, Args&&... args ) {
70                 ::new ((void*)p) U (::std::forward<Args>(args)...);
71         }
72         #endif
73         void destroy(pointer p) {
74                 p->~value_type();
75         }
76 };
77
78 };
79
80 #endif
81
82 // vim: ft=cpp
83

UCC git Repository :: git.ucc.asn.au