|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81339 - in branches/release: . boost boost/smart_ptr boost/smart_ptr/detail libs libs/smart_ptr libs/smart_ptr/test
From: pdimov_at_[hidden]
Date: 2012-11-14 08:52:15
Author: pdimov
Date: 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
New Revision: 81339
URL: http://svn.boost.org/trac/boost/changeset/81339
Log:
Merged revision(s) 81149, 81159, 81171, 81174, 81219-81220, 81222-81224, 81226, 81229-81239, 81242, 81253, 81257-81262, 81265-81268, 81271-81272, 81275-81277, 81299-81300 from trunk:
Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
........
Fix shared_ptr<T[]> EDG issues.
........
Disable make_shared<T> overloads when T is Q[].
........
Add catch(...) clauses to sp_array_test.cpp.
........
Add allocate_shared and make_shared for shared_ptr arrays of runtime size. Fulfills need for allocate_shared_array and make_shared_array.
........
Update Jamfile.v2 to run make_shared array tests and allocate_shared array tests.
........
Fix g++ issues.
........
Add specialization of sp_if_not_array<T[N]>.
........
Rename make_shared.hpp to make_shared_object.hpp, include from make_shared.hpp.
........
Add make_shared_array_args_test.cpp.
........
Add support for make_shared of array of arrays. Correctly destroy elements and construct elements for the variadic template constructor variants.
........
Fix sp_convertible<T const[], T const[]>.
........
Update smart_ptr/detail/array_helper to have create and create_noinit for non-array case.
........
Rename sp_convertible_test.cpp to shared_ptr_convertible_test.cpp.
........
Don't treat array_helper create and create_noinit for array types as a special case.
........
Add sp_convertible_test.cpp.
........
Fix array_helper (create_noinit and use of args...).
........
Update allocate_shared and make_shared to treat multidimensional array as single dimension. Remove detail array_helper. Add detail array traits. Update tests.
........
Simplify array_deleter interface
........
Add missing semicolon.
........
Fix typo.
........
Add tests for variadic template constructors overload of array forms of make_shared and allocate_shared for multidimensional arrays and up to 9 constructor arguments.
........
Add support for shared_ptr<X[N>.
........
Add C++11 initializer list support for make_shared and allocate_shared array forms.
........
Clean up code in allocate_shared_array.hpp and make_shared_array.hpp
........
Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
........
Disable make_shared for arrays when the compiler doesn't support partial specialization or SFINAE.
........
For allocate_shared and make_shared: Separate test case that g++ does support yet. Remove macros testing for no partial specialization in traits. Add additional traits.
........
Actually remove test cases from make_shared_array_create_test.cpp and allocate_shared_array_create_test.cpp that g++ does not handle.
........
Add overloads to support fixed size arrays, T[N], to allocate_shared (variadic) and make_shared (variadic) and make_shared_noinit.
........
Add additional overload for make_shared and allocate_shared for arrays for fixed size arrays and initializer lists.
........
Add assertion to overload of make_shared and allocate_shared for T[N] with initializer lists. Rename detail type to be more intuitive.
........
Add allocate_shared_array_args_test.cpp.
........
Keep old definition of sp_assert_convertible when BOOST_SP_NO_SP_CONVERTIBLE is set.
........
Updated shared_array to match shared_ptr. Refs #1113.
........
Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
........
Change traits for initializer list for g++
........
Tidy long line formatting in allocate_shared_array.hpp and make_shared_array.hpp
........
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
........
Update Jamfile.v2 with two new smart_ptr tests for allocate_shared and make_shared
........
Added:
branches/release/boost/smart_ptr/allocate_shared_array.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/allocate_shared_array.hpp
branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/detail/allocate_array_helper.hpp
branches/release/boost/smart_ptr/detail/array_deleter.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/detail/array_deleter.hpp
branches/release/boost/smart_ptr/detail/array_traits.hpp
- copied, changed from r81239, /trunk/boost/smart_ptr/detail/array_traits.hpp
branches/release/boost/smart_ptr/detail/make_array_helper.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/detail/make_array_helper.hpp
branches/release/boost/smart_ptr/detail/sp_if_array.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/detail/sp_if_array.hpp
branches/release/boost/smart_ptr/make_shared.hpp
- copied, changed from r81224, /trunk/boost/smart_ptr/make_shared.hpp
branches/release/boost/smart_ptr/make_shared_array.hpp
- copied, changed from r81220, /trunk/boost/smart_ptr/make_shared_array.hpp
branches/release/boost/smart_ptr/make_shared_object.hpp
- copied unchanged from r81224, /trunk/boost/smart_ptr/make_shared_object.hpp
branches/release/libs/smart_ptr/make_shared_array.html
- copied, changed from r81220, /trunk/libs/smart_ptr/make_shared_array.html
branches/release/libs/smart_ptr/test/allocate_shared_array_args_test.cpp
- copied unchanged from r81268, /trunk/libs/smart_ptr/test/allocate_shared_array_args_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_array_create_test.cpp
- copied, changed from r81242, /trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_array_init_test.cpp
- copied unchanged from r81300, /trunk/libs/smart_ptr/test/allocate_shared_array_init_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp
- copied, changed from r81262, /trunk/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp
branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp
- copied, changed from r81239, /trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp
branches/release/libs/smart_ptr/test/array_fail_ap_spa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_ap_spa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_ap_spa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_ap_spa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_ap_spa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_ap_spa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_ap_spa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_ap_spa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_array_access.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_array_access.cpp
branches/release/libs/smart_ptr/test/array_fail_dereference.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_dereference.cpp
branches/release/libs/smart_ptr/test/array_fail_member_access.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_member_access.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_spa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_spa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_spa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_spa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_spa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_spa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_spa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_spa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_wpa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_wpa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_wpa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_wpa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_wpa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_wpa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_sp_wpa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_sp_wpa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_sp_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_sp_a.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_sp_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_sp_c.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_sp_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_sp_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_sp_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_sp_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_spa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_spa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_spa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_spa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_spa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_spa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_spa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_spa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wp_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wp_a.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wp_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wp_c.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wp_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wp_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wp_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wp_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wpa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wpa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wpa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wpa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wpa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wpa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_spa_wpa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_spa_wpa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_up_spa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_up_spa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_up_spa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_up_spa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_up_spa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_up_spa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_up_spa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_up_spa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_upa_sp_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_upa_sp_a.cpp
branches/release/libs/smart_ptr/test/array_fail_upa_sp_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_upa_sp_c.cpp
branches/release/libs/smart_ptr/test/array_fail_upa_sp_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_upa_sp_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_upa_sp_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_upa_sp_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_wp_wpa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wp_wpa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_wp_wpa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wp_wpa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_wp_wpa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wp_wpa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_wp_wpa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wp_wpa_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wp_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wp_a.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wp_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wp_c.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wp_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wp_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wp_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wp_mc.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wpa_a.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wpa_a.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wpa_c.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wpa_c.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wpa_ma.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wpa_ma.cpp
branches/release/libs/smart_ptr/test/array_fail_wpa_wpa_mc.cpp
- copied unchanged from r81149, /trunk/libs/smart_ptr/test/array_fail_wpa_wpa_mc.cpp
branches/release/libs/smart_ptr/test/make_shared_array_args_test.cpp
- copied unchanged from r81226, /trunk/libs/smart_ptr/test/make_shared_array_args_test.cpp
branches/release/libs/smart_ptr/test/make_shared_array_create_test.cpp
- copied, changed from r81242, /trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp
branches/release/libs/smart_ptr/test/make_shared_array_esft_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp
branches/release/libs/smart_ptr/test/make_shared_array_init_test.cpp
- copied unchanged from r81300, /trunk/libs/smart_ptr/test/make_shared_array_init_test.cpp
branches/release/libs/smart_ptr/test/make_shared_array_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/make_shared_array_test.cpp
branches/release/libs/smart_ptr/test/make_shared_array_throws_test.cpp
- copied, changed from r81220, /trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp
branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp
- copied, changed from r81262, /trunk/libs/smart_ptr/test/make_shared_arrays_create_test.cpp
branches/release/libs/smart_ptr/test/make_shared_arrays_test.cpp
- copied, changed from r81239, /trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp
branches/release/libs/smart_ptr/test/shared_ptr_convertible_test.cpp
- copied unchanged from r81239, /trunk/libs/smart_ptr/test/shared_ptr_convertible_test.cpp
branches/release/libs/smart_ptr/test/sp_array_cv_test.cpp
- copied, changed from r81159, /trunk/libs/smart_ptr/test/sp_array_cv_test.cpp
branches/release/libs/smart_ptr/test/sp_array_n_test.cpp
- copied unchanged from r81253, /trunk/libs/smart_ptr/test/sp_array_n_test.cpp
branches/release/libs/smart_ptr/test/sp_array_test.cpp
- copied, changed from r81149, /trunk/libs/smart_ptr/test/sp_array_test.cpp
branches/release/libs/smart_ptr/test/sp_convertible_test.cpp
- copied, changed from r81239, /trunk/libs/smart_ptr/test/sp_convertible_test.cpp
Properties modified:
branches/release/ (props changed)
branches/release/boost/ (props changed)
branches/release/libs/ (props changed)
Text files modified:
branches/release/boost/smart_ptr/allocate_shared_array.hpp | 127 +++++++++++++++++--
branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp | 7
branches/release/boost/smart_ptr/detail/array_deleter.hpp | 16 ++
branches/release/boost/smart_ptr/detail/array_traits.hpp | 41 +++++-
branches/release/boost/smart_ptr/detail/make_array_helper.hpp | 17 +-
branches/release/boost/smart_ptr/detail/operator_bool.hpp | 4
branches/release/boost/smart_ptr/detail/shared_count.hpp | 2
branches/release/boost/smart_ptr/detail/sp_convertible.hpp | 15 ++
branches/release/boost/smart_ptr/detail/sp_if_array.hpp | 9 +
branches/release/boost/smart_ptr/make_shared.hpp | 7
branches/release/boost/smart_ptr/make_shared_array.hpp | 154 ++++++++++++++++++++---
branches/release/boost/smart_ptr/shared_array.hpp | 106 +++++++++++++++-
branches/release/boost/smart_ptr/shared_ptr.hpp | 261 +++++++++++++++++++++++++++++++++------
branches/release/boost/smart_ptr/weak_ptr.hpp | 21 ++
branches/release/libs/smart_ptr/make_shared_array.html | 39 +++++
branches/release/libs/smart_ptr/test/Jamfile.v2 | 79 +++++++++++
branches/release/libs/smart_ptr/test/allocate_shared_array_create_test.cpp | 36 +++++
branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp | 2
branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp | 38 +++++
branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp | 7 +
branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp | 21 +++
branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp | 29 ++++
branches/release/libs/smart_ptr/test/make_shared_array_create_test.cpp | 36 +++++
branches/release/libs/smart_ptr/test/make_shared_array_esft_test.cpp | 4
branches/release/libs/smart_ptr/test/make_shared_array_test.cpp | 85 ++++++++++++
branches/release/libs/smart_ptr/test/make_shared_array_throws_test.cpp | 16 ++
branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp | 22 +++
branches/release/libs/smart_ptr/test/make_shared_arrays_test.cpp | 59 +++++++++
branches/release/libs/smart_ptr/test/smart_ptr_test.cpp | 4
branches/release/libs/smart_ptr/test/sp_array_cv_test.cpp | 50 +++++--
branches/release/libs/smart_ptr/test/sp_array_test.cpp | 20 +++
branches/release/libs/smart_ptr/test/sp_convertible_test.cpp | 2
32 files changed, 1185 insertions(+), 151 deletions(-)
Copied: branches/release/boost/smart_ptr/allocate_shared_array.hpp (from r81220, /trunk/boost/smart_ptr/allocate_shared_array.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/allocate_shared_array.hpp (original)
+++ branches/release/boost/smart_ptr/allocate_shared_array.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -9,38 +9,133 @@
#ifndef BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
-#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/allocate_array_helper.hpp>
#include <boost/smart_ptr/detail/array_deleter.hpp>
+#include <boost/smart_ptr/detail/array_traits.hpp>
#include <boost/smart_ptr/detail/sp_if_array.hpp>
-#include <boost/type_traits/remove_cv.hpp>
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+#include <initializer_list>
+#endif
namespace boost {
template<typename T, typename A>
inline typename detail::sp_if_array<T>::type
- allocate_shared(const A& allocator, size_t size) {
- typedef typename remove_cv<shared_ptr<T>::element_type>::type T1;
+ allocate_shared(const A& allocator, std::size_t size) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
T1* p1 = 0;
- detail::allocate_array_helper<A, T1> a1(allocator, size, &p1);
- detail::array_deleter<T1> d1;
+ T2* p2 = 0;
+ std::size_t n1 = size * detail::array_total<T1>::size;
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
shared_ptr<T> s1(p1, d1, a1);
- detail::array_deleter<T1>* d2;
- d2 = get_deleter<detail::array_deleter<T1> >(s1);
- d2->construct(p1, size);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1);
return shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
template<typename T, typename A, typename... Args>
inline typename detail::sp_if_array<T>::type
- allocate_shared(const A& allocator, size_t size, Args&&... args) {
- typedef typename remove_cv<shared_ptr<T>::element_type>::type T1;
+ allocate_shared(const A& allocator, std::size_t size, Args&&... args) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ std::size_t n1 = size * detail::array_total<T1>::size;
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1, std::forward<Args>(args)...);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T, typename A, typename... Args>
+ inline typename detail::sp_if_size_array<T>::type
+ allocate_shared(const A& allocator, Args&&... args) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ std::size_t n1 = detail::array_total<T>::size;
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1, std::forward<Args>(args)...);
+ return shared_ptr<T>(s1, p1);
+ }
+#endif
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ template<typename T, typename A>
+ inline typename detail::sp_if_array<T>::type
+ allocate_shared(const A& allocator,
+ std::initializer_list<typename detail::array_inner<T>::type> list) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n1 = list.size() * detail::array_total<T1>::size;
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T, typename A>
+ inline typename detail::sp_if_size_array<T>::type
+ allocate_shared(const A& allocator,
+ std::initializer_list<typename detail::array_inner<T>::type> list) {
+ BOOST_ASSERT(list.size() == detail::array_size<T>::size);
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n1 = detail::array_total<T>::size;
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T, typename A>
+ inline typename detail::sp_if_array<T>::type
+ allocate_shared(const A& allocator, std::size_t size,
+ std::initializer_list<typename detail::arrays_inner<T>::type> list) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
T1* p1 = 0;
- detail::allocate_array_helper<A, T1> a1(allocator, size, &p1);
- detail::array_deleter<T1> d1;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n0 = detail::array_total<T1>::size;
+ std::size_t n1 = n0 * list.size();
+ detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
+ detail::array_deleter<T2> d1;
shared_ptr<T> s1(p1, d1, a1);
- detail::array_deleter<T1>* d2;
- d2 = get_deleter<detail::array_deleter<T1> >(s1);
- d2->construct(p1, size, std::forward<Args>(args)...);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3, n0);
return shared_ptr<T>(s1, p1);
}
#endif
Copied: branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp (from r81220, /trunk/boost/smart_ptr/detail/allocate_array_helper.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/detail/allocate_array_helper.hpp (original)
+++ branches/release/boost/smart_ptr/detail/allocate_array_helper.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -10,16 +10,15 @@
#define BOOST_SMART_PTR_DETAIL_ALLOCATE_ARRAY_HELPER_HPP
#include <boost/type_traits/alignment_of.hpp>
-#include <cstddef>
namespace boost {
namespace detail {
template<typename A, typename T, typename Y = T>
class allocate_array_helper {
- template<typename A, typename T, typename Y>
+ template<typename A9, typename T9, typename Y9>
friend class allocate_array_helper;
- typedef typename A::rebind<Y> ::other A2;
- typedef typename A::rebind<char>::other A3;
+ 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;
Copied: branches/release/boost/smart_ptr/detail/array_deleter.hpp (from r81220, /trunk/boost/smart_ptr/detail/array_deleter.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/detail/array_deleter.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_deleter.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -38,13 +38,27 @@
}
}
#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, 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]);
+ }
+ }
+#endif
void construct_noinit(T* memory, std::size_t count) {
for (object = memory; size < count; size++) {
void* p1 = object + size;
::new(p1) T;
}
}
- void operator()(T*) {
+ void operator()(const void*) {
destroy();
}
private:
Copied: branches/release/boost/smart_ptr/detail/array_traits.hpp (from r81239, /trunk/boost/smart_ptr/detail/array_traits.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/detail/array_traits.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_traits.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -14,25 +14,52 @@
namespace boost {
namespace detail {
template<typename T>
- struct array_type {
+ struct array_base {
typedef typename boost::remove_cv<T>::type type;
};
- template<typename T, size_t N>
- struct array_type<T[N]> {
- typedef typename array_type<T>::type type;
+ template<typename T, std::size_t N>
+ struct array_base<T[N]> {
+ typedef typename array_base<T>::type type;
};
template<typename T>
struct array_size {
+ };
+ template<typename T, size_t N>
+ struct array_size<T[N]> {
+ enum {
+ size = N
+ };
+ };
+ template<typename T>
+ struct array_total {
enum {
size = 1
};
};
- template<typename T, size_t N>
- struct array_size<T[N]> {
+ template<typename T, std::size_t N>
+ struct array_total<T[N]> {
enum {
- size = N * array_size<T>::size
+ size = N * array_total<T>::size
};
};
+ template<typename T>
+ struct array_inner {
+ };
+ template<typename T>
+ struct array_inner<T[]> {
+ typedef T type;
+ };
+ template<typename T, size_t N>
+ struct array_inner<T[N]> {
+ typedef T type;
+ };
+ template<typename T>
+ struct arrays_inner {
+ };
+ template<typename T, size_t N>
+ struct arrays_inner<T[][N]> {
+ typedef T type;
+ };
}
}
Copied: branches/release/boost/smart_ptr/detail/make_array_helper.hpp (from r81220, /trunk/boost/smart_ptr/detail/make_array_helper.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/detail/make_array_helper.hpp (original)
+++ branches/release/boost/smart_ptr/detail/make_array_helper.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -10,22 +10,21 @@
#define BOOST_SMART_PTR_DETAIL_MAKE_ARRAY_HELPER_HPP
#include <boost/type_traits/alignment_of.hpp>
-#include <cstddef>
namespace boost {
namespace detail {
template<typename T, typename Y = T>
class make_array_helper {
- template<typename T, typename Y>
+ template<typename T2, typename Y2>
friend class make_array_helper;
public:
- typedef typename Y value_type;
- typedef typename Y* pointer;
- typedef typename const Y* const_pointer;
- typedef typename Y& reference;
- typedef typename const Y& const_reference;
- typedef typename std::size_t size_type;
- typedef typename ptrdiff_t difference_type;
+ 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, U> other;
Modified: branches/release/boost/smart_ptr/detail/operator_bool.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/operator_bool.hpp (original)
+++ branches/release/boost/smart_ptr/detail/operator_bool.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -31,7 +31,7 @@
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
- typedef T * (this_type::*unspecified_bool_type)() const;
+ typedef element_type * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws
{
@@ -40,7 +40,7 @@
#else
- typedef T * this_type::*unspecified_bool_type;
+ typedef element_type * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const // never throws
{
Modified: branches/release/boost/smart_ptr/detail/shared_count.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/shared_count.hpp (original)
+++ branches/release/boost/smart_ptr/detail/shared_count.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -347,7 +347,7 @@
typedef typename sp_convert_reference<D>::type D2;
D2 d2( r.get_deleter() );
- pi_ = new sp_counted_impl_pd< Y*, D2 >( r.get(), d2 );
+ pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
#ifdef BOOST_NO_EXCEPTIONS
Modified: branches/release/boost/smart_ptr/detail/sp_convertible.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/sp_convertible.hpp (original)
+++ branches/release/boost/smart_ptr/detail/sp_convertible.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -48,6 +48,21 @@
enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
};
+template< class Y, class T > struct sp_convertible< Y, T[] >
+{
+ enum _vt { value = false };
+};
+
+template< class Y, class T > struct sp_convertible< Y[], T[] >
+{
+ enum _vt { value = sp_convertible< Y[1], T[1] >::value };
+};
+
+template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
+{
+ enum _vt { value = sp_convertible< Y[1], T[1] >::value };
+};
+
struct sp_empty
{
};
Copied: branches/release/boost/smart_ptr/detail/sp_if_array.hpp (from r81220, /trunk/boost/smart_ptr/detail/sp_if_array.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/detail/sp_if_array.hpp (original)
+++ branches/release/boost/smart_ptr/detail/sp_if_array.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -16,12 +16,17 @@
template<typename T>
struct sp_if_array {
};
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template<typename T>
struct sp_if_array<T[]> {
typedef boost::shared_ptr<T[]> type;
};
-#endif
+ template<typename T>
+ struct sp_if_size_array {
+ };
+ template<typename T, std::size_t N>
+ struct sp_if_size_array<T[N]> {
+ typedef boost::shared_ptr<T[N]> type;
+ };
}
}
Copied: branches/release/boost/smart_ptr/make_shared.hpp (from r81224, /trunk/boost/smart_ptr/make_shared.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/make_shared.hpp (original)
+++ branches/release/boost/smart_ptr/make_shared.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -13,7 +13,10 @@
// for documentation.
#include <boost/smart_ptr/make_shared_object.hpp>
-#include <boost/smart_ptr/make_shared_array.hpp>
-#include <boost/smart_ptr/allocate_shared_array.hpp>
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_SFINAE )
+# include <boost/smart_ptr/make_shared_array.hpp>
+# include <boost/smart_ptr/allocate_shared_array.hpp>
+#endif
#endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_HPP_INCLUDED
Copied: branches/release/boost/smart_ptr/make_shared_array.hpp (from r81220, /trunk/boost/smart_ptr/make_shared_array.hpp)
==============================================================================
--- /trunk/boost/smart_ptr/make_shared_array.hpp (original)
+++ branches/release/boost/smart_ptr/make_shared_array.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -9,52 +9,166 @@
#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
-#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/array_deleter.hpp>
+#include <boost/smart_ptr/detail/array_traits.hpp>
#include <boost/smart_ptr/detail/make_array_helper.hpp>
#include <boost/smart_ptr/detail/sp_if_array.hpp>
-#include <boost/type_traits/remove_cv.hpp>
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+#include <initializer_list>
+#endif
namespace boost {
template<typename T>
inline typename detail::sp_if_array<T>::type
make_shared(std::size_t size) {
- typedef typename remove_cv<shared_ptr<T>::element_type>::type T1;
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
T1* p1 = 0;
- detail::make_array_helper<T1> a1(size, &p1);
- detail::array_deleter<T1> d1;
+ T2* p2 = 0;
+ std::size_t n1 = size * detail::array_total<T1>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
shared_ptr<T> s1(p1, d1, a1);
- detail::array_deleter<T1>* d2;
- d2 = get_deleter<detail::array_deleter<T1> >(s1);
- d2->construct(p1, size);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1);
return shared_ptr<T>(s1, p1);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
template<typename T, typename... Args>
inline typename detail::sp_if_array<T>::type
make_shared(std::size_t size, Args&&... args) {
- typedef typename remove_cv<shared_ptr<T>::element_type>::type T1;
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ std::size_t n1 = size * detail::array_total<T1>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1, std::forward<Args>(args)...);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T, typename... Args>
+ inline typename detail::sp_if_size_array<T>::type
+ make_shared(Args&&... args) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
T1* p1 = 0;
- detail::make_array_helper<T1> a1(size, &p1);
- detail::array_deleter<T1> d1;
+ T2* p2 = 0;
+ std::size_t n1 = detail::array_total<T>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
shared_ptr<T> s1(p1, d1, a1);
- detail::array_deleter<T1>* d2;
- d2 = get_deleter<detail::array_deleter<T1> >(s1);
- d2->construct(p1, size, std::forward<Args>(args)...);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct(p2, n1, std::forward<Args>(args)...);
+ return shared_ptr<T>(s1, p1);
+ }
+#endif
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ template<typename T>
+ inline typename detail::sp_if_array<T>::type
+ make_shared(std::initializer_list<typename detail::array_inner<T>::type> list) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n1 = list.size() * detail::array_total<T1>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T>
+ inline typename detail::sp_if_size_array<T>::type
+ make_shared(std::initializer_list<typename detail::array_inner<T>::type> list) {
+ BOOST_ASSERT(list.size() == detail::array_size<T>::size);
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n1 = detail::array_total<T>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T>
+ inline typename detail::sp_if_array<T>::type
+ make_shared(std::size_t size,
+ std::initializer_list<typename detail::arrays_inner<T>::type> list) {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ typedef const T2 T3;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ T3* p3 = 0;
+ std::size_t n0 = detail::array_total<T1>::size;
+ std::size_t n1 = n0 * size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p3 = reinterpret_cast<T3*>(list.begin());
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_list(p2, n1, p3, n0);
return shared_ptr<T>(s1, p1);
}
#endif
template<typename T>
inline typename detail::sp_if_array<T>::type
make_shared_noinit(std::size_t size) {
- typedef typename remove_cv<shared_ptr<T>::element_type>::type T1;
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
+ T1* p1 = 0;
+ T2* p2 = 0;
+ std::size_t n1 = size * detail::array_total<T1>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
+ shared_ptr<T> s1(p1, d1, a1);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_noinit(p2, n1);
+ return shared_ptr<T>(s1, p1);
+ }
+ template<typename T>
+ inline typename detail::sp_if_size_array<T>::type
+ make_shared_noinit() {
+ typedef typename detail::array_inner<T>::type T1;
+ typedef typename detail::array_base<T1>::type T2;
T1* p1 = 0;
- detail::make_array_helper<T1> a1(size, &p1);
- detail::array_deleter<T1> d1;
+ T2* p2 = 0;
+ std::size_t n1 = detail::array_total<T>::size;
+ detail::make_array_helper<T2> a1(n1, &p2);
+ detail::array_deleter<T2> d1;
shared_ptr<T> s1(p1, d1, a1);
- detail::array_deleter<T1>* d2;
- d2 = get_deleter<detail::array_deleter<T1> >(s1);
- d2->construct_noinit(p1, size);
+ detail::array_deleter<T2>* d2;
+ p1 = reinterpret_cast<T1*>(p2);
+ d2 = get_deleter<detail::array_deleter<T2> >(s1);
+ d2->construct_noinit(p2, n1);
return shared_ptr<T>(s1, p1);
}
}
Modified: branches/release/boost/smart_ptr/shared_array.hpp
==============================================================================
--- branches/release/boost/smart_ptr/shared_array.hpp (original)
+++ branches/release/boost/smart_ptr/shared_array.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -5,7 +5,7 @@
// shared_array.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
-// Copyright (c) 2001, 2002 Peter Dimov
+// Copyright (c) 2001, 2002, 2012 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -25,6 +25,7 @@
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
+#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/detail/workaround.hpp>
@@ -55,18 +56,32 @@
typedef T element_type;
- explicit shared_array(T * p = 0): px(p), pn(p, deleter())
+ shared_array(): px( 0 ), pn() // never throws
{
}
+ template<class Y>
+ explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() )
+ {
+ boost::detail::sp_assert_convertible< Y[], T[] >();
+ }
+
//
// Requirements: D's copy constructor must not throw
//
// shared_array will release p by calling d(p)
//
- template<class D> shared_array(T * p, D d): px(p), pn(p, d)
+ template<class Y, class D> shared_array( Y * p, D d ): px( p ), pn( p, d )
+ {
+ boost::detail::sp_assert_convertible< Y[], T[] >();
+ }
+
+ // As above, but with allocator. A's copy constructor shall not throw.
+
+ template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a )
{
+ boost::detail::sp_assert_convertible< Y[], T[] >();
}
// generated copy constructor, destructor are fine...
@@ -79,8 +94,38 @@
{
}
+ shared_array( shared_array && r ): px( r.px ), pn() // never throws
+ {
+ pn.swap( r.pn );
+ r.px = 0;
+ }
+
#endif
+ // conversion
+
+ template<class Y>
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+
+ shared_array( shared_array<Y> const & r, typename boost::detail::sp_enable_if_convertible< Y[], T[] >::type = boost::detail::sp_empty() )
+
+#else
+
+ shared_array( shared_array<Y> const & r )
+
+#endif
+ : px( r.px ), pn( r.pn ) // never throws
+ {
+ boost::detail::sp_assert_convertible< Y[], T[] >();
+ }
+
+ // aliasing
+
+ template< class Y >
+ shared_array( shared_array<Y> const & r, element_type * p ): px( p ), pn( r.pn ) // never throws
+ {
+ }
+
// assignment
shared_array & operator=( shared_array const & r ) // never throws
@@ -89,15 +134,58 @@
return *this;
}
- void reset(T * p = 0)
+#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
+
+ template<class Y>
+ shared_array & operator=( shared_array<Y> const & r ) // never throws
+ {
+ this_type( r ).swap( *this );
+ return *this;
+ }
+
+#endif
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+ shared_array & operator=( shared_array && r ) // never throws
+ {
+ this_type( static_cast< shared_array && >( r ) ).swap( *this );
+ return *this;
+ }
+
+ template<class Y>
+ shared_array & operator=( shared_array<Y> && r ) // never throws
{
- BOOST_ASSERT(p == 0 || p != px);
- this_type(p).swap(*this);
+ this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this );
+ return *this;
}
- template <class D> void reset(T * p, D d)
+#endif
+
+ void reset() // never throws
{
- this_type(p, d).swap(*this);
+ this_type().swap( *this );
+ }
+
+ template<class Y> void reset( Y * p ) // Y must be complete
+ {
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+ this_type( p ).swap( *this );
+ }
+
+ template<class Y, class D> void reset( Y * p, D d )
+ {
+ this_type( p, d ).swap( *this );
+ }
+
+ template<class Y, class D, class A> void reset( Y * p, D d, A a )
+ {
+ this_type( p, d, a ).swap( *this );
+ }
+
+ template<class Y> void reset( shared_array<Y> const & r, element_type * p )
+ {
+ this_type( r, p ).swap( *this );
}
T & operator[] (std::ptrdiff_t i) const // never throws
@@ -138,6 +226,8 @@
private:
+ template<class Y> friend class shared_array;
+
T * px; // contained pointer
detail::shared_count pn; // reference counter
Modified: branches/release/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- branches/release/boost/smart_ptr/shared_ptr.hpp (original)
+++ branches/release/boost/smart_ptr/shared_ptr.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -67,34 +67,129 @@
struct dynamic_cast_tag {};
struct polymorphic_cast_tag {};
-template<class T> struct shared_ptr_traits
+// sp_element, element_type
+
+template< class T > struct sp_element
+{
+ typedef T type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_element< T[] >
+{
+ typedef T type;
+};
+
+template< class T, std::size_t N > struct sp_element< T[N] >
{
- typedef T & reference;
+ typedef T type;
};
-template<> struct shared_ptr_traits<void>
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_dereference, return type of operator*
+
+template< class T > struct sp_dereference
{
- typedef void reference;
+ typedef T & type;
+};
+
+template<> struct sp_dereference< void >
+{
+ typedef void type;
};
#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
-template<> struct shared_ptr_traits<void const>
+template<> struct sp_dereference< void const >
{
- typedef void reference;
+ typedef void type;
};
-template<> struct shared_ptr_traits<void volatile>
+template<> struct sp_dereference< void volatile >
{
- typedef void reference;
+ typedef void type;
};
-template<> struct shared_ptr_traits<void const volatile>
+template<> struct sp_dereference< void const volatile >
{
- typedef void reference;
+ typedef void type;
};
-#endif
+#endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_dereference< T[] >
+{
+ typedef void type;
+};
+
+template< class T, std::size_t N > struct sp_dereference< T[N] >
+{
+ typedef void type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_member_access, return type of operator->
+
+template< class T > struct sp_member_access
+{
+ typedef T * type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_member_access< T[] >
+{
+ typedef void type;
+};
+
+template< class T, std::size_t N > struct sp_member_access< T[N] >
+{
+ typedef void type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_array_access, return type of operator[]
+
+template< class T > struct sp_array_access
+{
+ typedef void type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_array_access< T[] >
+{
+ typedef T & type;
+};
+
+template< class T, std::size_t N > struct sp_array_access< T[N] >
+{
+ typedef T & type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_extent, for operator[] index check
+
+template< class T > struct sp_extent
+{
+ enum _vt { value = 0 };
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T, std::size_t N > struct sp_extent< T[N] >
+{
+ enum _vt { value = N };
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
// enable_shared_from_this support
@@ -144,6 +239,69 @@
#endif
+// sp_assert_convertible
+
+template< class Y, class T > inline void sp_assert_convertible()
+{
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+
+ // static_assert( sp_convertible< Y, T >::value );
+ typedef char tmp[ sp_convertible< Y, T >::value? 1: -1 ];
+ (void)sizeof( tmp );
+
+#else
+
+ T* p = static_cast< Y* >( 0 );
+ (void)p;
+
+#endif
+}
+
+// pointer constructor helper
+
+template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T > * ppx, Y * p, boost::detail::shared_count & pn )
+{
+ boost::detail::shared_count( p ).swap( pn );
+ boost::detail::sp_enable_shared_from_this( ppx, p, p );
+}
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * p, boost::detail::shared_count & pn )
+{
+ sp_assert_convertible< Y[], T[] >();
+ boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn );
+}
+
+template< class T, std::size_t N, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * p, boost::detail::shared_count & pn )
+{
+ sp_assert_convertible< Y[N], T[N] >();
+ boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn );
+}
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// deleter constructor helper
+
+template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T > * ppx, Y * p )
+{
+ boost::detail::sp_enable_shared_from_this( ppx, p, p );
+}
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ )
+{
+ sp_assert_convertible< Y[], T[] >();
+}
+
+template< class T, std::size_t N, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * /*p*/ )
+{
+ sp_assert_convertible< Y[N], T[N] >();
+}
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
} // namespace detail
@@ -164,19 +322,16 @@
public:
- typedef T element_type;
- typedef T value_type;
- typedef T * pointer;
- typedef typename boost::detail::shared_ptr_traits<T>::reference reference;
+ typedef typename boost::detail::sp_element< T >::type element_type;
- shared_ptr(): px(0), pn() // never throws in 1.30+
+ shared_ptr(): px( 0 ), pn() // never throws in 1.30+
{
}
template<class Y>
- explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete
+ explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete
{
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_pointer_construct( this, p, pn );
}
//
@@ -185,16 +340,16 @@
// shared_ptr will release p by calling d(p)
//
- template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d)
+ template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d )
{
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_deleter_construct( this, p );
}
// As above, but with allocator. A's copy constructor shall not throw.
template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
{
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_deleter_construct( this, p );
}
// generated copy constructor, destructor are fine...
@@ -210,8 +365,10 @@
#endif
template<class Y>
- explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw
+ explicit shared_ptr( weak_ptr<Y> const & r ): pn( r.pn ) // may throw
{
+ boost::detail::sp_assert_convertible< Y, T >();
+
// it is now safe to copy r.px, as pn(r.pn) did not throw
px = r.px;
}
@@ -237,11 +394,12 @@
#endif
: px( r.px ), pn( r.pn ) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
}
// aliasing
template< class Y >
- shared_ptr( shared_ptr<Y> const & r, T * p ): px( p ), pn( r.pn ) // never throws
+ shared_ptr( shared_ptr<Y> const & r, element_type * p ): px( p ), pn( r.pn ) // never throws
{
}
@@ -278,9 +436,12 @@
template<class Y>
explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn()
{
+ boost::detail::sp_assert_convertible< Y, T >();
+
Y * tmp = r.get();
pn = boost::detail::shared_count(r);
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
+
+ boost::detail::sp_deleter_construct( this, tmp );
}
#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
@@ -288,11 +449,15 @@
template<class Ap>
explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn()
{
- typename Ap::element_type * tmp = r.get();
+ typedef typename Ap::element_type Y;
+
+ boost::detail::sp_assert_convertible< Y, T >();
+
+ Y * tmp = r.get();
pn = boost::detail::shared_count( r );
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
- }
+ boost::detail::sp_deleter_construct( this, tmp );
+ }
#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
@@ -301,11 +466,14 @@
#if !defined( BOOST_NO_CXX11_SMART_PTR )
template< class Y, class D >
- shared_ptr( std::unique_ptr< Y, D > && r): px( r.get() ), pn()
+ shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn()
{
- Y * tmp = r.get();
+ boost::detail::sp_assert_convertible< Y, T >();
+
+ typename std::unique_ptr< Y, D >::pointer tmp = r.get();
pn = boost::detail::shared_count( r );
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
+
+ boost::detail::sp_deleter_construct( this, tmp );
}
#endif
@@ -347,7 +515,6 @@
return *this;
}
-
#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif // BOOST_NO_AUTO_PTR
@@ -374,6 +541,8 @@
#endif
: px( r.px ), pn() // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
+
pn.swap( r.pn );
r.px = 0;
}
@@ -398,10 +567,10 @@
this_type().swap(*this);
}
- template<class Y> void reset(Y * p) // Y must be complete
+ template<class Y> void reset( Y * p ) // Y must be complete
{
- BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors
- this_type(p).swap(*this);
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+ this_type( p ).swap( *this );
}
template<class Y, class D> void reset( Y * p, D d )
@@ -414,24 +583,32 @@
this_type( p, d, a ).swap( *this );
}
- template<class Y> void reset( shared_ptr<Y> const & r, T * p )
+ template<class Y> void reset( shared_ptr<Y> const & r, element_type * p )
{
this_type( r, p ).swap( *this );
}
- reference operator* () const // never throws
+ typename boost::detail::sp_dereference< T >::type operator* () const // never throws
{
- BOOST_ASSERT(px != 0);
+ BOOST_ASSERT( px != 0 );
return *px;
}
- T * operator-> () const // never throws
+ typename boost::detail::sp_member_access< T >::type operator-> () const // never throws
{
- BOOST_ASSERT(px != 0);
+ BOOST_ASSERT( px != 0 );
return px;
}
- T * get() const // never throws
+ typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const // never throws
+ {
+ BOOST_ASSERT( px != 0 );
+ BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
+
+ return px[ i ];
+ }
+
+ element_type * get() const // never throws
{
return px;
}
@@ -449,7 +626,7 @@
return pn.use_count();
}
- void swap(shared_ptr<T> & other) // never throws
+ void swap( shared_ptr & other ) // never throws
{
std::swap(px, other.px);
pn.swap(other.pn);
@@ -488,7 +665,7 @@
#endif
- T * px; // contained pointer
+ element_type * px; // contained pointer
boost::detail::shared_count pn; // reference counter
}; // shared_ptr
Modified: branches/release/boost/smart_ptr/weak_ptr.hpp
==============================================================================
--- branches/release/boost/smart_ptr/weak_ptr.hpp (original)
+++ branches/release/boost/smart_ptr/weak_ptr.hpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -29,7 +29,7 @@
public:
- typedef T element_type;
+ typedef typename boost::detail::sp_element< T >::type element_type;
weak_ptr(): px(0), pn() // never throws in 1.30+
{
@@ -83,6 +83,7 @@
#endif
: px(r.lock().get()), pn(r.pn) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
}
#if defined( BOOST_HAS_RVALUE_REFS )
@@ -99,6 +100,7 @@
#endif
: px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
r.px = 0;
}
@@ -130,15 +132,19 @@
#endif
: px( r.px ), pn( r.pn ) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
}
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
template<class Y>
- weak_ptr & operator=(weak_ptr<Y> const & r) // never throws
+ weak_ptr & operator=( weak_ptr<Y> const & r ) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
+
px = r.lock().get();
pn = r.pn;
+
return *this;
}
@@ -154,10 +160,13 @@
#endif
template<class Y>
- weak_ptr & operator=(shared_ptr<Y> const & r) // never throws
+ weak_ptr & operator=( shared_ptr<Y> const & r ) // never throws
{
+ boost::detail::sp_assert_convertible< Y, T >();
+
px = r.px;
pn = r.pn;
+
return *this;
}
@@ -165,7 +174,7 @@
shared_ptr<T> lock() const // never throws
{
- return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() );
+ return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() );
}
long use_count() const // never throws
@@ -195,7 +204,7 @@
}
template<typename Y>
- void _internal_aliasing_assign(weak_ptr<Y> const & r, T * px2)
+ void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2)
{
px = px2;
pn = r.pn;
@@ -223,7 +232,7 @@
#endif
- T * px; // contained pointer
+ element_type * px; // contained pointer
boost::detail::weak_count pn; // reference counter
}; // weak_ptr
Copied: branches/release/libs/smart_ptr/make_shared_array.html (from r81220, /trunk/libs/smart_ptr/make_shared_array.html)
==============================================================================
--- /trunk/libs/smart_ptr/make_shared_array.html (original)
+++ branches/release/libs/smart_ptr/make_shared_array.html 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -28,21 +28,50 @@
<h2><a name="Synopsis">Synopsis</a></h2>
<pre>namespace boost {
template<typename T>
- shared_ptr<T> make_shared(size_t size);
+ shared_ptr<T[]> make_shared(size_t size);
template<typename T, typename A>
- shared_ptr<T> allocate_shared(const A& allocator, size_t size);
+ 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);
+ shared_ptr<T[]> make_shared(size_t size, Args&&... args);
+
+ template<typename T, typename... Args>
+ shared_ptr<T[N]> make_shared(Args&&... args);
template<typename T, typename A, typename... Args>
shared_ptr<T> allocate_shared(const A& allocator, size_t size, Args&&... args);
+
+ 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... Args>
+ shared_ptr<T[N]> 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, 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
template<typename T>
shared_ptr<T> make_shared_noinit(size_t size);
+
+ template<typename T>
+ shared_ptr<T[N]> make_shared_noinit();
}</pre>
<h2><a name="functions">Free Functions</a></h2>
<pre>template<typename T, typename... Args>
@@ -51,7 +80,7 @@
shared_ptr<T> allocate_shared(const A& allocator, size_t size, Args&&... args);</pre>
<blockquote>
<p><b>Requires:</b> The expression
- <code>new(pointer) T(std::forward<Args>(args)...)</code>, where
+ <code>new(pointer) T(forward<Args>(args)...)</code>, where
<code>pointer</code> is a <code>void*</code> pointing to storage
suitable to hold an object of type <code>T</code>, shall be
well-formed. <code>A</code> shall be an <em>Allocator</em>, as
@@ -62,7 +91,7 @@
<code>T</code> and size <code>size</code> and constructs an array
of objects in it via the placement new expression
<code>new(pointer) T()</code> or
- <code>new(pointer) T(std::forward<Args>(args)...)</code>.
+ <code>new(pointer) T(forward<Args>(args)...)</code>.
<code>allocate_shared</code> uses a copy of
<code>allocator</code> to allocate memory. If an exception is thrown,
has no effect.</p>
Modified: branches/release/libs/smart_ptr/test/Jamfile.v2
==============================================================================
--- branches/release/libs/smart_ptr/test/Jamfile.v2 (original)
+++ branches/release/libs/smart_ptr/test/Jamfile.v2 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -46,7 +46,7 @@
[ run spinlock_pool_test.cpp ]
[ run make_shared_test.cpp ]
[ run make_shared_perfect_forwarding_test.cpp ]
- [ run sp_convertible_test.cpp ]
+ [ run shared_ptr_convertible_test.cpp ]
[ run wp_convertible_test.cpp ]
[ run ip_convertible_test.cpp ]
[ run allocate_shared_test.cpp ]
@@ -70,5 +70,82 @@
[ run ip_hash_test.cpp ]
[ run owner_less_test.cpp ]
[ run sp_unique_ptr_test.cpp ]
+ [ run sp_array_test.cpp ]
+ [ compile sp_array_cv_test.cpp ]
+ [ run sp_convertible_test.cpp ]
+ [ run sp_array_n_test.cpp ]
+
+ [ compile-fail array_fail_spa_sp_c.cpp ]
+ [ compile-fail array_fail_sp_spa_c.cpp ]
+ [ compile-fail array_fail_spa_spa_c.cpp ]
+ [ compile-fail array_fail_spa_wp_c.cpp ]
+ [ compile-fail array_fail_sp_wpa_c.cpp ]
+ [ compile-fail array_fail_spa_wpa_c.cpp ]
+ [ compile-fail array_fail_wpa_wp_c.cpp ]
+ [ compile-fail array_fail_wp_wpa_c.cpp ]
+ [ compile-fail array_fail_wpa_wpa_c.cpp ]
+ [ compile-fail array_fail_ap_spa_c.cpp ]
+ [ compile-fail array_fail_upa_sp_c.cpp ]
+ [ compile-fail array_fail_up_spa_c.cpp ]
+
+ [ compile-fail array_fail_spa_sp_mc.cpp ]
+ [ compile-fail array_fail_sp_spa_mc.cpp ]
+ [ compile-fail array_fail_spa_spa_mc.cpp ]
+ [ compile-fail array_fail_spa_wp_mc.cpp ]
+ [ compile-fail array_fail_sp_wpa_mc.cpp ]
+ [ compile-fail array_fail_spa_wpa_mc.cpp ]
+ [ compile-fail array_fail_wpa_wp_mc.cpp ]
+ [ compile-fail array_fail_wp_wpa_mc.cpp ]
+ [ compile-fail array_fail_wpa_wpa_mc.cpp ]
+ [ compile-fail array_fail_ap_spa_mc.cpp ]
+ [ compile-fail array_fail_upa_sp_mc.cpp ]
+ [ compile-fail array_fail_up_spa_mc.cpp ]
+
+ [ compile-fail array_fail_spa_sp_a.cpp ]
+ [ compile-fail array_fail_sp_spa_a.cpp ]
+ [ compile-fail array_fail_spa_spa_a.cpp ]
+ [ compile-fail array_fail_spa_wp_a.cpp ]
+ [ compile-fail array_fail_sp_wpa_a.cpp ]
+ [ compile-fail array_fail_spa_wpa_a.cpp ]
+ [ compile-fail array_fail_wpa_wp_a.cpp ]
+ [ compile-fail array_fail_wp_wpa_a.cpp ]
+ [ compile-fail array_fail_wpa_wpa_a.cpp ]
+ [ compile-fail array_fail_ap_spa_a.cpp ]
+ [ compile-fail array_fail_upa_sp_a.cpp ]
+ [ compile-fail array_fail_up_spa_a.cpp ]
+
+ [ compile-fail array_fail_spa_sp_ma.cpp ]
+ [ compile-fail array_fail_sp_spa_ma.cpp ]
+ [ compile-fail array_fail_spa_spa_ma.cpp ]
+ [ compile-fail array_fail_spa_wp_ma.cpp ]
+ [ compile-fail array_fail_sp_wpa_ma.cpp ]
+ [ compile-fail array_fail_spa_wpa_ma.cpp ]
+ [ compile-fail array_fail_wpa_wp_ma.cpp ]
+ [ compile-fail array_fail_wp_wpa_ma.cpp ]
+ [ compile-fail array_fail_wpa_wpa_ma.cpp ]
+ [ compile-fail array_fail_ap_spa_ma.cpp ]
+ [ compile-fail array_fail_upa_sp_ma.cpp ]
+ [ compile-fail array_fail_up_spa_ma.cpp ]
+
+ [ compile-fail array_fail_dereference.cpp ]
+ [ compile-fail array_fail_member_access.cpp ]
+ [ compile-fail array_fail_array_access.cpp ]
+
+ [ run make_shared_array_test.cpp ]
+ [ run make_shared_arrays_test.cpp ]
+ [ run make_shared_array_create_test.cpp ]
+ [ run make_shared_array_init_test.cpp ]
+ [ run make_shared_arrays_create_test.cpp ]
+ [ run make_shared_array_throws_test.cpp ]
+ [ run make_shared_array_esft_test.cpp ]
+ [ run make_shared_array_args_test.cpp ]
+ [ run allocate_shared_array_test.cpp ]
+ [ run allocate_shared_arrays_test.cpp ]
+ [ run allocate_shared_array_create_test.cpp ]
+ [ run allocate_shared_array_init_test.cpp ]
+ [ run allocate_shared_arrays_create_test.cpp ]
+ [ run allocate_shared_array_throws_test.cpp ]
+ [ run allocate_shared_array_esft_test.cpp ]
+ [ run allocate_shared_array_args_test.cpp ]
;
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_array_create_test.cpp (from r81242, /trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_create_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -48,6 +48,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2]> a1 = boost::allocate_shared<type[2]>(std::allocator<type>(), 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ BOOST_TEST(type::instances == 2);
+ BOOST_TEST(a1[0].a == 1);
+ BOOST_TEST(a1[0].d == 4);
+ BOOST_TEST(a1[1].f == 6);
+ BOOST_TEST(a1[1].i == 9);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(std::allocator<type>(), 2, 1, 2, 3, 4, 5, 6, 7);
BOOST_TEST(type::instances == 4);
BOOST_TEST(a1[0][0].a == 1);
@@ -57,6 +66,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(std::allocator<type>(), 1, 2, 3, 4, 5, 6, 7);
+ BOOST_TEST(type::instances == 4);
+ BOOST_TEST(a1[0][0].a == 1);
+ BOOST_TEST(a1[0][1].d == 4);
+ BOOST_TEST(a1[1][0].f == 6);
+ BOOST_TEST(a1[1][1].i == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2][2]> a1 = boost::allocate_shared<type[][2][2]>(std::allocator<type>(), 2, 1, 2, 3, 4, 5);
BOOST_TEST(type::instances == 8);
BOOST_TEST(a1[0][0][0].a == 1);
@@ -66,6 +84,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2][2][2]> a1 = boost::allocate_shared<type[2][2][2]>(std::allocator<type>(), 1, 2, 3, 4, 5);
+ BOOST_TEST(type::instances == 8);
+ BOOST_TEST(a1[0][0][0].a == 1);
+ BOOST_TEST(a1[0][1][0].c == 3);
+ BOOST_TEST(a1[1][0][1].e == 5);
+ BOOST_TEST(a1[1][1][1].i == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2][2][2]> a1 = boost::allocate_shared<type[][2][2][2]>(std::allocator<type>(), 2, 1, 2, 3);
BOOST_TEST(type::instances == 16);
BOOST_TEST(a1[0][0][0][1].a == 1);
@@ -73,6 +100,15 @@
BOOST_TEST(a1[0][1][0][0].f == 0);
BOOST_TEST(a1[1][0][0][0].i == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2][2]> a1 = boost::allocate_shared<type[2][2][2][2]>(std::allocator<type>(), 1, 2, 3);
+ BOOST_TEST(type::instances == 16);
+ BOOST_TEST(a1[0][0][0][1].a == 1);
+ BOOST_TEST(a1[0][0][1][0].c == 3);
+ BOOST_TEST(a1[0][1][0][0].f == 0);
+ BOOST_TEST(a1[1][0][0][0].i == 0);
+ }
#endif
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp (from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -34,7 +34,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp (from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -70,15 +70,53 @@
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);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
{
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), 3, 1, 5);
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<type[3]>(std::allocator<type>(), 1, 5);
+ 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<const type[]>(std::allocator<type>(), 3, 1, 5);
+ 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<const type[3]>(std::allocator<type>(), 1, 5);
+ 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);
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp (from r81220, /trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -36,5 +36,12 @@
} catch (...) {
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::allocate_shared<type[][2]>(std::allocator<type>(), 3);
+ BOOST_ERROR("allocate_shared did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp (from r81262, /trunk/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_arrays_create_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -18,6 +18,27 @@
BOOST_TEST(a1[1][0] == 2);
BOOST_TEST(a1[1][1] == 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);
+ BOOST_TEST(a1[0][1] == 1);
+ BOOST_TEST(a1[1][0] == 2);
+ BOOST_TEST(a1[1][1] == 3);
+ }
+ {
+ 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);
+ BOOST_TEST(a1[1][0] == 0);
+ BOOST_TEST(a1[1][1] == 1);
+ }
+ {
+ boost::shared_ptr<int[][2][2]> a1 = boost::allocate_shared<int[][2][2]>(std::allocator<int>(), 2, { {0, 1}, {2, 3} });
+ BOOST_TEST(a1[0][0][0] == 0);
+ BOOST_TEST(a1[0][0][1] == 1);
+ BOOST_TEST(a1[1][1][0] == 2);
+ BOOST_TEST(a1[1][1][1] == 3);
+ }
#endif
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp (from r81239, /trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/allocate_shared_arrays_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -59,6 +59,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
@@ -70,6 +72,33 @@
a1.reset();
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2]> a1 = boost::allocate_shared<type[2][2][2]>(std::allocator<type>(), 1, 5);
+ 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<const type[][2][2]>(std::allocator<type>(), 2, 1, 5);
+ 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<const type[2][2][2]>(std::allocator<type>(), 1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
#endif
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/make_shared_array_create_test.cpp (from r81242, /trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_array_create_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -48,6 +48,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2]> a1 = boost::make_shared<type[2]>(1, 2, 3, 4, 5, 6, 7, 8, 9);
+ BOOST_TEST(type::instances == 2);
+ BOOST_TEST(a1[0].a == 1);
+ BOOST_TEST(a1[0].d == 4);
+ BOOST_TEST(a1[1].f == 6);
+ BOOST_TEST(a1[1].i == 9);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2]> a1 = boost::make_shared<type[][2]>(2, 1, 2, 3, 4, 5, 6, 7);
BOOST_TEST(type::instances == 4);
BOOST_TEST(a1[0][0].a == 1);
@@ -57,6 +66,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2][2]> a1 = boost::make_shared<type[2][2]>(1, 2, 3, 4, 5, 6, 7);
+ BOOST_TEST(type::instances == 4);
+ BOOST_TEST(a1[0][0].a == 1);
+ BOOST_TEST(a1[0][1].d == 4);
+ BOOST_TEST(a1[1][0].f == 6);
+ BOOST_TEST(a1[1][1].i == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2][2]> a1 = boost::make_shared<type[][2][2]>(2, 1, 2, 3, 4, 5);
BOOST_TEST(type::instances == 8);
BOOST_TEST(a1[0][0][0].a == 1);
@@ -66,6 +84,15 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2][2][2]> a1 = boost::make_shared<type[2][2][2]>(1, 2, 3, 4, 5);
+ BOOST_TEST(type::instances == 8);
+ BOOST_TEST(a1[0][0][0].a == 1);
+ BOOST_TEST(a1[0][1][0].c == 3);
+ BOOST_TEST(a1[1][0][1].e == 5);
+ BOOST_TEST(a1[1][1][1].i == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<type[][2][2][2]> a1 = boost::make_shared<type[][2][2][2]>(2, 1, 2, 3);
BOOST_TEST(type::instances == 16);
BOOST_TEST(a1[0][0][0][1].a == 1);
@@ -73,6 +100,15 @@
BOOST_TEST(a1[0][1][0][0].f == 0);
BOOST_TEST(a1[1][0][0][0].i == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2][2]> a1 = boost::make_shared<type[2][2][2][2]>(1, 2, 3);
+ BOOST_TEST(type::instances == 16);
+ BOOST_TEST(a1[0][0][0][1].a == 1);
+ BOOST_TEST(a1[0][0][1][0].c == 3);
+ BOOST_TEST(a1[0][1][0][0].f == 0);
+ BOOST_TEST(a1[1][0][0][0].i == 0);
+ }
#endif
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/make_shared_array_esft_test.cpp (from r81220, /trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_array_esft_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -34,7 +34,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
@@ -44,7 +44,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
Copied: branches/release/libs/smart_ptr/test/make_shared_array_test.cpp (from r81220, /trunk/libs/smart_ptr/test/make_shared_array_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_array_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_array_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -70,15 +70,53 @@
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);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
{
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3, 1, 5);
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::make_shared<type[3]>(1, 5);
+ 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(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::make_shared<const type[]>(3, 1, 5);
+ 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::make_shared<const type[3]>(1, 5);
+ 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);
}
@@ -86,12 +124,28 @@
{
boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<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_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
+ }
+ {
+ boost::shared_ptr<int[3]> a1 = boost::make_shared_noinit<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<const int[]> a1 = boost::make_shared_noinit<const 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::make_shared_noinit<const 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);
}
@@ -99,6 +153,7 @@
{
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<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);
@@ -108,11 +163,37 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[3]> a1 = boost::make_shared_noinit<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[3]> w1 = a1;
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
boost::shared_ptr<const type[]> a1 = boost::make_shared_noinit<const 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::make_shared_noinit<const 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);
}
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/make_shared_array_throws_test.cpp (from r81220, /trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_array_throws_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -38,7 +38,21 @@
}
BOOST_TEST(type::instances == 0);
try {
- boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(6);
+ boost::make_shared<type[][2]>(3);
+ BOOST_ERROR("make_shared did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::make_shared_noinit<type[]>(6);
+ BOOST_ERROR("make_shared_noinit did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::make_shared_noinit<type[][2]>(3);
BOOST_ERROR("make_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
Copied: branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp (from r81262, /trunk/libs/smart_ptr/test/make_shared_arrays_create_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_arrays_create_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_arrays_create_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -8,6 +8,7 @@
*/
#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)
@@ -18,6 +19,27 @@
BOOST_TEST(a1[1][0] == 2);
BOOST_TEST(a1[1][1] == 3);
}
+ {
+ boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][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);
+ }
+ {
+ 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);
+ BOOST_TEST(a1[1][0] == 0);
+ BOOST_TEST(a1[1][1] == 1);
+ }
+ {
+ boost::shared_ptr<int[][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_TEST(a1[1][1][0] == 2);
+ BOOST_TEST(a1[1][1][1] == 3);
+ }
#endif
return boost::report_errors();
}
Copied: branches/release/libs/smart_ptr/test/make_shared_arrays_test.cpp (from r81239, /trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/make_shared_arrays_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -59,6 +59,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
@@ -70,16 +72,53 @@
a1.reset();
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2]> a1 = boost::make_shared<type[2][2][2]>(1, 5);
+ 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::make_shared<const type[][2][2]>(2, 1, 5);
+ 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::make_shared<const type[2][2][2]>(1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
#endif
{
boost::shared_ptr<int[][2][2]> a1 = boost::make_shared_noinit<int[][2][2]>(2);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
+ }
+ {
+ boost::shared_ptr<int[2][2][2]> a1 = boost::make_shared_noinit<int[2][2][2]>();
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
}
{
boost::shared_ptr<const int[][2][2]> a1 = boost::make_shared_noinit<const int[][2][2]>(2);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
+ }
+ {
+ boost::shared_ptr<const int[2][2][2]> a1 = boost::make_shared_noinit<const int[2][2][2]>();
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
}
BOOST_TEST(type::instances == 0);
{
@@ -92,10 +131,30 @@
}
BOOST_TEST(type::instances == 0);
{
+ boost::shared_ptr<type[2][2][2]> a1 = boost::make_shared_noinit<type[2][2][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]> a1 = boost::make_shared_noinit<const type[][2][2]>(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::make_shared_noinit<const type[2][2][2]>();
+ 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();
}
Modified: branches/release/libs/smart_ptr/test/smart_ptr_test.cpp
==============================================================================
--- branches/release/libs/smart_ptr/test/smart_ptr_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/smart_ptr_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -236,7 +236,7 @@
ca2.reset();
BOOST_TEST( ca.use_count() == 2 );
BOOST_TEST( ca3.use_count() == 2 );
- BOOST_TEST( ca2.use_count() == 1 );
+ BOOST_TEST( ca2.use_count() == 0 );
ca.reset();
BOOST_TEST( ca.get() == 0 );
@@ -269,7 +269,7 @@
udta2.reset();
BOOST_TEST( udta2.get() == 0 );
BOOST_TEST( udta.use_count() == 1 );
- BOOST_TEST( udta2.use_count() == 1 );
+ BOOST_TEST( udta2.use_count() == 0 );
BOOST_TEST( UDT_use_count == 4 ); // reality check
Copied: branches/release/libs/smart_ptr/test/sp_array_cv_test.cpp (from r81159, /trunk/libs/smart_ptr/test/sp_array_cv_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/sp_array_cv_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/sp_array_cv_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -14,29 +14,47 @@
{
};
-int main()
+class B
{
- boost::shared_ptr< X[] > px;
+};
- boost::shared_ptr< X const[] > pcx( px );
- boost::shared_ptr< X volatile[] > pvx( px );
+class D: public B
+{
+};
- boost::shared_ptr< X const volatile[] > pcvx( px );
- boost::shared_ptr< X const volatile[] > pcvx2( pcx );
- boost::shared_ptr< X const volatile[] > pcvx3( pvx );
+#define TEST_CONV( T, U ) \
+ { \
+ boost::shared_ptr< T > p1; \
+ boost::shared_ptr< U > p2( p1 ); \
+ p2 = p1; \
+ boost::shared_ptr< U > p3 = boost::shared_ptr< T >(); \
+ p3 = boost::shared_ptr< T >(); \
+ }
+
+#define TEST_CV_TRUE( T, U ) \
+ TEST_CONV( T, U ) \
+ TEST_CONV( T, const U ) \
+ TEST_CONV( T, volatile U ) \
+ TEST_CONV( T, const volatile U ) \
+ TEST_CONV( const T, const U ) \
+ TEST_CONV( const T, const volatile U ) \
+ TEST_CONV( volatile T, volatile U ) \
+ TEST_CONV( volatile T, const volatile U ) \
+ TEST_CONV( const volatile T, const volatile U )
- boost::shared_ptr< void > pv( px );
+int main()
+{
+ TEST_CV_TRUE( X, X )
+ TEST_CV_TRUE( X, void )
+ TEST_CV_TRUE( D, B )
- boost::shared_ptr< void const > pcv( px );
- boost::shared_ptr< void const > pcv2( pcx );
+ TEST_CV_TRUE( X[], X[] )
+ TEST_CV_TRUE( X[3], X[3] )
- boost::shared_ptr< void volatile > pvv( px );
- boost::shared_ptr< void volatile > pvv2( pvx );
+ TEST_CV_TRUE( X[3], X[] )
- boost::shared_ptr< void const volatile > pcvv( px );
- boost::shared_ptr< void const volatile > pcvv2( pcx );
- boost::shared_ptr< void const volatile > pcvv3( pvx );
- boost::shared_ptr< void const volatile > pcvv4( pcvx );
+ TEST_CV_TRUE( X[], void )
+ TEST_CV_TRUE( X[3], void )
return 0;
}
Copied: branches/release/libs/smart_ptr/test/sp_array_test.cpp (from r81149, /trunk/libs/smart_ptr/test/sp_array_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/sp_array_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/sp_array_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -95,6 +95,10 @@
catch( boost::bad_weak_ptr const& )
{
}
+ catch( ... )
+ {
+ BOOST_ERROR( "px2[0].shared_from_this() threw something else than bad_weak_ptr" );
+ }
BOOST_TEST( X::allocations == 1 );
BOOST_TEST( X::instances == 3 );
@@ -210,6 +214,10 @@
catch( boost::bad_weak_ptr const& )
{
}
+ catch( ... )
+ {
+ BOOST_ERROR( "px2[0].shared_from_this() threw something else than bad_weak_ptr" );
+ }
px2.reset();
@@ -236,6 +244,10 @@
catch( boost::bad_weak_ptr const& )
{
}
+ catch( ... )
+ {
+ BOOST_ERROR( "px2[0].shared_from_this() threw something else than bad_weak_ptr" );
+ }
px2.reset();
@@ -258,6 +270,10 @@
catch( boost::bad_weak_ptr const& )
{
}
+ catch( ... )
+ {
+ BOOST_ERROR( "px[0].shared_from_this() threw something else than bad_weak_ptr" );
+ }
px.reset();
@@ -279,6 +295,10 @@
catch( boost::bad_weak_ptr const& )
{
}
+ catch( ... )
+ {
+ BOOST_ERROR( "px[0].shared_from_this() threw something else than bad_weak_ptr" );
+ }
px.reset();
Copied: branches/release/libs/smart_ptr/test/sp_convertible_test.cpp (from r81239, /trunk/libs/smart_ptr/test/sp_convertible_test.cpp)
==============================================================================
--- /trunk/libs/smart_ptr/test/sp_convertible_test.cpp (original)
+++ branches/release/libs/smart_ptr/test/sp_convertible_test.cpp 2012-11-14 08:52:11 EST (Wed, 14 Nov 2012)
@@ -78,7 +78,7 @@
TEST_CV_FALSE( X[3], X[4] )
TEST_CV_FALSE( D[3], B[3] )
- //TEST_CV_TRUE( X[3], X[] )
+ TEST_CV_TRUE( X[3], X[] )
TEST_CV_FALSE( X[], X[3] )
TEST_CV_TRUE( X[], void )
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