PageRenderTime 26ms CodeModel.GetById 21ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/std/std_alloc.i

#
Swig | 77 lines | 49 code | 14 blank | 14 comment | 0 complexity | a017f0cab1ad935b28aa5cb04d209773 MD5 | raw file
 1namespace std
 2{
 3  /**
 4   *  @brief  The "standard" allocator, as per [20.4].
 5   *
 6   *  The private _Alloc is "SGI" style.  (See comments at the top
 7   *  of stl_alloc.h.)
 8   *
 9   *  The underlying allocator behaves as follows.
10   *    - __default_alloc_template is used via two typedefs
11   *    - "__single_client_alloc" typedef does no locking for threads
12   *    - "__alloc" typedef is threadsafe via the locks
13   *    - __new_alloc is used for memory requests
14   *
15   *  (See @link Allocators allocators info @endlink for more.)
16   */
17  template<typename _Tp>
18    class allocator
19    {
20    public:
21      typedef size_t     size_type;
22      typedef ptrdiff_t  difference_type;
23      typedef _Tp*       pointer;
24      typedef const _Tp* const_pointer;
25      typedef _Tp&       reference;
26      typedef const _Tp& const_reference;
27      typedef _Tp        value_type;
28
29      template<typename _Tp1>
30        struct rebind;
31
32      allocator() throw();
33      
34      allocator(const allocator&) throw();
35      template<typename _Tp1>
36        allocator(const allocator<_Tp1>&) throw();
37      ~allocator() throw();
38      
39
40      pointer
41      address(reference __x) const;
42      
43
44      const_pointer
45      address(const_reference __x) const;
46      
47
48      // NB: __n is permitted to be 0.  The C++ standard says nothing
49      // about what the return value is when __n == 0.
50      _Tp*
51      allocate(size_type __n, const void* = 0);
52
53      // __p is not permitted to be a null pointer.
54      void
55      deallocate(pointer __p, size_type __n);
56
57      size_type
58      max_size() const throw();
59
60      void construct(pointer __p, const _Tp& __val);
61      void destroy(pointer __p);
62    };
63
64  template<>
65    class allocator<void>
66    {
67    public:
68      typedef size_t      size_type;
69      typedef ptrdiff_t   difference_type;
70      typedef void*       pointer;
71      typedef const void* const_pointer;
72      typedef void        value_type;
73
74      template<typename _Tp1>
75        struct rebind;
76    };
77} // namespace std