alloc_construct.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. Copyright 2019 Glen Joseph Fernandes
  3. ([email protected])
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
  8. #define BOOST_CORE_ALLOC_CONSTRUCT_HPP
  9. /*
  10. This functionality is now in <boost/core/allocator_access.hpp>.
  11. */
  12. #include <boost/core/noinit_adaptor.hpp>
  13. namespace boost {
  14. template<class A, class T>
  15. inline void
  16. alloc_destroy(A& a, T* p)
  17. {
  18. boost::allocator_destroy(a, p);
  19. }
  20. template<class A, class T>
  21. inline void
  22. alloc_destroy_n(A& a, T* p, std::size_t n)
  23. {
  24. boost::allocator_destroy_n(a, p, n);
  25. }
  26. template<class A, class T>
  27. inline void
  28. alloc_construct(A& a, T* p)
  29. {
  30. boost::allocator_construct(a, p);
  31. }
  32. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  33. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  34. template<class A, class T, class U, class... V>
  35. inline void
  36. alloc_construct(A& a, T* p, U&& u, V&&... v)
  37. {
  38. boost::allocator_construct(a, p, std::forward<U>(u),
  39. std::forward<V>(v)...);
  40. }
  41. #else
  42. template<class A, class T, class U>
  43. inline void
  44. alloc_construct(A& a, T* p, U&& u)
  45. {
  46. boost::allocator_construct(a, p, std::forward<U>(u));
  47. }
  48. #endif
  49. #else
  50. template<class A, class T, class U>
  51. inline void
  52. alloc_construct(A& a, T* p, const U& u)
  53. {
  54. boost::allocator_construct(a, p, u);
  55. }
  56. template<class A, class T, class U>
  57. inline void
  58. alloc_construct(A& a, T* p, U& u)
  59. {
  60. boost::allocator_construct(a, p, u);
  61. }
  62. #endif
  63. template<class A, class T>
  64. inline void
  65. alloc_construct_n(A& a, T* p, std::size_t n)
  66. {
  67. boost::allocator_construct_n(a, p, n);
  68. }
  69. template<class A, class T>
  70. inline void
  71. alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
  72. {
  73. boost::allocator_construct_n(a, p, n, l, m);
  74. }
  75. template<class A, class T, class I>
  76. inline void
  77. alloc_construct_n(A& a, T* p, std::size_t n, I b)
  78. {
  79. boost::allocator_construct_n(a, p, n, b);
  80. }
  81. } /* boost */
  82. #endif