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