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

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