|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81658 - in trunk: boost/smart_ptr boost/smart_ptr/detail libs/smart_ptr
From: glenfe_at_[hidden]
Date: 2012-12-01 17:43:58
Author: glenfe
Date: 2012-12-01 17:43:57 EST (Sat, 01 Dec 2012)
New Revision: 81658
URL: http://svn.boost.org/trac/boost/changeset/81658
Log:
Change make_shared and allocate_shared array form overload for size and inner array initialization list to use const T(&)[N] instead of std::initializer_list<T>.
Text files modified:
trunk/boost/smart_ptr/allocate_shared_array.hpp | 42 ++++++++++++++++++++--------------------
trunk/boost/smart_ptr/detail/array_traits.hpp | 6 -----
trunk/boost/smart_ptr/make_shared_array.hpp | 42 ++++++++++++++++++++--------------------
trunk/libs/smart_ptr/make_shared_array.html | 18 ++++++++--------
4 files changed, 51 insertions(+), 57 deletions(-)
Modified: trunk/boost/smart_ptr/allocate_shared_array.hpp
==============================================================================
--- trunk/boost/smart_ptr/allocate_shared_array.hpp (original)
+++ trunk/boost/smart_ptr/allocate_shared_array.hpp 2012-12-01 17:43:57 EST (Sat, 01 Dec 2012)
@@ -97,52 +97,52 @@
d2->construct_list(p2, n1, p3);
return boost::shared_ptr<T>(s1, p1);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T, typename A>
- inline typename boost::detail::sp_if_array<T>::type
- allocate_shared(const A& allocator, std::size_t size,
- std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
+ inline typename boost::detail::sp_if_size_array<T>::type
+ allocate_shared(const A& allocator, const T& list) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
typedef const T2 T3;
enum {
- M = boost::detail::array_total<T1>::size
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- 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::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;
- p3 = reinterpret_cast<T3*>(list.begin());
+ boost::detail::array_deleter<T2[N]>* d2;
+ p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
- d2->construct_list(p2, n1, p3, M);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
-#endif
-#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T, typename A>
- inline typename boost::detail::sp_if_size_array<T>::type
- allocate_shared(const A& allocator, const T& list) {
+ inline typename boost::detail::sp_if_array<T>::type
+ allocate_shared(const A& allocator, std::size_t size,
+ const typename boost::detail::array_inner<T>::type& list) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
typedef const T2 T3;
enum {
- N = boost::detail::array_total<T>::size
+ M = boost::detail::array_total<T1>::size
};
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
- boost::detail::array_deleter<T2[N]> d1;
+ std::size_t n1 = M * 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[N]>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
- d2->construct_list(p2, p3);
+ 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>
Modified: trunk/boost/smart_ptr/detail/array_traits.hpp
==============================================================================
--- trunk/boost/smart_ptr/detail/array_traits.hpp (original)
+++ trunk/boost/smart_ptr/detail/array_traits.hpp 2012-12-01 17:43:57 EST (Sat, 01 Dec 2012)
@@ -51,12 +51,6 @@
struct array_inner<T[N]> {
typedef T type;
};
- template<typename T>
- struct arrays_inner;
- template<typename T, std::size_t N>
- struct arrays_inner<T[][N]> {
- typedef T type;
- };
}
}
Modified: trunk/boost/smart_ptr/make_shared_array.hpp
==============================================================================
--- trunk/boost/smart_ptr/make_shared_array.hpp (original)
+++ trunk/boost/smart_ptr/make_shared_array.hpp 2012-12-01 17:43:57 EST (Sat, 01 Dec 2012)
@@ -96,52 +96,52 @@
d2->construct_list(p2, n1, p3);
return boost::shared_ptr<T>(s1, p1);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T>
- inline typename boost::detail::sp_if_array<T>::type
- make_shared(std::size_t size,
- std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
+ inline typename boost::detail::sp_if_size_array<T>::type
+ make_shared(const T& list) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
typedef const T2 T3;
enum {
- M = boost::detail::array_total<T1>::size
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- std::size_t n1 = M * size;
- boost::detail::make_array_helper<T2[]> a1(n1, &p2);
- boost::detail::array_deleter<T2[]> d1;
+ 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;
- p3 = reinterpret_cast<T3*>(list.begin());
+ boost::detail::array_deleter<T2[N]>* d2;
+ p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
- d2->construct_list(p2, n1, p3, M);
+ d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
-#endif
-#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T>
- inline typename boost::detail::sp_if_size_array<T>::type
- make_shared(const T& list) {
+ inline typename boost::detail::sp_if_array<T>::type
+ make_shared(std::size_t size,
+ const typename boost::detail::array_inner<T>::type& list) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
typedef const T2 T3;
enum {
- N = boost::detail::array_total<T>::size
+ M = boost::detail::array_total<T1>::size
};
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- boost::detail::make_array_helper<T2[N]> a1(&p2);
- boost::detail::array_deleter<T2[N]> d1;
+ 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[N]>* d2;
+ boost::detail::array_deleter<T2[]>* d2;
p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
- d2->construct_list(p2, p3);
+ 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>
Modified: trunk/libs/smart_ptr/make_shared_array.html
==============================================================================
--- trunk/libs/smart_ptr/make_shared_array.html (original)
+++ trunk/libs/smart_ptr/make_shared_array.html 2012-12-01 17:43:57 EST (Sat, 01 Dec 2012)
@@ -12,7 +12,7 @@
<A href="#Synopsis">Synopsis</A><br>
<A href="#functions">Free Functions</A><br>
<A href="#example">Example</A><br>
- History<br>
+ History<br></p>
<h2><a name="Introduction">Introduction</a></h2>
<p>Originally the Boost function templates <code>make_shared</code> and
<code>allocate_shared</code> were for efficient allocation of single
@@ -53,14 +53,8 @@
template<typename T, typename... Args>
shared_ptr<T[]> make_shared(initializer_list<T> list);
- template<typename T, typename... Args>
- shared_ptr<T[][N]> make_shared(size_t size, initializer_list<T> list);
-
template<typename T, typename A, typename... Args>
shared_ptr<T[]> allocate_shared(const A& allocator, initializer_list<T> list);
-
- template<typename T, typename A, typename... Args>
- shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list);
#endif
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
@@ -68,12 +62,18 @@
shared_ptr<T[N]> make_shared(const T (&list)[N]);
template<typename T, typename... Args>
+ shared_ptr<T[][N]> make_shared(size_t size, const T (&list)[N]);
+
+ template<typename T, typename... Args>
shared_ptr<T[M][N]> make_shared(const T (&list)[N]);
template<typename T, typename A, typename... Args>
shared_ptr<T[N]> allocate_shared(const A& allocator, const T (&list)[N]);
template<typename T, typename A, typename... Args>
+ shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, const T (&list)[N]);
+
+ template<typename T, typename A, typename... Args>
shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]);
#endif
@@ -151,9 +151,9 @@
fixed size array.</p>
</blockquote>
<pre>template<typename T, typename... Args>
- shared_ptr<T[][N]> make_shared(size_t size, initializer_list<T> list);
+ shared_ptr<T[][N]> make_shared(size_t size, const T (&list)[N]);
template<typename T, typename A, typename... Args>
- shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list);</pre>
+ shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, const T (&list)[N]);</pre>
<blockquote>
<p><b>Description:</b> These overloads initialize inner array elements
from the initializer list.</p>
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