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