• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright 2017 Peter Dimov
3 Copyright 2017-2019 Glen Joseph Fernandes
4 (glenjofe@gmail.com)
5 
6 Distributed under the Boost Software License, Version 1.0.
7 (http://www.boost.org/LICENSE_1_0.txt)
8 */
9 #ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
10 #define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
11 
12 #include <boost/core/default_allocator.hpp>
13 #include <boost/smart_ptr/allocate_local_shared_array.hpp>
14 
15 namespace boost {
16 
17 template<class T>
18 inline typename enable_if_<is_bounded_array<T>::value,
19     local_shared_ptr<T> >::type
make_local_shared()20 make_local_shared()
21 {
22     return boost::allocate_local_shared<T>(boost::default_allocator<typename
23         detail::sp_array_element<T>::type>());
24 }
25 
26 template<class T>
27 inline typename enable_if_<is_bounded_array<T>::value,
28     local_shared_ptr<T> >::type
make_local_shared(const typename remove_extent<T>::type & value)29 make_local_shared(const typename remove_extent<T>::type& value)
30 {
31     return boost::allocate_local_shared<T>(boost::default_allocator<typename
32         detail::sp_array_element<T>::type>(), value);
33 }
34 
35 template<class T>
36 inline typename enable_if_<is_unbounded_array<T>::value,
37     local_shared_ptr<T> >::type
make_local_shared(std::size_t size)38 make_local_shared(std::size_t size)
39 {
40     return boost::allocate_local_shared<T>(boost::default_allocator<typename
41         detail::sp_array_element<T>::type>(), size);
42 }
43 
44 template<class T>
45 inline typename enable_if_<is_unbounded_array<T>::value,
46     local_shared_ptr<T> >::type
make_local_shared(std::size_t size,const typename remove_extent<T>::type & value)47 make_local_shared(std::size_t size,
48     const typename remove_extent<T>::type& value)
49 {
50     return boost::allocate_local_shared<T>(boost::default_allocator<typename
51         detail::sp_array_element<T>::type>(), size, value);
52 }
53 
54 template<class T>
55 inline typename enable_if_<is_bounded_array<T>::value,
56     local_shared_ptr<T> >::type
make_local_shared_noinit()57 make_local_shared_noinit()
58 {
59     return boost::allocate_local_shared_noinit<T>(boost::
60         default_allocator<typename detail::sp_array_element<T>::type>());
61 }
62 
63 template<class T>
64 inline typename enable_if_<is_unbounded_array<T>::value,
65     local_shared_ptr<T> >::type
make_local_shared_noinit(std::size_t size)66 make_local_shared_noinit(std::size_t size)
67 {
68     return boost::allocate_local_shared_noinit<T>(boost::
69         default_allocator<typename detail::sp_array_element<T>::type>(), size);
70 }
71 
72 } /* boost */
73 
74 #endif
75