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/smart_ptr/detail/requires_cxx11.hpp>
12#include <boost/core/default_allocator.hpp>
13#include <boost/smart_ptr/allocate_shared_array.hpp>
14
15namespace boost {
16
17template<class T>
18inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
19make_shared()
20{
21 return boost::allocate_shared<T>(boost::default_allocator<typename
22 detail::sp_array_element<T>::type>());
23}
24
25template<class T>
26inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
27make_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
33template<class T>
34inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
35make_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
41template<class T>
42inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
43make_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
49template<class T>
50inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
51make_shared_noinit()
52{
53 return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
54 detail::sp_array_element<T>::type>());
55}
56
57template<class T>
58inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
59make_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