Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81635 - in branches/release/boost/smart_ptr: . detail
From: glenfe_at_[hidden]
Date: 2012-11-30 12:29:37


Author: glenfe
Date: 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
New Revision: 81635
URL: http://svn.boost.org/trac/boost/changeset/81635

Log:
Merged revision(s) 81608-81610 from trunk:
Optimization: Add specializations of make_array_helper, allocate_array_helper, and array_deleter for fixed size arrays to avoid storing size.
........
Consistent formatting across overloads of make_shared and allocate_shared (array forms).
........
More consistency in type parameters in helper details of allocate_shared and make_shared.
........

Properties modified:
   branches/release/boost/smart_ptr/ (props changed)
Text files modified:
   branches/release/boost/smart_ptr/allocate_shared_array.hpp | 76 +++++++++++++++---------------
   branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp | 93 ++++++++++++++++++++++++++++++++----
   branches/release/boost/smart_ptr/detail/array_deleter.hpp | 67 ++++++++++++++++++++++++++
   branches/release/boost/smart_ptr/detail/make_array_helper.hpp | 86 ++++++++++++++++++++++++++++++----
   branches/release/boost/smart_ptr/make_shared_array.hpp | 100 ++++++++++++++++++++--------------------
   5 files changed, 312 insertions(+), 110 deletions(-)

Modified: branches/release/boost/smart_ptr/allocate_shared_array.hpp
==============================================================================
--- branches/release/boost/smart_ptr/allocate_shared_array.hpp (original)
+++ branches/release/boost/smart_ptr/allocate_shared_array.hpp 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
@@ -28,12 +28,12 @@
         T1* p1 = 0;
         T2* p2 = 0;
         std::size_t n1 = size * boost::detail::array_total<T1>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct(p2, n1);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -46,12 +46,12 @@
         T1* p1 = 0;
         T2* p2 = 0;
         std::size_t n1 = size * boost::detail::array_total<T1>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct(p2, n1, boost::detail::sp_forward<Args>(args)...);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -62,14 +62,14 @@
         typedef typename boost::detail::array_base<T1>::type T2;
         T1* p1 = 0;
         T2* p2 = 0;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct(p2, n1, boost::detail::sp_forward<Args>(args)...);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
         return boost::shared_ptr<T>(s1, p1);
     }
 #endif
@@ -85,13 +85,13 @@
         T2* p2 = 0;
         T3* p3 = 0;
         std::size_t n1 = list.size() * boost::detail::array_total<T1>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct_list(p2, n1, p3);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -106,15 +106,15 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3);
         return boost::shared_ptr<T>(s1, p1);
     }
     template<typename T, typename A>
@@ -127,16 +127,16 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n0 = boost::detail::array_total<T1>::size;
- std::size_t n1 = n0 * list.size();
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { M = boost::detail::array_total<T1>::size };
+ std::size_t n1 = M * list.size();
+ boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3, n0);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ d2->construct_list(p2, n1, p3, M);
         return boost::shared_ptr<T>(s1, p1);
     }
     template<typename T, typename A>
@@ -150,16 +150,16 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n0 = boost::detail::array_total<T1>::size;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { M = boost::detail::array_total<T1>::size };
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3, n0);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3, M);
         return boost::shared_ptr<T>(s1, p1);
     }
 #endif

Modified: branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp (original)
+++ branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
@@ -13,8 +13,10 @@
 
 namespace boost {
     namespace detail {
- template<typename A, typename T, typename Y = T>
- class allocate_array_helper {
+ template<typename A, typename T, typename Y = char>
+ class allocate_array_helper;
+ template<typename A, typename T, typename Y>
+ class allocate_array_helper<A, T[], Y> {
             template<typename A9, typename T9, typename Y9>
             friend class allocate_array_helper;
             typedef typename A::template rebind<Y> ::other A2;
@@ -29,20 +31,15 @@
             typedef typename A2::difference_type difference_type;
             template<typename U>
             struct rebind {
- typedef allocate_array_helper<A, T, U> other;
+ typedef allocate_array_helper<A, T[], U> other;
             };
             allocate_array_helper(const A& allocator, std::size_t size, T** data)
                 : allocator(allocator),
                   size(sizeof(T) * size),
                   data(data) {
             }
- allocate_array_helper(const allocate_array_helper& other)
- : allocator(other.allocator),
- size(other.size),
- data(other.data) {
- }
             template<class U>
- allocate_array_helper(const allocate_array_helper<A, T, U>& other)
+ allocate_array_helper(const allocate_array_helper<A, T[], U>& other)
                 : allocator(other.allocator),
                   size(other.size),
                   data(other.data) {
@@ -80,11 +77,11 @@
                 allocator.destroy(memory);
             }
             template<typename U>
- bool operator==(const allocate_array_helper<A, T, U>& other) const {
+ bool operator==(const allocate_array_helper<A, T[], U>& other) const {
                 return allocator == other.allocator;
             }
             template<typename U>
- bool operator!=(const allocate_array_helper<A, T, U>& other) const {
+ bool operator!=(const allocate_array_helper<A, T[], U>& other) const {
                 return !(*this == other);
             }
         private:
@@ -92,6 +89,80 @@
             std::size_t size;
             T** data;
         };
+ template<typename A, typename T, std::size_t N, typename Y>
+ class allocate_array_helper<A, T[N], Y> {
+ template<typename A9, typename T9, typename Y9>
+ friend class allocate_array_helper;
+ typedef typename A::template rebind<Y> ::other A2;
+ typedef typename A::template rebind<char>::other A3;
+ public:
+ typedef typename A2::value_type value_type;
+ typedef typename A2::pointer pointer;
+ typedef typename A2::const_pointer const_pointer;
+ typedef typename A2::reference reference;
+ typedef typename A2::const_reference const_reference;
+ typedef typename A2::size_type size_type;
+ typedef typename A2::difference_type difference_type;
+ template<typename U>
+ struct rebind {
+ typedef allocate_array_helper<A, T[N], U> other;
+ };
+ allocate_array_helper(const A& allocator, T** data)
+ : allocator(allocator),
+ data(data) {
+ }
+ template<class U>
+ allocate_array_helper(const allocate_array_helper<A, T[N], U>& other)
+ : allocator(other.allocator),
+ data(other.data) {
+ }
+ pointer address(reference value) const {
+ return allocator.address(value);
+ }
+ const_pointer address(const_reference value) const {
+ return allocator.address(value);
+ }
+ size_type max_size() const {
+ return allocator.max_size();
+ }
+ pointer allocate(size_type count, const void* value = 0) {
+ std::size_t a1 = boost::alignment_of<T>::value;
+ std::size_t n1 = count * sizeof(Y) + a1 - 1;
+ char* p1 = A3(allocator).allocate(n1 + N1, value);
+ char* p2 = p1 + n1;
+ while (std::size_t(p2) % a1 != 0) {
+ p2--;
+ }
+ *data = reinterpret_cast<T*>(p2);
+ return reinterpret_cast<Y*>(p1);
+ }
+ void deallocate(pointer memory, size_type count) {
+ std::size_t a1 = boost::alignment_of<T>::value;
+ std::size_t n1 = count * sizeof(Y) + a1 - 1;
+ char* p1 = reinterpret_cast<char*>(memory);
+ A3(allocator).deallocate(p1, n1 + N1);
+ }
+ void construct(pointer memory, const Y& value) {
+ allocator.construct(memory, value);
+ }
+ void destroy(pointer memory) {
+ allocator.destroy(memory);
+ }
+ template<typename U>
+ bool operator==(const allocate_array_helper<A, T[N], U>& other) const {
+ return allocator == other.allocator;
+ }
+ template<typename U>
+ bool operator!=(const allocate_array_helper<A, T[N], U>& other) const {
+ return !(*this == other);
+ }
+ private:
+ enum {
+ N1 = N * sizeof(T)
+ };
+ A2 allocator;
+ T** data;
+ };
     }
 }
 

Modified: branches/release/boost/smart_ptr/detail/array_deleter.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/array_deleter.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_deleter.hpp 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
@@ -15,7 +15,9 @@
 namespace boost {
     namespace detail {
         template<typename T>
- class array_deleter {
+ class array_deleter;
+ template<typename T>
+ class array_deleter<T[]> {
         public:
             array_deleter()
                 : size(0) {
@@ -70,6 +72,69 @@
             std::size_t size;
             T* object;
         };
+ template<typename T, std::size_t N>
+ class array_deleter<T[N]> {
+ public:
+ array_deleter()
+ : object(0) {
+ }
+ ~array_deleter() {
+ destroy();
+ }
+ void construct(T* memory) {
+ object = memory;
+ for (std::size_t i = 0; i < N; i++) {
+ void* p1 = object + i;
+ ::new(p1) T();
+ }
+ }
+#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<typename... Args>
+ void construct(T* memory, Args&&... args) {
+ object = memory;
+ for (std::size_t i = 0; i < N; i++) {
+ void* p1 = object + i;
+ ::new(p1) T(args...);
+ }
+ }
+#endif
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ void construct_list(T* memory, const T* list) {
+ object = memory;
+ for (std::size_t i = 0; i < N; i++) {
+ void* p1 = object + i;
+ ::new(p1) T(list[i]);
+ }
+ }
+ void construct_list(T* memory, const T* list, std::size_t n) {
+ object = memory;
+ for (std::size_t i = 0; i < N; i++) {
+ void* p1 = object + i;
+ ::new(p1) T(list[i % n]);
+ }
+ }
+#endif
+ void construct_noinit(T* memory) {
+ object = memory;
+ for (std::size_t i = 0; i < N; i++) {
+ void* p1 = object + i;
+ ::new(p1) T;
+ }
+ }
+ void operator()(const void*) {
+ destroy();
+ }
+ private:
+ void destroy() {
+ if (object) {
+ for (std::size_t i = N; i > 0; ) {
+ object[--i].~T();
+ }
+ object = 0;
+ }
+ }
+ T* object;
+ };
     }
 }
 

Modified: branches/release/boost/smart_ptr/detail/make_array_helper.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/make_array_helper.hpp (original)
+++ branches/release/boost/smart_ptr/detail/make_array_helper.hpp 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
@@ -13,8 +13,10 @@
 
 namespace boost {
     namespace detail {
- template<typename T, typename Y = T>
- class make_array_helper {
+ template<typename T, typename Y = char>
+ class make_array_helper;
+ template<typename T, typename Y>
+ class make_array_helper<T[], Y> {
             template<typename T2, typename Y2>
             friend class make_array_helper;
         public:
@@ -27,18 +29,14 @@
             typedef ptrdiff_t difference_type;
             template<typename U>
             struct rebind {
- typedef make_array_helper<T, U> other;
+ typedef make_array_helper<T[], U> other;
             };
             make_array_helper(std::size_t size, T** data)
                 : size(sizeof(T) * size),
                   data(data) {
             }
- make_array_helper(const make_array_helper& other)
- : size(other.size),
- data(other.data) {
- }
             template<class U>
- make_array_helper(const make_array_helper<T, U>& other)
+ make_array_helper(const make_array_helper<T[], U>& other)
                 : size(other.size),
                   data(other.data) {
             }
@@ -74,17 +72,85 @@
                 memory->~Y();
             }
             template<typename U>
- bool operator==(const make_array_helper<T, U>& other) const {
+ bool operator==(const make_array_helper<T[], U>& other) const {
                 return true;
             }
             template<typename U>
- bool operator!=(const make_array_helper<T, U>& other) const {
+ bool operator!=(const make_array_helper<T[], U>& other) const {
                 return !(*this == other);
             }
         private:
             std::size_t size;
             T** data;
         };
+ template<typename T, std::size_t N, typename Y>
+ class make_array_helper<T[N], Y> {
+ template<typename T2, typename Y2>
+ friend class make_array_helper;
+ public:
+ typedef Y value_type;
+ typedef Y* pointer;
+ typedef const Y* const_pointer;
+ typedef Y& reference;
+ typedef const Y& const_reference;
+ typedef std::size_t size_type;
+ typedef ptrdiff_t difference_type;
+ template<typename U>
+ struct rebind {
+ typedef make_array_helper<T[N], U> other;
+ };
+ make_array_helper(T** data)
+ : data(data) {
+ }
+ template<class U>
+ make_array_helper(const make_array_helper<T[N], U>& other)
+ : data(other.data) {
+ }
+ pointer address(reference value) const {
+ return &value;
+ }
+ const_pointer address(const_reference value) const {
+ return &value;
+ }
+ size_type max_size() const {
+ return static_cast<std::size_t>(-1) / sizeof(Y);
+ }
+ pointer allocate(size_type count, const void* = 0) {
+ std::size_t a1 = boost::alignment_of<T>::value;
+ std::size_t n1 = count * sizeof(Y) + a1 - 1;
+ void* p1 = ::operator new(n1 + N1);
+ char* p2 = static_cast<char*>(p1) + n1;
+ while (std::size_t(p2) % a1 != 0) {
+ p2--;
+ }
+ *data = reinterpret_cast<T*>(p2);
+ return reinterpret_cast<Y*>(p1);
+ }
+ void deallocate(pointer memory, size_type) {
+ void* p1 = memory;
+ ::operator delete(p1);
+ }
+ void construct(pointer memory, const Y& value) {
+ void* p1 = memory;
+ ::new(p1) Y(value);
+ }
+ void destroy(pointer memory) {
+ memory->~Y();
+ }
+ template<typename U>
+ bool operator==(const make_array_helper<T[N], U>& other) const {
+ return true;
+ }
+ template<typename U>
+ bool operator!=(const make_array_helper<T[N], U>& other) const {
+ return !(*this == other);
+ }
+ private:
+ enum {
+ N1 = N * sizeof(T)
+ };
+ T** data;
+ };
     }
 }
 

Modified: branches/release/boost/smart_ptr/make_shared_array.hpp
==============================================================================
--- branches/release/boost/smart_ptr/make_shared_array.hpp (original)
+++ branches/release/boost/smart_ptr/make_shared_array.hpp 2012-11-30 12:29:36 EST (Fri, 30 Nov 2012)
@@ -28,12 +28,12 @@
         T1* p1 = 0;
         T2* p2 = 0;
         std::size_t n1 = size * boost::detail::array_total<T1>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::make_array_helper<T2[]> a1(n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct(p2, n1);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -46,12 +46,12 @@
         T1* p1 = 0;
         T2* p2 = 0;
         std::size_t n1 = size * boost::detail::array_total<T1>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::make_array_helper<T2[]> a1(n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct(p2, n1, boost::detail::sp_forward<Args>(args)...);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -62,14 +62,14 @@
         typedef typename boost::detail::array_base<T1>::type T2;
         T1* p1 = 0;
         T2* p2 = 0;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::make_array_helper<T2[N]> a1(&p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct(p2, n1, boost::detail::sp_forward<Args>(args)...);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
         return boost::shared_ptr<T>(s1, p1);
     }
 #endif
@@ -84,13 +84,13 @@
         T2* p2 = 0;
         T3* p3 = 0;
         std::size_t n1 = list.size() * boost::detail::array_total<T1>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::make_array_helper<T2[]> a1(n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct_list(p2, n1, p3);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -104,15 +104,15 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::make_array_helper<T2[N]> a1(&p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3);
         return boost::shared_ptr<T>(s1, p1);
     }
     template<typename T>
@@ -125,16 +125,16 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n0 = boost::detail::array_total<T1>::size;
- std::size_t n1 = n0 * size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { M = boost::detail::array_total<T1>::size };
+ std::size_t n1 = M * size;
+ boost::detail::make_array_helper<T2[]> a1(n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3, n0);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ d2->construct_list(p2, n1, p3, M);
         return boost::shared_ptr<T>(s1, p1);
     }
     template<typename T>
@@ -147,16 +147,16 @@
         T1* p1 = 0;
         T2* p2 = 0;
         T3* p3 = 0;
- std::size_t n0 = boost::detail::array_total<T1>::size;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ enum { M = boost::detail::array_total<T1>::size };
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::make_array_helper<T2[N]> a1(&p2);
+ boost::detail::array_deleter<T2[N]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[N]>* d2;
         p3 = reinterpret_cast<T3*>(list.begin());
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_list(p2, n1, p3, n0);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3, M);
         return boost::shared_ptr<T>(s1, p1);
     }
 #endif
@@ -168,12 +168,12 @@
         T1* p1 = 0;
         T2* p2 = 0;
         std::size_t n1 = size * boost::detail::array_total<T1>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
+ boost::detail::make_array_helper<T2[]> a1(n1, &p2);
+ boost::detail::array_deleter<T2[]> d1;
         boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
         p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
+ d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
         d2->construct_noinit(p2, n1);
         return boost::shared_ptr<T>(s1, p1);
     }
@@ -184,14 +184,14 @@
         typedef typename boost::detail::array_base<T1>::type T2;
         T1* p1 = 0;
         T2* p2 = 0;
- std::size_t n1 = boost::detail::array_total<T>::size;
- boost::detail::make_array_helper<T2> a1(n1, &p2);
- boost::detail::array_deleter<T2> d1;
- boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2>* d2;
- p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2> >(s1);
- d2->construct_noinit(p2, n1);
+ enum { N = boost::detail::array_total<T>::size };
+ boost::detail::make_array_helper<T2[N]> a1(&p2);
+ boost::detail::array_deleter<T2[N]> d1;
+ boost::shared_ptr<T> s1(p1, d1, a1);
+ boost::detail::array_deleter<T2[N]>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_noinit(p2);
         return boost::shared_ptr<T>(s1, p1);
     }
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk