|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81882 - 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-12 17:57:04
Author: glenfe
Date: 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
New Revision: 81882
URL: http://svn.boost.org/trac/boost/changeset/81882
Log:
Merged revision(s) 81858,81859,81865,81867 from trunk:
Add overloads of allocate_shared_noinit to complement make_shared_noinit
........
Explicitly name detail array construct overloads for different parameter types.
........
Use _internal_get_untyped_deleter in allocate_shared_array and make_shared_array
........
Documentation corrections: make_shared_array.html
........
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 | 112 ++++++++++++++++++++++++++-------------
branches/release/boost/smart_ptr/detail/array_deleter.hpp | 8 +-
branches/release/boost/smart_ptr/detail/array_utility.hpp | 4
branches/release/boost/smart_ptr/make_shared_array.hpp | 90 ++++++++++++++++----------------
branches/release/libs/smart_ptr/make_shared_array.html | 18 +++++-
branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp | 10 +++
branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp | 74 ++++++++++++++++++++++++++
branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp | 14 +++++
branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp | 56 ++++++++++++++++++++
9 files changed, 293 insertions(+), 93 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-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2012 Glen Joseph Fernandes
+ * Copyright (c) 2012 Glen Joseph Fernandes
* glenfe at live dot com
*
- * Distributed under the Boost Software License,
- * Version 1.0. (See accompanying file LICENSE_1_0.txt
+ * Distributed under the Boost Software License,
+ * Version 1.0. (See accompanying file LICENSE_1_0.txt
* or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
@@ -20,7 +20,7 @@
namespace boost {
template<typename T, typename A>
- inline typename boost::detail::sp_if_array<T>::type
+ inline typename boost::detail::sp_if_array<T>::type
allocate_shared(const A& allocator, std::size_t size) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
@@ -30,9 +30,9 @@
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2);
return boost::shared_ptr<T>(s1, p1);
}
@@ -48,9 +48,9 @@
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
@@ -59,17 +59,17 @@
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 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;
+ typedef boost::detail::array_deleter<T2[N]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
@@ -77,7 +77,7 @@
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
template<typename T, typename A>
inline typename boost::detail::sp_if_array<T>::type
- allocate_shared(const A& allocator,
+ allocate_shared(const A& allocator,
std::initializer_list<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;
@@ -89,10 +89,10 @@
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef 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 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
@@ -104,8 +104,8 @@
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
@@ -113,21 +113,21 @@
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;
+ typedef 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[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T, typename A>
inline typename boost::detail::sp_if_array<T>::type
- allocate_shared(const A& allocator, std::size_t size,
+ 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 {
+ enum {
M = boost::detail::array_total<T1>::size
};
T1* p1 = 0;
@@ -137,41 +137,41 @@
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list<M>(p2, p3);
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,
+ allocate_shared(const A& allocator,
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,
- N = boost::detail::array_total<T>::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;
+ 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;
+ typedef 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[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list<M>(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_RVALUE_REFS)
template<typename T, typename A>
inline typename boost::detail::sp_if_array<T>::type
- allocate_shared(const A& allocator, std::size_t size,
+ allocate_shared(const A& allocator, std::size_t size,
typename boost::detail::array_base<T>::type&& value) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
@@ -181,34 +181,70 @@
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<T2>(value));
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,
+ allocate_shared(const A& allocator,
typename boost::detail::array_base<T>::type&& value) {
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 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;
+ typedef boost::detail::array_deleter<T2[N]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<T2>(value));
return boost::shared_ptr<T>(s1, p1);
}
#endif
#endif
+ template<typename T, typename A>
+ inline typename boost::detail::sp_if_array<T>::type
+ allocate_shared_noinit(const A& allocator, std::size_t size) {
+ typedef typename boost::detail::array_inner<T>::type T1;
+ typedef typename boost::detail::array_base<T1>::type T2;
+ 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(n1);
+ boost::shared_ptr<T> s1(p1, d1, a1);
+ typedef boost::detail::array_deleter<T2[]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
+ d2->construct_noinit(p2);
+ return boost::shared_ptr<T>(s1, p1);
+ }
+ template<typename T, typename A>
+ inline typename boost::detail::sp_if_size_array<T>::type
+ allocate_shared_noinit(const A& allocator) {
+ 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;
+ 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);
+ typedef boost::detail::array_deleter<T2[N]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
+ d2->construct_noinit(p2);
+ return boost::shared_ptr<T>(s1, p1);
+ }
}
#endif
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-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -34,13 +34,13 @@
}
#if defined(BOOST_HAS_RVALUE_REFS)
void construct(T* memory, T&& value) {
- array_construct(memory, size, sp_forward<T>(value));
+ array_construct_value(memory, size, sp_forward<T>(value));
object = memory;
}
#if defined(BOOST_HAS_VARIADIC_TMPL)
template<typename... Args>
void construct(T* memory, Args&&... args) {
- array_construct(memory, size, sp_forward<Args>(args)...);
+ array_construct_args(memory, size, sp_forward<Args>(args)...);
object = memory;
}
#endif
@@ -85,13 +85,13 @@
}
#if defined(BOOST_HAS_RVALUE_REFS)
void construct(T* memory, T&& value) {
- array_construct(memory, N, sp_forward<T>(value));
+ array_construct_value(memory, N, sp_forward<T>(value));
object = memory;
}
#if defined(BOOST_HAS_VARIADIC_TMPL)
template<typename... Args>
void construct(T* memory, Args&&... args) {
- array_construct(memory, N, sp_forward<Args>(args)...);
+ array_construct_args(memory, N, sp_forward<Args>(args)...);
object = memory;
}
#endif
Modified: branches/release/boost/smart_ptr/detail/array_utility.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/array_utility.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_utility.hpp 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -55,7 +55,7 @@
}
#if defined(BOOST_HAS_RVALUE_REFS)
template<typename T>
- inline void array_construct(T* memory, std::size_t size, T&& value) {
+ inline void array_construct_value(T* memory, std::size_t size, T&& value) {
std::size_t i = 0;
try {
for (; i < size; i++) {
@@ -69,7 +69,7 @@
}
#if defined(BOOST_HAS_VARIADIC_TMPL)
template<typename T, typename... Args>
- inline void array_construct(T* memory, std::size_t size, Args&&... args) {
+ inline void array_construct_args(T* memory, std::size_t size, Args&&... args) {
std::size_t i = 0;
try {
for (; i < size; i++) {
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-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2012 Glen Joseph Fernandes
+ * Copyright (c) 2012 Glen Joseph Fernandes
* glenfe at live dot com
*
- * Distributed under the Boost Software License,
- * Version 1.0. (See accompanying file LICENSE_1_0.txt
+ * Distributed under the Boost Software License,
+ * Version 1.0. (See accompanying file LICENSE_1_0.txt
* or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
@@ -30,9 +30,9 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
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);
+ typedef boost::detail::array_deleter<T2[]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2);
return boost::shared_ptr<T>(s1, p1);
}
@@ -48,9 +48,9 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
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);
+ typedef boost::detail::array_deleter<T2[]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
@@ -59,17 +59,17 @@
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
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);
+ typedef boost::detail::array_deleter<T2[N]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<Args>(args)...);
return boost::shared_ptr<T>(s1, p1);
}
@@ -88,13 +88,13 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef 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 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
- }
+ }
#endif
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<typename T>
@@ -103,8 +103,8 @@
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
@@ -112,22 +112,22 @@
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;
+ typedef 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[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
template<typename T>
inline typename boost::detail::sp_if_array<T>::type
- make_shared(std::size_t size,
+ 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 {
- M = boost::detail::array_total<T1>::size
+ enum {
+ M = boost::detail::array_total<T1>::size
};
T1* p1 = 0;
T2* p2 = 0;
@@ -136,10 +136,10 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p3 = reinterpret_cast<T3*>(list);
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list<M>(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
@@ -149,9 +149,9 @@
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
typedef const T2 T3;
- enum {
+ enum {
M = boost::detail::array_total<T1>::size,
- N = boost::detail::array_total<T>::size
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
@@ -159,17 +159,17 @@
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;
+ typedef 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[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_list<M>(p2, p3);
return boost::shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_RVALUE_REFS)
template<typename T>
inline typename boost::detail::sp_if_array<T>::type
- make_shared(std::size_t size,
+ make_shared(std::size_t size,
typename boost::detail::array_base<T>::type&& value) {
typedef typename boost::detail::array_inner<T>::type T1;
typedef typename boost::detail::array_base<T1>::type T2;
@@ -179,9 +179,9 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
boost::detail::array_deleter<T2[]> d1(n1);
boost::shared_ptr<T> s1(p1, d1, a1);
- boost::detail::array_deleter<T2[]>* d2;
+ typedef boost::detail::array_deleter<T2[]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<T2>(value));
return boost::shared_ptr<T>(s1, p1);
}
@@ -190,17 +190,17 @@
make_shared(typename boost::detail::array_base<T>::type&& value) {
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
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;
+ typedef boost::detail::array_deleter<T2[N]>* D2;
p1 = reinterpret_cast<T1*>(p2);
- d2 = get_deleter<boost::detail::array_deleter<T2[N]> >(s1);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct(p2, boost::detail::sp_forward<T2>(value));
return boost::shared_ptr<T>(s1, p1);
}
@@ -217,9 +217,9 @@
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
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);
+ typedef boost::detail::array_deleter<T2[]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_noinit(p2);
return boost::shared_ptr<T>(s1, p1);
}
@@ -228,17 +228,17 @@
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
+ enum {
+ N = boost::detail::array_total<T>::size
};
T1* p1 = 0;
T2* p2 = 0;
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);
+ typedef boost::detail::array_deleter<T2[N]>* D2;
+ p1 = reinterpret_cast<T1*>(p2);
+ D2 d2 = static_cast<D2>(s1._internal_get_untyped_deleter());
d2->construct_noinit(p2);
return boost::shared_ptr<T>(s1, p1);
}
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-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -96,6 +96,12 @@
template<typename T>
shared_ptr<T[N]> make_shared_noinit();
+
+ template<typename T, typename A>
+ shared_ptr<T[]> allocate_shared_noinit(const A& allocator, size_t size);
+
+ template<typename T, typename A>
+ shared_ptr<T[N]> allocate_shared_noinit(const A& allocator);
}</pre>
<h2><a name="functions">Free Functions</a></h2>
<pre>template<typename T, typename... Args>
@@ -197,15 +203,19 @@
fixed size array.</p>
</blockquote>
<pre>template<typename T>
- shared_ptr<T[]> make_shared_noinit(size_t size);</pre>
+ shared_ptr<T[]> make_shared_noinit(size_t size);
+template<typename T, typename A>
+ shared_ptr<T[]> allocate_shared_noinit(const A& allocator, size_t size);</pre>
<blockquote>
- <p><b>Description:</b> This overload does not perform value
+ <p><b>Description:</b> These overloads do not perform any value
initialization of elements.</p>
</blockquote>
<pre>template<typename T>
- shared_ptr<T[N]> make_shared_noinit();</pre>
+ shared_ptr<T[N]> make_shared_noinit();
+template<typename T, typename A>
+ shared_ptr<T[N]> allocate_shared_noinit(const A& allocator);</pre>
<blockquote>
- <p><b>Description:</b> This overload of the utility above is used for a
+ <p><b>Description:</b> These overloads of the utilities above are for a
fixed size array.</p>
</blockquote>
<h2><a name="example">Example</a></h2>
Modified: branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -38,5 +38,15 @@
BOOST_TEST(type::instances == 3);
}
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
+ try {
+ a1[0].shared_from_this();
+ BOOST_ERROR("shared_from_this did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 3);
+ }
+ }
return boost::report_errors();
}
Modified: branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -121,5 +121,79 @@
BOOST_TEST(type::instances == 0);
}
#endif
+ {
+ boost::shared_ptr<int[]> a1 = boost::allocate_shared_noinit<int[]>(std::allocator<int>(), 3);
+ int* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
+ }
+ {
+ boost::shared_ptr<int[3]> a1 = boost::allocate_shared_noinit<int[3]>(std::allocator<int>());
+ int* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
+ }
+ {
+ boost::shared_ptr<const int[]> a1 = boost::allocate_shared_noinit<const int[]>(std::allocator<int>(), 3);
+ const int* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
+ }
+ {
+ boost::shared_ptr<const int[3]> a1 = boost::allocate_shared_noinit<const int[3]>(std::allocator<int>());
+ const int* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
+ type* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
+ BOOST_TEST(type::instances == 3);
+ boost::weak_ptr<type[]> w1 = a1;
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[3]> a1 = boost::allocate_shared_noinit<type[3]>(std::allocator<type>());
+ type* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
+ BOOST_TEST(type::instances == 3);
+ boost::weak_ptr<type[3]> w1 = a1;
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[]> a1 = boost::allocate_shared_noinit<const type[]>(std::allocator<type>(), 3);
+ const type* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
+ BOOST_TEST(type::instances == 3);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[3]> a1 = boost::allocate_shared_noinit<const type[3]>(std::allocator<type>());
+ const type* a2 = a1.get();
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(a2 != 0);
+ BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
+ BOOST_TEST(type::instances == 3);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
return boost::report_errors();
}
Modified: branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -59,5 +59,19 @@
BOOST_TEST(type::instances == 0);
}
#endif
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 6);
+ BOOST_ERROR("allocate_shared_noinit did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 3);
+ BOOST_ERROR("allocate_shared_noinit did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
return boost::report_errors();
}
Modified: branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp 2012-12-12 17:57:03 EST (Wed, 12 Dec 2012)
@@ -100,5 +100,61 @@
BOOST_TEST(type::instances == 0);
}
#endif
+ {
+ boost::shared_ptr<int[][2][2]> a1 = boost::allocate_shared_noinit<int[][2][2]>(std::allocator<int>(), 2);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ }
+ {
+ boost::shared_ptr<int[2][2][2]> a1 = boost::allocate_shared_noinit<int[2][2][2]>(std::allocator<int>());
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ }
+ {
+ boost::shared_ptr<const int[][2][2]> a1 = boost::allocate_shared_noinit<const int[][2][2]>(std::allocator<int>(), 2);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ }
+ {
+ boost::shared_ptr<const int[2][2][2]> a1 = boost::allocate_shared_noinit<const int[2][2][2]>(std::allocator<int>());
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[][2][2]> a1 = boost::allocate_shared_noinit<type[][2][2]>(std::allocator<type>(), 2);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2]> a1 = boost::allocate_shared_noinit<type[2][2][2]>(std::allocator<type>());
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[][2][2]> a1 = boost::allocate_shared_noinit<const type[][2][2]>(std::allocator<type>(), 2);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[2][2][2]> a1 = boost::allocate_shared_noinit<const type[2][2][2]>(std::allocator<type>());
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
return boost::report_errors();
}
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