1 | /* |
---|---|
2 | Copyright 2012-2017 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_SMART_PTR_MAKE_SHARED_ARRAY_HPP |
9 | #define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP |
10 | |
11 | #include <boost/smart_ptr/allocate_shared_array.hpp> |
12 | |
13 | namespace boost { |
14 | |
15 | template<class T> |
16 | inline typename detail::sp_if_size_array<T>::type |
17 | make_shared() |
18 | { |
19 | return boost::allocate_shared<T>(std::allocator<typename |
20 | detail::sp_array_scalar<T>::type>()); |
21 | } |
22 | |
23 | template<class T> |
24 | inline typename detail::sp_if_size_array<T>::type |
25 | make_shared(const typename detail::sp_array_element<T>::type& value) |
26 | { |
27 | return boost::allocate_shared<T>(std::allocator<typename |
28 | detail::sp_array_scalar<T>::type>(), value); |
29 | } |
30 | |
31 | template<class T> |
32 | inline typename detail::sp_if_array<T>::type |
33 | make_shared(std::size_t size) |
34 | { |
35 | return boost::allocate_shared<T>(std::allocator<typename |
36 | detail::sp_array_scalar<T>::type>(), size); |
37 | } |
38 | |
39 | template<class T> |
40 | inline typename detail::sp_if_array<T>::type |
41 | make_shared(std::size_t size, |
42 | const typename detail::sp_array_element<T>::type& value) |
43 | { |
44 | return boost::allocate_shared<T>(std::allocator<typename |
45 | detail::sp_array_scalar<T>::type>(), size, value); |
46 | } |
47 | |
48 | template<class T> |
49 | inline typename detail::sp_if_size_array<T>::type |
50 | make_shared_noinit() |
51 | { |
52 | return allocate_shared_noinit<T>(std::allocator<typename |
53 | detail::sp_array_scalar<T>::type>()); |
54 | } |
55 | |
56 | template<class T> |
57 | inline typename detail::sp_if_array<T>::type |
58 | make_shared_noinit(std::size_t size) |
59 | { |
60 | return allocate_shared_noinit<T>(std::allocator<typename |
61 | detail::sp_array_scalar<T>::type>(), size); |
62 | } |
63 | |
64 | } /* boost */ |
65 | |
66 | #endif |
67 |