Usermode/libc++ - Exceptions mostly
[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 "cstddef"
12
13 namespace std {
14
15 template <class T> class allocator
16 {
17 public:
18         typedef T       value_type;
19         typedef T*      pointer;
20         typedef T&      reference;
21         typedef const T* const_pointer;
22         typedef const T&        const_reference;
23         typedef size_t  size_type;
24         typedef ptrdiff_t       difference_type;
25         
26         template <class Type>
27         struct rebind
28         {
29                 typedef allocator<Type> other;
30         };
31         
32         allocator() throw() {
33         }
34         allocator(const allocator& alloc __attribute__((unused))) throw() {
35         }
36         template <class U>
37         allocator(const allocator<U>& alloc) throw() {
38         }
39         ~allocator() throw() {
40         }
41         
42         pointer address(reference x) const {
43                 return &x;
44         }
45         const_pointer address(const_reference x) const {
46                 return &x;
47         }
48         pointer allocate(size_type n, const void* hint=0) {
49                 hint = hint;
50                 return static_cast<pointer>( ::operator new (n * sizeof(value_type)) );
51         }
52         void deallocate(pointer p, size_type n) {
53                 n=n;
54                 ::operator delete(p);
55         }
56         size_type max_size() {
57                 return ((size_type)-1) / sizeof(value_type);
58         }
59         void construct( pointer p, const_reference val ) {
60                 ::new ((void*)p) value_type (val);
61         }
62         // C++11
63         //template<class U, class... Args>
64         //void construct( U* p, Args&&... args ) {
65         //      ::new ((void*)p) U (forward<Args>(args));
66         //}
67         void destroy(pointer p) {
68                 p->~value_type();
69         }
70 };
71
72 };
73
74 #endif
75
76 // vim: ft=cpp
77

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