forked from boostorg/smart_ptr
Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
[SVN r81275]
This commit is contained in:
@ -18,12 +18,12 @@
|
|||||||
namespace boost {
|
namespace boost {
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
inline typename detail::sp_if_array<T>::type
|
inline typename detail::sp_if_array<T>::type
|
||||||
allocate_shared(const A& allocator, size_t size) {
|
allocate_shared(const A& allocator, std::size_t size) {
|
||||||
typedef typename detail::array_inner<T>::type T1;
|
typedef typename detail::array_inner<T>::type T1;
|
||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = size * detail::array_total<T1>::size;
|
std::size_t n1 = size * detail::array_total<T1>::size;
|
||||||
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -36,12 +36,12 @@ namespace boost {
|
|||||||
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
|
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
|
||||||
template<typename T, typename A, typename... Args>
|
template<typename T, typename A, typename... Args>
|
||||||
inline typename detail::sp_if_array<T>::type
|
inline typename detail::sp_if_array<T>::type
|
||||||
allocate_shared(const A& allocator, size_t size, Args&&... args) {
|
allocate_shared(const A& allocator, std::size_t size, Args&&... args) {
|
||||||
typedef typename detail::array_inner<T>::type T1;
|
typedef typename detail::array_inner<T>::type T1;
|
||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = size * detail::array_total<T1>::size;
|
std::size_t n1 = size * detail::array_total<T1>::size;
|
||||||
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -58,7 +58,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = detail::array_total<T>::size;
|
std::size_t n1 = detail::array_total<T>::size;
|
||||||
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -79,7 +79,7 @@ namespace boost {
|
|||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = list.size() * detail::array_total<T1>::size;
|
std::size_t n1 = list.size() * detail::array_total<T1>::size;
|
||||||
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -87,7 +87,7 @@ namespace boost {
|
|||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
p3 = reinterpret_cast<T3*>(list.begin());
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
||||||
d2->construct(p2, n1, p3);
|
d2->construct_list(p2, n1, p3);
|
||||||
return shared_ptr<T>(s1, p1);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
@ -100,7 +100,7 @@ namespace boost {
|
|||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = detail::array_total<T>::size;
|
std::size_t n1 = detail::array_total<T>::size;
|
||||||
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
detail::allocate_array_helper<A, T2> a1(allocator, n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -108,7 +108,28 @@ namespace boost {
|
|||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
p3 = reinterpret_cast<T3*>(list.begin());
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
||||||
d2->construct(p2, n1, p3);
|
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, typename detail::inner_list<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 * 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<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);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#define BOOST_SMART_PTR_DETAIL_ALLOCATE_ARRAY_HELPER_HPP
|
#define BOOST_SMART_PTR_DETAIL_ALLOCATE_ARRAY_HELPER_HPP
|
||||||
|
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -39,12 +39,18 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
void construct(T* memory, std::size_t count, const T* list) {
|
void construct_list(T* memory, std::size_t count, const T* list) {
|
||||||
for (object = memory; size < count; size++) {
|
for (object = memory; size < count; size++) {
|
||||||
void* p1 = object + size;
|
void* p1 = object + size;
|
||||||
::new(p1) T(list[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
|
#endif
|
||||||
void construct_noinit(T* memory, std::size_t count) {
|
void construct_noinit(T* memory, std::size_t count) {
|
||||||
for (object = memory; size < count; size++) {
|
for (object = memory; size < count; size++) {
|
||||||
|
@ -68,6 +68,13 @@ namespace boost {
|
|||||||
struct array_list<T[N]> {
|
struct array_list<T[N]> {
|
||||||
typedef std::initializer_list<T> type;
|
typedef std::initializer_list<T> type;
|
||||||
};
|
};
|
||||||
|
template<typename T>
|
||||||
|
struct inner_list {
|
||||||
|
};
|
||||||
|
template<typename T, size_t N>
|
||||||
|
struct inner_list<T[][N]> {
|
||||||
|
typedef std::initializer_list<T> type;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#define BOOST_SMART_PTR_DETAIL_MAKE_ARRAY_HELPER_HPP
|
#define BOOST_SMART_PTR_DETAIL_MAKE_ARRAY_HELPER_HPP
|
||||||
|
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -23,7 +23,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = size * detail::array_total<T1>::size;
|
std::size_t n1 = size * detail::array_total<T1>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -41,7 +41,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = size * detail::array_total<T1>::size;
|
std::size_t n1 = size * detail::array_total<T1>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -58,7 +58,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = detail::array_total<T>::size;
|
std::size_t n1 = detail::array_total<T>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -79,7 +79,7 @@ namespace boost {
|
|||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = list.size() * detail::array_total<T1>::size;
|
std::size_t n1 = list.size() * detail::array_total<T1>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -87,7 +87,7 @@ namespace boost {
|
|||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
p3 = reinterpret_cast<T3*>(list.begin());
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
||||||
d2->construct(p2, n1, p3);
|
d2->construct_list(p2, n1, p3);
|
||||||
return shared_ptr<T>(s1, p1);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -100,7 +100,7 @@ namespace boost {
|
|||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = detail::array_total<T>::size;
|
std::size_t n1 = detail::array_total<T>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -108,7 +108,28 @@ namespace boost {
|
|||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
p3 = reinterpret_cast<T3*>(list.begin());
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
d2 = get_deleter<detail::array_deleter<T2> >(s1);
|
||||||
d2->construct(p2, n1, p3);
|
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, typename detail::inner_list<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);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -119,7 +140,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = size * detail::array_total<T1>::size;
|
std::size_t n1 = size * detail::array_total<T1>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
@ -136,7 +157,7 @@ namespace boost {
|
|||||||
typedef typename detail::array_base<T1>::type T2;
|
typedef typename detail::array_base<T1>::type T2;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
size_t n1 = detail::array_total<T>::size;
|
std::size_t n1 = detail::array_total<T>::size;
|
||||||
detail::make_array_helper<T2> a1(n1, &p2);
|
detail::make_array_helper<T2> a1(n1, &p2);
|
||||||
detail::array_deleter<T2> d1;
|
detail::array_deleter<T2> d1;
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
|
@ -49,16 +49,22 @@
|
|||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
shared_ptr<T[]> <a href="#functions">make_shared</a>(std::initializer_list<T> list);
|
shared_ptr<T[]> <a href="#functions">make_shared</a>(initializer_list<T> list);
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
shared_ptr<T[N]> <a href="#functions">make_shared</a>(std::initializer_list<T> list);
|
shared_ptr<T[N]> <a href="#functions">make_shared</a>(initializer_list<T> list);
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
shared_ptr<T[][N]> <a href="#functions">make_shared</a>(size_t size, initializer_list<T> list);
|
||||||
|
|
||||||
template<typename T, typename A, typename... Args>
|
template<typename T, typename A, typename... Args>
|
||||||
shared_ptr<T[]> <a href="#functions">allocate_shared</a>(const A& allocator, std::initializer_list<T> list);
|
shared_ptr<T[]> <a href="#functions">allocate_shared</a>(const A& allocator, initializer_list<T> list);
|
||||||
|
|
||||||
template<typename T, typename A, typename... Args>
|
template<typename T, typename A, typename... Args>
|
||||||
shared_ptr<T[N]> <a href="#functions">allocate_shared</a>(const A& allocator, std::initializer_list<T> list);
|
shared_ptr<T[N]> <a href="#functions">allocate_shared</a>(const A& allocator, initializer_list<T> list);
|
||||||
|
|
||||||
|
template<typename T, typename A, typename... Args>
|
||||||
|
shared_ptr<T[][N]> <a href="#functions">allocate_shared</a>(const A& allocator, size_t size, initializer_list<T> list);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -74,7 +80,7 @@ template<typename T, typename A, typename... Args>
|
|||||||
shared_ptr<T> allocate_shared(const A& allocator, size_t size, Args&&... args);</pre>
|
shared_ptr<T> allocate_shared(const A& allocator, size_t size, Args&&... args);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Requires:</b> The expression
|
<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
|
<code>pointer</code> is a <code>void*</code> pointing to storage
|
||||||
suitable to hold an object of type <code>T</code>, shall be
|
suitable to hold an object of type <code>T</code>, shall be
|
||||||
well-formed. <code>A</code> shall be an <em>Allocator</em>, as
|
well-formed. <code>A</code> shall be an <em>Allocator</em>, as
|
||||||
@ -85,7 +91,7 @@ template<typename T, typename A, typename... Args>
|
|||||||
<code>T</code> and size <code>size</code> and constructs an array
|
<code>T</code> and size <code>size</code> and constructs an array
|
||||||
of objects in it via the placement new expression
|
of objects in it via the placement new expression
|
||||||
<code>new(pointer) T()</code> or
|
<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>allocate_shared</code> uses a copy of
|
||||||
<code>allocator</code> to allocate memory. If an exception is thrown,
|
<code>allocator</code> to allocate memory. If an exception is thrown,
|
||||||
has no effect.</p>
|
has no effect.</p>
|
||||||
|
@ -25,6 +25,20 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 2);
|
BOOST_TEST(a1[1][0] == 2);
|
||||||
BOOST_TEST(a1[1][1] == 3);
|
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
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared_array.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
@ -25,6 +26,20 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 2);
|
BOOST_TEST(a1[1][0] == 2);
|
||||||
BOOST_TEST(a1[1][1] == 3);
|
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
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user