forked from boostorg/smart_ptr
Add additional overload for allocate_shared and make_shared array forms that take initializer list of T for the array types T[M][N]
[SVN r81341]
This commit is contained in:
@@ -96,10 +96,10 @@ namespace boost {
|
||||
template<typename T>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
make_shared(std::initializer_list<typename detail::array_inner<T>::type> list) {
|
||||
BOOST_ASSERT(list.size() == detail::array_size<T>::size);
|
||||
typedef typename detail::array_inner<T>::type T1;
|
||||
typedef typename detail::array_base<T1>::type T2;
|
||||
typedef const T2 T3;
|
||||
BOOST_ASSERT(list.size() == detail::array_size<T>::size);
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T3* p3 = 0;
|
||||
@@ -136,6 +136,28 @@ namespace boost {
|
||||
d2->construct_list(p2, n1, p3, n0);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
template<typename T>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
make_shared(std::initializer_list<typename detail::arrays_inner<T>::type> list) {
|
||||
typedef typename detail::array_inner<T>::type T1;
|
||||
typedef typename detail::array_base<T1>::type T2;
|
||||
typedef const T2 T3;
|
||||
BOOST_ASSERT(list.size() == detail::array_size<T1>::size);
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T3* p3 = 0;
|
||||
std::size_t n0 = detail::array_total<T1>::size;
|
||||
std::size_t n1 = detail::array_total<T>::size;
|
||||
detail::make_array_helper<T2> a1(n1, &p2);
|
||||
detail::array_deleter<T2> d1;
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
detail::array_deleter<T2>* d2;
|
||||
p3 = reinterpret_cast<T3*>(list.begin());
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
||||
d2->construct_list(p2, n1, p3, n0);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
#endif
|
||||
template<typename T>
|
||||
inline typename detail::sp_if_array<T>::type
|
||||
|
Reference in New Issue
Block a user