forked from boostorg/smart_ptr
Merged revision(s) 81341-81342 from trunk:
Add additional overload for allocate_shared and make_shared array forms that take initializer list of T for the array types T[M][N] ........ Minor style change: Fix indentation in allocate_shared_array.hpp and make_shared_array.hpp ........ [SVN r81366]
This commit is contained in:
@@ -98,10 +98,10 @@ namespace boost {
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
allocate_shared(const A& allocator,
|
||||
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;
|
||||
@@ -138,6 +138,29 @@ namespace boost {
|
||||
d2->construct_list(p2, n1, p3, n0);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
template<typename T, typename A>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
allocate_shared(const A& allocator,
|
||||
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::allocate_array_helper<A, T2> a1(allocator, 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user