PageRenderTime 37ms CodeModel.GetById 12ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. namespace 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. template<typename _Tp1>
  29. struct rebind;
  30. allocator() throw();
  31. allocator(const allocator&) throw();
  32. template<typename _Tp1>
  33. allocator(const allocator<_Tp1>&) throw();
  34. ~allocator() throw();
  35. pointer
  36. address(reference __x) const;
  37. const_pointer
  38. address(const_reference __x) const;
  39. // NB: __n is permitted to be 0. The C++ standard says nothing
  40. // about what the return value is when __n == 0.
  41. _Tp*
  42. allocate(size_type __n, const void* = 0);
  43. // __p is not permitted to be a null pointer.
  44. void
  45. deallocate(pointer __p, size_type __n);
  46. size_type
  47. max_size() const throw();
  48. void construct(pointer __p, const _Tp& __val);
  49. void destroy(pointer __p);
  50. };
  51. template<>
  52. class allocator<void>
  53. {
  54. public:
  55. typedef size_t size_type;
  56. typedef ptrdiff_t difference_type;
  57. typedef void* pointer;
  58. typedef const void* const_pointer;
  59. typedef void value_type;
  60. template<typename _Tp1>
  61. struct rebind;
  62. };
  63. } // namespace std