forked from boostorg/smart_ptr
Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
[SVN r81259]
This commit is contained in:
@ -55,14 +55,14 @@ namespace boost {
|
|||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
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, typename detail::array_list<T>::type list) {
|
allocate_shared(const A& allocator, typename detail::array_list<T>::type list) {
|
||||||
typedef typename shared_ptr<T>::element_type T1;
|
typedef typename shared_ptr<T>::element_type T1;
|
||||||
typedef typename detail::array_type<T1>::type T2;
|
typedef typename detail::array_type<T1>::type T2;
|
||||||
typedef const T2 T3;
|
typedef const T2 T3;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = size * detail::array_size<T1>::size;
|
size_t n1 = list.size() * detail::array_size<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);
|
||||||
|
@ -55,14 +55,14 @@ namespace boost {
|
|||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline typename detail::sp_if_array<T>::type
|
inline typename detail::sp_if_array<T>::type
|
||||||
make_shared(std::size_t size, typename detail::array_list<T>::type list) {
|
make_shared(typename detail::array_list<T>::type list) {
|
||||||
typedef typename shared_ptr<T>::element_type T1;
|
typedef typename shared_ptr<T>::element_type T1;
|
||||||
typedef typename detail::array_type<T1>::type T2;
|
typedef typename detail::array_type<T1>::type T2;
|
||||||
typedef const T2 T3;
|
typedef const T2 T3;
|
||||||
T1* p1 = 0;
|
T1* p1 = 0;
|
||||||
T2* p2 = 0;
|
T2* p2 = 0;
|
||||||
T3* p3 = 0;
|
T3* p3 = 0;
|
||||||
size_t n1 = size * detail::array_size<T1>::size;
|
size_t n1 = list.size() * detail::array_size<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);
|
||||||
|
@ -76,14 +76,14 @@ int main() {
|
|||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), 4, { 0, 1, 2, 3 });
|
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), { 0, 1, 2, 3 });
|
||||||
BOOST_TEST(a1[0] == 0);
|
BOOST_TEST(a1[0] == 0);
|
||||||
BOOST_TEST(a1[1] == 1);
|
BOOST_TEST(a1[1] == 1);
|
||||||
BOOST_TEST(a1[2] == 2);
|
BOOST_TEST(a1[2] == 2);
|
||||||
BOOST_TEST(a1[3] == 3);
|
BOOST_TEST(a1[3] == 3);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2, { {0, 1}, {2, 3} });
|
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), { {0, 1}, {2, 3} });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
BOOST_TEST(a1[0][1] == 1);
|
BOOST_TEST(a1[0][1] == 1);
|
||||||
BOOST_TEST(a1[1][0] == 2);
|
BOOST_TEST(a1[1][0] == 2);
|
||||||
|
@ -76,14 +76,14 @@ int main() {
|
|||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(4, { 0, 1, 2, 3 });
|
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>({ 0, 1, 2, 3 });
|
||||||
BOOST_TEST(a1[0] == 0);
|
BOOST_TEST(a1[0] == 0);
|
||||||
BOOST_TEST(a1[1] == 1);
|
BOOST_TEST(a1[1] == 1);
|
||||||
BOOST_TEST(a1[2] == 2);
|
BOOST_TEST(a1[2] == 2);
|
||||||
BOOST_TEST(a1[3] == 3);
|
BOOST_TEST(a1[3] == 3);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2, { {0, 1}, {2, 3} });
|
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>({ {0, 1}, {2, 3} });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
BOOST_TEST(a1[0][1] == 1);
|
BOOST_TEST(a1[0][1] == 1);
|
||||||
BOOST_TEST(a1[1][0] == 2);
|
BOOST_TEST(a1[1][0] == 2);
|
||||||
|
Reference in New Issue
Block a user