liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Copyright 2012-2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
 
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
 
#include <boost/core/default_allocator.hpp>
#include <boost/smart_ptr/allocate_shared_array.hpp>
 
namespace boost {
 
template<class T>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared()
{
    return boost::allocate_shared<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>());
}
 
template<class T>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared(const typename remove_extent<T>::type& value)
{
    return boost::allocate_shared<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>(), value);
}
 
template<class T>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared(std::size_t size)
{
    return boost::allocate_shared<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>(), size);
}
 
template<class T>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared(std::size_t size, const typename remove_extent<T>::type& value)
{
    return boost::allocate_shared<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>(), size, value);
}
 
template<class T>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared_noinit()
{
    return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>());
}
 
template<class T>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared_noinit(std::size_t size)
{
    return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
        detail::sp_array_element<T>::type>(), size);
}
 
} /* boost */
 
#endif