diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp index f151c00..c3ca93e 100644 --- a/include/boost/smart_ptr/allocate_shared_array.hpp +++ b/include/boost/smart_ptr/allocate_shared_array.hpp @@ -23,7 +23,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = size * detail::array_size::size; + size_t n1 = size * detail::array_total::size; detail::allocate_array_helper a1(allocator, n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -41,7 +41,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = size * detail::array_size::size; + size_t n1 = size * detail::array_total::size; detail::allocate_array_helper a1(allocator, n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -58,7 +58,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = detail::array_size::size; + size_t n1 = detail::array_total::size; detail::allocate_array_helper a1(allocator, n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -79,7 +79,7 @@ namespace boost { T1* p1 = 0; T2* p2 = 0; T3* p3 = 0; - size_t n1 = list.size() * detail::array_size::size; + size_t n1 = list.size() * detail::array_total::size; detail::allocate_array_helper a1(allocator, n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -93,13 +93,14 @@ namespace boost { template inline typename detail::sp_if_size_array::type allocate_shared(const A& allocator, typename detail::array_list::type list) { + BOOST_ASSERT(list.size() == detail::array_size::size); typedef typename detail::array_inner::type T1; typedef typename detail::array_base::type T2; typedef const T2 T3; T1* p1 = 0; T2* p2 = 0; T3* p3 = 0; - size_t n1 = detail::array_size::size; + size_t n1 = detail::array_total::size; detail::allocate_array_helper a1(allocator, n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); diff --git a/include/boost/smart_ptr/detail/array_traits.hpp b/include/boost/smart_ptr/detail/array_traits.hpp index d80798f..6343f71 100644 --- a/include/boost/smart_ptr/detail/array_traits.hpp +++ b/include/boost/smart_ptr/detail/array_traits.hpp @@ -13,7 +13,6 @@ #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include #endif -#include namespace boost { namespace detail { @@ -27,14 +26,23 @@ namespace boost { }; template struct array_size { + }; + template + struct array_size { + enum { + size = N + }; + }; + template + struct array_total { enum { size = 1 }; }; template - struct array_size { + struct array_total { enum { - size = N * array_size::size + size = N * array_total::size }; }; template diff --git a/include/boost/smart_ptr/detail/sp_if_array.hpp b/include/boost/smart_ptr/detail/sp_if_array.hpp index 96819b5..3ba3a0e 100644 --- a/include/boost/smart_ptr/detail/sp_if_array.hpp +++ b/include/boost/smart_ptr/detail/sp_if_array.hpp @@ -23,7 +23,7 @@ namespace boost { template struct sp_if_size_array { }; - template + template struct sp_if_size_array { typedef boost::shared_ptr type; }; diff --git a/include/boost/smart_ptr/make_shared_array.hpp b/include/boost/smart_ptr/make_shared_array.hpp index a1a9f40..9e96412 100644 --- a/include/boost/smart_ptr/make_shared_array.hpp +++ b/include/boost/smart_ptr/make_shared_array.hpp @@ -23,7 +23,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = size * detail::array_size::size; + size_t n1 = size * detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -41,7 +41,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = size * detail::array_size::size; + size_t n1 = size * detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -58,7 +58,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = detail::array_size::size; + size_t n1 = detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -79,7 +79,7 @@ namespace boost { T1* p1 = 0; T2* p2 = 0; T3* p3 = 0; - size_t n1 = list.size() * detail::array_size::size; + size_t n1 = list.size() * detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -93,13 +93,14 @@ namespace boost { template inline typename detail::sp_if_size_array::type make_shared(typename detail::array_list::type list) { + BOOST_ASSERT(list.size() == detail::array_size::size); typedef typename detail::array_inner::type T1; typedef typename detail::array_base::type T2; typedef const T2 T3; T1* p1 = 0; T2* p2 = 0; T3* p3 = 0; - size_t n1 = detail::array_size::size; + size_t n1 = detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -118,7 +119,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = size * detail::array_size::size; + size_t n1 = size * detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1); @@ -135,7 +136,7 @@ namespace boost { typedef typename detail::array_base::type T2; T1* p1 = 0; T2* p2 = 0; - size_t n1 = detail::array_size::size; + size_t n1 = detail::array_total::size; detail::make_array_helper a1(n1, &p2); detail::array_deleter d1; shared_ptr s1(p1, d1, a1);