|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81682 - in branches/release: . boost boost/smart_ptr boost/smart_ptr/detail libs libs/smart_ptr libs/smart_ptr/test
From: glenfe_at_[hidden]
Date: 2012-12-02 18:15:56
Author: glenfe
Date: 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
New Revision: 81682
URL: http://svn.boost.org/trac/boost/changeset/81682
Log:
Merged revision(s) 81641-81643,81658,81669,81681 from trunk:
Use const T (&)[N] for fixed size arrays instead of std::initializer<T> in overloads of make_shared and allocate_shared for arrays.
........
Use BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX instead for certain overloads of make_shared and allocate_shared
........
Code consistency: Use the same style of #if conditional compilation checks in allocate_shared_array.hpp and make_shared_array.hpp.
........
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>.
........
Move two tests for allocate_shared and make_shared within check for BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
........
Make specializations of detail array_deleter consistent.
........
Properties modified:
branches/release/ (props changed)
branches/release/boost/ (props changed)
branches/release/boost/smart_ptr/ (props changed)
branches/release/libs/ (props changed)
branches/release/libs/smart_ptr/ (props changed)
Text files modified:
branches/release/boost/smart_ptr/allocate_shared_array.hpp | 55 ++++++++++++++++++++----------------
branches/release/boost/smart_ptr/detail/array_deleter.hpp | 55 ++++++++++++++++++++----------------
branches/release/boost/smart_ptr/detail/array_traits.hpp | 17 +----------
branches/release/boost/smart_ptr/make_shared_array.hpp | 60 +++++++++++++++++++++++----------------
branches/release/libs/smart_ptr/make_shared_array.html | 38 +++++++++++++------------
branches/release/libs/smart_ptr/test/allocate_shared_array_init_test.cpp | 34 ++++++++++++----------
branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp | 30 +++++++++++++++----
branches/release/libs/smart_ptr/test/make_shared_array_init_test.cpp | 34 ++++++++++++----------
branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp | 31 +++++++++++++++-----
9 files changed, 200 insertions(+), 154 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-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -29,12 +29,12 @@
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::array_deleter<T2[]> d1(n1);
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(p2, n1);
+ d2->construct(p2);
return boost::shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
@@ -47,12 +47,12 @@
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::array_deleter<T2[]> d1(n1);
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(p2, n1, boost::detail::sp_forward<Args>(args)...);
+ d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T, typename A, typename... Args>
@@ -60,9 +60,11 @@
allocate_shared(const A& allocator, Args&&... args) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
+ enum {
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
- 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);
@@ -86,32 +88,34 @@
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::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
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);
+ 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,
- std::initializer_list<typename boost::detail::array_inner<T>::type> list) {
+ 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;
- BOOST_ASSERT(list.size() == boost::detail::array_size<T>::size);
+ enum {
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- 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[N]>* d2;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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);
@@ -120,43 +124,46 @@
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) {
+ 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 {
+ M = boost::detail::array_total<T1>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- enum { M = boost::detail::array_total<T1>::size };
- std::size_t n1 = M * list.size();
+ std::size_t n1 = M * size;
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
- boost::detail::array_deleter<T2[]> d1;
+ boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
boost::detail::array_deleter<T2[]>* d2;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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->construct_list(p2, p3, M);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T, typename A>
inline typename boost::detail::sp_if_size_array<T>::type
allocate_shared(const A& allocator,
- std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
+ 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;
- BOOST_ASSERT(list.size() == boost::detail::array_size<T1>::size);
+ enum {
+ M = boost::detail::array_total<T1>::size,
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
- T3* p3 = 0;
- enum { M = boost::detail::array_total<T1>::size };
- enum { N = boost::detail::array_total<T>::size };
+ T3* p3 = 0;
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[N]>* d2;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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, M);
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-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -19,44 +19,48 @@
template<typename T>
class array_deleter<T[]> {
public:
- array_deleter()
- : size(0) {
+ array_deleter(std::size_t size)
+ : size(size),
+ object(0) {
}
~array_deleter() {
destroy();
}
- void construct(T* memory, std::size_t count) {
- for (object = memory; size < count; size++) {
- void* p1 = object + size;
+ void construct(T* memory) {
+ object = memory;
+ for (std::size_t i = 0; i < size; 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, std::size_t count, Args&&... args) {
- for (object = memory; size < count; size++) {
- void* p1 = object + size;
+ void construct(T* memory, Args&&... args) {
+ object = memory;
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = object + i;
::new(p1) T(args...);
}
}
#endif
-#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
- void construct_list(T* memory, std::size_t count, const T* list) {
- for (object = memory; size < count; size++) {
- void* p1 = object + size;
- ::new(p1) T(list[size]);
+ void construct_list(T* memory, const T* list) {
+ object = memory;
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = object + i;
+ ::new(p1) T(list[i]);
}
}
- void construct_list(T* memory, std::size_t count, const T* list, std::size_t n) {
- for (object = memory; size < count; size++) {
- void* p1 = object + size;
- ::new(p1) T(list[size % n]);
+ void construct_list(T* memory, const T* list, std::size_t n) {
+ object = memory;
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = object + i;
+ ::new(p1) T(list[i % n]);
}
}
-#endif
- void construct_noinit(T* memory, std::size_t count) {
- for (object = memory; size < count; size++) {
- void* p1 = object + size;
+ void construct_noinit(T* memory) {
+ object = memory;
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = object + i;
::new(p1) T;
}
}
@@ -65,8 +69,11 @@
}
private:
void destroy() {
- while (size > 0) {
- object[--size].~T();
+ if (object) {
+ for (std::size_t i = size; i > 0; ) {
+ object[--i].~T();
+ }
+ object = 0;
}
}
std::size_t size;
@@ -98,7 +105,6 @@
}
}
#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++) {
@@ -113,7 +119,6 @@
::new(p1) T(list[i % n]);
}
}
-#endif
void construct_noinit(T* memory) {
object = memory;
for (std::size_t i = 0; i < N; i++) {
Modified: branches/release/boost/smart_ptr/detail/array_traits.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/array_traits.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_traits.hpp 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -22,8 +22,7 @@
typedef typename array_base<T>::type type;
};
template<typename T>
- struct array_size {
- };
+ struct array_size;
template<typename T, std::size_t N>
struct array_size<T[N]> {
enum {
@@ -43,8 +42,7 @@
};
};
template<typename T>
- struct array_inner {
- };
+ struct array_inner;
template<typename T>
struct array_inner<T[]> {
typedef T type;
@@ -53,17 +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;
- };
- template<typename T, std::size_t M, std::size_t N>
- struct arrays_inner<T[M][N]> {
- typedef T type;
- };
}
}
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-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -29,12 +29,12 @@
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::array_deleter<T2[]> d1(n1);
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(p2, n1);
+ d2->construct(p2);
return boost::shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
@@ -47,12 +47,12 @@
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::array_deleter<T2[]> d1(n1);
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(p2, n1, boost::detail::sp_forward<Args>(args)...);
+ d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T, typename... Args>
@@ -60,9 +60,11 @@
make_shared(Args&&... args) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
+ enum {
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
- 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);
@@ -85,31 +87,34 @@
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::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
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);
+ 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(std::initializer_list<typename boost::detail::array_inner<T>::type> list) {
+ 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;
- BOOST_ASSERT(list.size() == boost::detail::array_size<T>::size);
+ enum {
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- 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;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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);
@@ -118,42 +123,45 @@
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) {
+ 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 {
+ M = boost::detail::array_total<T1>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- 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::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
boost::detail::array_deleter<T2[]>* d2;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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->construct_list(p2, p3, M);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T>
inline typename boost::detail::sp_if_size_array<T>::type
- make_shared(std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
+ make_shared(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;
- BOOST_ASSERT(list.size() == boost::detail::array_size<T1>::size);
+ enum {
+ M = boost::detail::array_total<T1>::size,
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
T3* p3 = 0;
- 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[N]>* d2;
- p3 = reinterpret_cast<T3*>(list.begin());
+ 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, M);
@@ -169,12 +177,12 @@
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::array_deleter<T2[]> d1(n1);
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);
+ d2->construct_noinit(p2);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T>
@@ -182,9 +190,11 @@
make_shared_noinit() {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
+ enum {
+ N = boost::detail::array_total<T>::size
+ };
T1* p1 = 0;
T2* p2 = 0;
- 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);
Modified: branches/release/libs/smart_ptr/make_shared_array.html
==============================================================================
--- branches/release/libs/smart_ptr/make_shared_array.html (original)
+++ branches/release/libs/smart_ptr/make_shared_array.html 2012-12-02 18:15:55 EST (Sun, 02 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
@@ -34,7 +34,7 @@
template<typename T, typename A>
shared_ptr<T[]> allocate_shared(const A& allocator, size_t size);
-
+
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
template<typename T, typename... Args>
shared_ptr<T[]> make_shared(size_t size, Args&&... args);
@@ -48,31 +48,33 @@
template<typename T, typename A, typename... Args>
shared_ptr<T[N]> allocate_shared(const A& allocator, Args&&... args);
#endif
-
+
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
template<typename T, typename... Args>
shared_ptr<T[]> make_shared(initializer_list<T> list);
+ template<typename T, typename A, typename... Args>
+ shared_ptr<T[]> allocate_shared(const A& allocator, initializer_list<T> list);
+#endif
+
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T, typename... Args>
- shared_ptr<T[N]> make_shared(initializer_list<T> list);
+ shared_ptr<T[N]> make_shared(const T (&list)[N]);
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... Args>
- shared_ptr<T[M][N]> make_shared(initializer_list<T> list);
-
- template<typename T, typename A, typename... Args>
- shared_ptr<T[]> allocate_shared(const A& allocator, initializer_list<T> list);
+ 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, initializer_list<T> list);
+ 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, initializer_list<T> list);
+ 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, initializer_list<T> list);
+ shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]);
#endif
template<typename T>
@@ -141,25 +143,25 @@
from the initializer list.</p>
</blockquote>
<pre>template<typename T, typename... Args>
- shared_ptr<T[N]> make_shared(initializer_list<T> list);
+ shared_ptr<T[N]> make_shared(const T (&list)[N]);
template<typename T, typename A, typename... Args>
- shared_ptr<T[N]> allocate_shared(const A& allocator, initializer_list<T> list);</pre>
+ shared_ptr<T[N]> allocate_shared(const A& allocator, const T (&list)[N]);</pre>
<blockquote>
<p><b>Description:</b> These overloads of the utilities above are for a
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>
</blockquote>
<pre>template<typename T, typename... Args>
- shared_ptr<T[M][N]> make_shared(initializer_list<T> list);
+ shared_ptr<T[M][N]> make_shared(const T (&list)[N]);
template<typename T, typename A, typename... Args>
- shared_ptr<T[M][N]> allocate_shared(const A& allocator, initializer_list<T> list);</pre>
+ shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]);</pre>
<blockquote>
<p><b>Description:</b> These overloads of the utilities above are for a
fixed size array.</p>
Modified: branches/release/libs/smart_ptr/test/allocate_shared_array_init_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_array_init_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_init_test.cpp 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -29,13 +29,6 @@
BOOST_TEST(a1[3] == 3);
}
{
- boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), { 0, 1, 2, 3 });
BOOST_TEST(a1[0] == 0);
BOOST_TEST(a1[1] == 1);
@@ -43,13 +36,6 @@
BOOST_TEST(a1[3] == 3);
}
{
- boost::shared_ptr<const int[4]> a1 = boost::allocate_shared<const int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), { 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
@@ -57,14 +43,30 @@
BOOST_TEST(a1[3].value == 3);
}
{
- boost::shared_ptr<type[4]> a1 = boost::allocate_shared<type[4]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(std::allocator<type>(), { 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
BOOST_TEST(a1[2].value == 2);
BOOST_TEST(a1[3].value == 3);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
{
- boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[4]> a1 = boost::allocate_shared<const int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<type[4]> a1 = boost::allocate_shared<type[4]>(std::allocator<type>(), { 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
BOOST_TEST(a1[2].value == 2);
Modified: branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -12,12 +12,28 @@
int main() {
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
{
+ boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), {0, 1, 2, 3});
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), { {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0] == 0);
BOOST_TEST(a1[0][1] == 1);
BOOST_TEST(a1[1][0] == 2);
BOOST_TEST(a1[1][1] == 3);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), {0, 1, 2, 3});
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
{
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>(), { {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0] == 0);
@@ -26,13 +42,6 @@
BOOST_TEST(a1[1][1] == 3);
}
{
- boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>(), {0, 1});
- BOOST_TEST(a1[0][0] == 0);
- BOOST_TEST(a1[0][1] == 1);
- BOOST_TEST(a1[1][0] == 0);
- BOOST_TEST(a1[1][1] == 1);
- }
- {
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2, {0, 1});
BOOST_TEST(a1[0][0] == 0);
BOOST_TEST(a1[0][1] == 1);
@@ -47,6 +56,13 @@
BOOST_TEST(a1[1][1][1] == 3);
}
{
+ boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>(), {0, 1});
+ BOOST_TEST(a1[0][0] == 0);
+ BOOST_TEST(a1[0][1] == 1);
+ BOOST_TEST(a1[1][0] == 0);
+ BOOST_TEST(a1[1][1] == 1);
+ }
+ {
boost::shared_ptr<int[2][2][2]> a1 = boost::allocate_shared<int[2][2][2]>(std::allocator<int>(), { {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0][0] == 0);
BOOST_TEST(a1[0][0][1] == 1);
Modified: branches/release/libs/smart_ptr/test/make_shared_array_init_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/make_shared_array_init_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_array_init_test.cpp 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -29,13 +29,6 @@
BOOST_TEST(a1[3] == 3);
}
{
- boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>({ 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>({ 0, 1, 2, 3 });
BOOST_TEST(a1[0] == 0);
BOOST_TEST(a1[1] == 1);
@@ -43,13 +36,6 @@
BOOST_TEST(a1[3] == 3);
}
{
- boost::shared_ptr<const int[4]> a1 = boost::make_shared<const int[4]>({ 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>({ 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
@@ -57,14 +43,30 @@
BOOST_TEST(a1[3].value == 3);
}
{
- boost::shared_ptr<type[4]> a1 = boost::make_shared<type[4]>({ 0, 1, 2, 3 });
+ boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>({ 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
BOOST_TEST(a1[2].value == 2);
BOOST_TEST(a1[3].value == 3);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
{
- boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>({ 0, 1, 2, 3 });
+ boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[4]> a1 = boost::make_shared<const int[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<type[4]> a1 = boost::make_shared<type[4]>({ 0, 1, 2, 3 });
BOOST_TEST(a1[0].value == 0);
BOOST_TEST(a1[1].value == 1);
BOOST_TEST(a1[2].value == 2);
Modified: branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp 2012-12-02 18:15:55 EST (Sun, 02 Dec 2012)
@@ -8,17 +8,32 @@
*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared_array.hpp>
-#include <string>
int main() {
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
{
+ boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>({0, 1, 2, 3});
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>({ {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0] == 0);
BOOST_TEST(a1[0][1] == 1);
BOOST_TEST(a1[1][0] == 2);
BOOST_TEST(a1[1][1] == 3);
}
+#endif
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>({0, 1, 2, 3});
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
{
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>({ {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0] == 0);
@@ -27,13 +42,6 @@
BOOST_TEST(a1[1][1] == 3);
}
{
- boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>({ 0, 1 });
- BOOST_TEST(a1[0][0] == 0);
- BOOST_TEST(a1[0][1] == 1);
- BOOST_TEST(a1[1][0] == 0);
- BOOST_TEST(a1[1][1] == 1);
- }
- {
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2, {0, 1});
BOOST_TEST(a1[0][0] == 0);
BOOST_TEST(a1[0][1] == 1);
@@ -48,6 +56,13 @@
BOOST_TEST(a1[1][1][1] == 3);
}
{
+ boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>({ 0, 1 });
+ BOOST_TEST(a1[0][0] == 0);
+ BOOST_TEST(a1[0][1] == 1);
+ BOOST_TEST(a1[1][0] == 0);
+ BOOST_TEST(a1[1][1] == 1);
+ }
+ {
boost::shared_ptr<int[2][2][2]> a1 = boost::make_shared<int[2][2][2]>({ {0, 1}, {2, 3} });
BOOST_TEST(a1[0][0][0] == 0);
BOOST_TEST(a1[0][0][1] == 1);
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