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