forked from boostorg/smart_ptr
Change make_shared and allocate_shared array form overload for size and inner array initialization list to use const T(&)[N] instead of std::initializer_list<T>.
[SVN r81658]
This commit is contained in:
@@ -97,30 +97,6 @@ namespace boost {
|
|||||||
d2->construct_list(p2, n1, p3);
|
d2->construct_list(p2, n1, p3);
|
||||||
return boost::shared_ptr<T>(s1, p1);
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T, typename A>
|
|
||||||
inline typename boost::detail::sp_if_array<T>::type
|
|
||||||
allocate_shared(const A& allocator, std::size_t size,
|
|
||||||
std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
|
|
||||||
typedef typename boost::detail::array_inner<T>::type T1;
|
|
||||||
typedef typename boost::detail::array_base<T1>::type T2;
|
|
||||||
typedef const T2 T3;
|
|
||||||
enum {
|
|
||||||
M = boost::detail::array_total<T1>::size
|
|
||||||
};
|
|
||||||
T1* p1 = 0;
|
|
||||||
T2* p2 = 0;
|
|
||||||
T3* p3 = 0;
|
|
||||||
std::size_t n1 = M * list.size();
|
|
||||||
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
|
|
||||||
boost::detail::array_deleter<T2[]> d1;
|
|
||||||
boost::shared_ptr<T> s1(p1, d1, a1);
|
|
||||||
boost::detail::array_deleter<T2[]>* d2;
|
|
||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
|
||||||
d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
|
|
||||||
d2->construct_list(p2, n1, p3, M);
|
|
||||||
return boost::shared_ptr<T>(s1, p1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
@@ -146,6 +122,30 @@ namespace boost {
|
|||||||
return boost::shared_ptr<T>(s1, p1);
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
|
inline typename boost::detail::sp_if_array<T>::type
|
||||||
|
allocate_shared(const A& allocator, std::size_t size,
|
||||||
|
const typename boost::detail::array_inner<T>::type& list) {
|
||||||
|
typedef typename boost::detail::array_inner<T>::type T1;
|
||||||
|
typedef typename boost::detail::array_base<T1>::type T2;
|
||||||
|
typedef const T2 T3;
|
||||||
|
enum {
|
||||||
|
M = boost::detail::array_total<T1>::size
|
||||||
|
};
|
||||||
|
T1* p1 = 0;
|
||||||
|
T2* p2 = 0;
|
||||||
|
T3* p3 = 0;
|
||||||
|
std::size_t n1 = M * size;
|
||||||
|
boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
|
||||||
|
boost::detail::array_deleter<T2[]> d1;
|
||||||
|
boost::shared_ptr<T> s1(p1, d1, a1);
|
||||||
|
boost::detail::array_deleter<T2[]>* d2;
|
||||||
|
p3 = reinterpret_cast<T3*>(list);
|
||||||
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
|
d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
|
||||||
|
d2->construct_list(p2, n1, p3, M);
|
||||||
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
|
}
|
||||||
|
template<typename T, typename A>
|
||||||
inline typename boost::detail::sp_if_size_array<T>::type
|
inline typename boost::detail::sp_if_size_array<T>::type
|
||||||
allocate_shared(const A& allocator,
|
allocate_shared(const A& allocator,
|
||||||
const typename boost::detail::array_inner<T>::type& list) {
|
const typename boost::detail::array_inner<T>::type& list) {
|
||||||
|
@@ -51,12 +51,6 @@ namespace boost {
|
|||||||
struct array_inner<T[N]> {
|
struct array_inner<T[N]> {
|
||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
template<typename T>
|
|
||||||
struct arrays_inner;
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct arrays_inner<T[][N]> {
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -96,30 +96,6 @@ namespace boost {
|
|||||||
d2->construct_list(p2, n1, p3);
|
d2->construct_list(p2, n1, p3);
|
||||||
return boost::shared_ptr<T>(s1, p1);
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T>
|
|
||||||
inline typename boost::detail::sp_if_array<T>::type
|
|
||||||
make_shared(std::size_t size,
|
|
||||||
std::initializer_list<typename boost::detail::arrays_inner<T>::type> list) {
|
|
||||||
typedef typename boost::detail::array_inner<T>::type T1;
|
|
||||||
typedef typename boost::detail::array_base<T1>::type T2;
|
|
||||||
typedef const T2 T3;
|
|
||||||
enum {
|
|
||||||
M = boost::detail::array_total<T1>::size
|
|
||||||
};
|
|
||||||
T1* p1 = 0;
|
|
||||||
T2* p2 = 0;
|
|
||||||
T3* p3 = 0;
|
|
||||||
std::size_t n1 = M * size;
|
|
||||||
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
|
|
||||||
boost::detail::array_deleter<T2[]> d1;
|
|
||||||
boost::shared_ptr<T> s1(p1, d1, a1);
|
|
||||||
boost::detail::array_deleter<T2[]>* d2;
|
|
||||||
p3 = reinterpret_cast<T3*>(list.begin());
|
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
|
||||||
d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
|
|
||||||
d2->construct_list(p2, n1, p3, M);
|
|
||||||
return boost::shared_ptr<T>(s1, p1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -145,6 +121,30 @@ namespace boost {
|
|||||||
return boost::shared_ptr<T>(s1, p1);
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
inline typename boost::detail::sp_if_array<T>::type
|
||||||
|
make_shared(std::size_t size,
|
||||||
|
const typename boost::detail::array_inner<T>::type& list) {
|
||||||
|
typedef typename boost::detail::array_inner<T>::type T1;
|
||||||
|
typedef typename boost::detail::array_base<T1>::type T2;
|
||||||
|
typedef const T2 T3;
|
||||||
|
enum {
|
||||||
|
M = boost::detail::array_total<T1>::size
|
||||||
|
};
|
||||||
|
T1* p1 = 0;
|
||||||
|
T2* p2 = 0;
|
||||||
|
T3* p3 = 0;
|
||||||
|
std::size_t n1 = M * size;
|
||||||
|
boost::detail::make_array_helper<T2[]> a1(n1, &p2);
|
||||||
|
boost::detail::array_deleter<T2[]> d1;
|
||||||
|
boost::shared_ptr<T> s1(p1, d1, a1);
|
||||||
|
boost::detail::array_deleter<T2[]>* d2;
|
||||||
|
p3 = reinterpret_cast<T3*>(list);
|
||||||
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
|
d2 = get_deleter<boost::detail::array_deleter<T2[]> >(s1);
|
||||||
|
d2->construct_list(p2, n1, p3, M);
|
||||||
|
return boost::shared_ptr<T>(s1, p1);
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
inline typename boost::detail::sp_if_size_array<T>::type
|
inline typename boost::detail::sp_if_size_array<T>::type
|
||||||
make_shared(const typename boost::detail::array_inner<T>::type& list) {
|
make_shared(const typename boost::detail::array_inner<T>::type& list) {
|
||||||
typedef typename boost::detail::array_inner<T>::type T1;
|
typedef typename boost::detail::array_inner<T>::type T1;
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<A href="#Synopsis">Synopsis</A><br>
|
<A href="#Synopsis">Synopsis</A><br>
|
||||||
<A href="#functions">Free Functions</A><br>
|
<A href="#functions">Free Functions</A><br>
|
||||||
<A href="#example">Example</A><br>
|
<A href="#example">Example</A><br>
|
||||||
<A href="#history">History</A><br>
|
<A href="#history">History</A><br></p>
|
||||||
<h2><a name="Introduction">Introduction</a></h2>
|
<h2><a name="Introduction">Introduction</a></h2>
|
||||||
<p>Originally the Boost function templates <code>make_shared</code> and
|
<p>Originally the Boost function templates <code>make_shared</code> and
|
||||||
<code>allocate_shared</code> were for efficient allocation of single
|
<code>allocate_shared</code> were for efficient allocation of single
|
||||||
@@ -53,26 +53,26 @@
|
|||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
shared_ptr<T[]> <a href="#functions">make_shared</a>(initializer_list<T> list);
|
shared_ptr<T[]> <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, 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>
|
|
||||||
shared_ptr<T[][N]> <a href="#functions">allocate_shared</a>(const A& allocator, size_t size, initializer_list<T> list);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
shared_ptr<T[N]> <a href="#functions">make_shared</a>(const T (&list)[N]);
|
shared_ptr<T[N]> <a href="#functions">make_shared</a>(const T (&list)[N]);
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
shared_ptr<T[][N]> <a href="#functions">make_shared</a>(size_t size, const T (&list)[N]);
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
shared_ptr<T[M][N]> <a href="#functions">make_shared</a>(const T (&list)[N]);
|
shared_ptr<T[M][N]> <a href="#functions">make_shared</a>(const T (&list)[N]);
|
||||||
|
|
||||||
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, const T (&list)[N]);
|
shared_ptr<T[N]> <a href="#functions">allocate_shared</a>(const A& allocator, const T (&list)[N]);
|
||||||
|
|
||||||
|
template<typename T, typename A, typename... Args>
|
||||||
|
shared_ptr<T[][N]> <a href="#functions">allocate_shared</a>(const A& allocator, size_t size, const T (&list)[N]);
|
||||||
|
|
||||||
template<typename T, typename A, typename... Args>
|
template<typename T, typename A, typename... Args>
|
||||||
shared_ptr<T[M][N]> <a href="#functions">allocate_shared</a>(const A& allocator, const T (&list)[N]);
|
shared_ptr<T[M][N]> <a href="#functions">allocate_shared</a>(const A& allocator, const T (&list)[N]);
|
||||||
#endif
|
#endif
|
||||||
@@ -151,9 +151,9 @@ template<typename T, typename A, typename... Args>
|
|||||||
fixed size array.</p>
|
fixed size array.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<typename T, typename... Args>
|
<pre>template<typename T, typename... Args>
|
||||||
shared_ptr<T[][N]> make_shared(size_t size, initializer_list<T> list);
|
shared_ptr<T[][N]> make_shared(size_t size, const T (&list)[N]);
|
||||||
template<typename T, typename A, typename... Args>
|
template<typename T, typename A, typename... Args>
|
||||||
shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list);</pre>
|
shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, const T (&list)[N]);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Description:</b> These overloads initialize inner array elements
|
<p><b>Description:</b> These overloads initialize inner array elements
|
||||||
from the initializer list.</p>
|
from the initializer list.</p>
|
||||||
|
Reference in New Issue
Block a user