1/*
2Copyright 2012-2019 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed 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
14namespace boost {
15
16template<class T>
17inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
18make_shared()
19{
20 return boost::allocate_shared<T>(boost::default_allocator<typename
21 detail::sp_array_element<T>::type>());
22}
23
24template<class T>
25inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
26make_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
32template<class T>
33inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
34make_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
40template<class T>
41inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
42make_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
48template<class T>
49inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
50make_shared_noinit()
51{
52 return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
53 detail::sp_array_element<T>::type>());
54}
55
56template<class T>
57inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
58make_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

source code of include/boost/smart_ptr/make_shared_array.hpp