diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp index e6f47d3..997a5c1 100644 --- a/include/boost/smart_ptr/allocate_shared_array.hpp +++ b/include/boost/smart_ptr/allocate_shared_array.hpp @@ -98,28 +98,6 @@ namespace boost { return boost::shared_ptr(s1, p1); } template - inline typename boost::detail::sp_if_size_array::type - allocate_shared(const A& allocator, const T& list) { - typedef typename boost::detail::array_inner::type T1; - typedef typename boost::detail::array_base::type T2; - typedef const T2 T3; - enum { - N = boost::detail::array_total::size - }; - T1* p1 = 0; - T2* p2 = 0; - T3* p3 = 0; - boost::detail::allocate_array_helper a1(allocator, &p2); - boost::detail::array_deleter d1; - boost::shared_ptr s1(p1, d1, a1); - boost::detail::array_deleter* d2; - p3 = reinterpret_cast(list); - p1 = reinterpret_cast(p2); - d2 = get_deleter >(s1); - d2->construct_list(p2, p3); - return boost::shared_ptr(s1, p1); - } - template inline typename boost::detail::sp_if_array::type allocate_shared(const A& allocator, std::size_t size, std::initializer_list::type> list) { @@ -143,6 +121,30 @@ namespace boost { d2->construct_list(p2, n1, p3, M); return boost::shared_ptr(s1, p1); } +#endif +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + template + inline typename boost::detail::sp_if_size_array::type + allocate_shared(const A& allocator, const T& list) { + typedef typename boost::detail::array_inner::type T1; + typedef typename boost::detail::array_base::type T2; + typedef const T2 T3; + enum { + N = boost::detail::array_total::size + }; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = 0; + boost::detail::allocate_array_helper a1(allocator, &p2); + boost::detail::array_deleter d1; + boost::shared_ptr s1(p1, d1, a1); + boost::detail::array_deleter* d2; + p3 = reinterpret_cast(list); + p1 = reinterpret_cast(p2); + d2 = get_deleter >(s1); + d2->construct_list(p2, p3); + return boost::shared_ptr(s1, p1); + } template inline typename boost::detail::sp_if_size_array::type allocate_shared(const A& allocator, diff --git a/include/boost/smart_ptr/make_shared_array.hpp b/include/boost/smart_ptr/make_shared_array.hpp index 52adf38..bf9e95f 100644 --- a/include/boost/smart_ptr/make_shared_array.hpp +++ b/include/boost/smart_ptr/make_shared_array.hpp @@ -97,28 +97,6 @@ namespace boost { return boost::shared_ptr(s1, p1); } template - inline typename boost::detail::sp_if_size_array::type - make_shared(const T& list) { - typedef typename boost::detail::array_inner::type T1; - typedef typename boost::detail::array_base::type T2; - typedef const T2 T3; - enum { - N = boost::detail::array_total::size - }; - T1* p1 = 0; - T2* p2 = 0; - T3* p3 = 0; - boost::detail::make_array_helper a1(&p2); - boost::detail::array_deleter d1; - boost::shared_ptr s1(p1, d1, a1); - boost::detail::array_deleter* d2; - p3 = reinterpret_cast(list); - p1 = reinterpret_cast(p2); - d2 = get_deleter >(s1); - d2->construct_list(p2, p3); - return boost::shared_ptr(s1, p1); - } - template inline typename boost::detail::sp_if_array::type make_shared(std::size_t size, std::initializer_list::type> list) { @@ -142,6 +120,30 @@ namespace boost { d2->construct_list(p2, n1, p3, M); return boost::shared_ptr(s1, p1); } +#endif +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + template + inline typename boost::detail::sp_if_size_array::type + make_shared(const T& list) { + typedef typename boost::detail::array_inner::type T1; + typedef typename boost::detail::array_base::type T2; + typedef const T2 T3; + enum { + N = boost::detail::array_total::size + }; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = 0; + boost::detail::make_array_helper a1(&p2); + boost::detail::array_deleter d1; + boost::shared_ptr s1(p1, d1, a1); + boost::detail::array_deleter* d2; + p3 = reinterpret_cast(list); + p1 = reinterpret_cast(p2); + d2 = get_deleter >(s1); + d2->construct_list(p2, p3); + return boost::shared_ptr(s1, p1); + } template inline typename boost::detail::sp_if_size_array::type make_shared(const typename boost::detail::array_inner::type& list) { diff --git a/make_shared_array.html b/make_shared_array.html index 3da2caa..f638555 100644 --- a/make_shared_array.html +++ b/make_shared_array.html @@ -34,7 +34,7 @@ template<typename T, typename A> 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); @@ -48,28 +48,30 @@ 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(const T (&list)[N]); - template<typename T, typename... Args> shared_ptr<T[][N]> make_shared(size_t size, initializer_list<T> list); - template<typename T, typename... Args> - shared_ptr<T[M][N]> make_shared(const T (&list)[N]); - 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, const T (&list)[N]); + shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list); +#endif + +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + template<typename T, typename... Args> + shared_ptr<T[N]> make_shared(const T (&list)[N]); + + template<typename T, typename... Args> + shared_ptr<T[M][N]> make_shared(const T (&list)[N]); template<typename T, typename A, typename... Args> - shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list); + shared_ptr<T[N]> allocate_shared(const A& allocator, const T (&list)[N]); template<typename T, typename A, typename... Args> shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]); diff --git a/test/allocate_shared_array_init_test.cpp b/test/allocate_shared_array_init_test.cpp index 6411aa8..8ca0d78 100644 --- a/test/allocate_shared_array_init_test.cpp +++ b/test/allocate_shared_array_init_test.cpp @@ -28,13 +28,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); BOOST_TEST(a1[0] == 0); @@ -42,13 +35,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); @@ -57,14 +43,30 @@ int main() { BOOST_TEST(a1[3].value == 3); } { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); BOOST_TEST(a1[1].value == 1); BOOST_TEST(a1[2].value == 2); BOOST_TEST(a1[3].value == 3); } +#endif +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } + { + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } + { + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); BOOST_TEST(a1[1].value == 1); BOOST_TEST(a1[2].value == 2); diff --git a/test/allocate_shared_arrays_create_test.cpp b/test/allocate_shared_arrays_create_test.cpp index 7764edf..8f7e052 100644 --- a/test/allocate_shared_arrays_create_test.cpp +++ b/test/allocate_shared_arrays_create_test.cpp @@ -18,13 +18,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), {0, 1, 2, 3}); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0] == 0); @@ -32,6 +25,29 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } + { + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), 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 a1 = boost::allocate_shared(std::allocator(), 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 +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + { + boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), {0, 1, 2, 3}); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } { boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0] == 0); @@ -46,20 +62,6 @@ int main() { BOOST_TEST(a1[1][0] == 0); BOOST_TEST(a1[1][1] == 1); } - { - boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), 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 a1 = boost::allocate_shared(std::allocator(), 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); - } { boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), { {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0][0] == 0); diff --git a/test/make_shared_array_init_test.cpp b/test/make_shared_array_init_test.cpp index 6a4c5d5..528c26f 100644 --- a/test/make_shared_array_init_test.cpp +++ b/test/make_shared_array_init_test.cpp @@ -28,13 +28,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); BOOST_TEST(a1[0] == 0); @@ -42,13 +35,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); @@ -57,14 +43,30 @@ int main() { BOOST_TEST(a1[3].value == 3); } { - boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); + boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); BOOST_TEST(a1[1].value == 1); BOOST_TEST(a1[2].value == 2); BOOST_TEST(a1[3].value == 3); } +#endif +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX { - boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); + boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } + { + boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } + { + boost::shared_ptr a1 = boost::make_shared({ 0, 1, 2, 3 }); BOOST_TEST(a1[0].value == 0); BOOST_TEST(a1[1].value == 1); BOOST_TEST(a1[2].value == 2); diff --git a/test/make_shared_arrays_create_test.cpp b/test/make_shared_arrays_create_test.cpp index e999182..c1ef6b9 100644 --- a/test/make_shared_arrays_create_test.cpp +++ b/test/make_shared_arrays_create_test.cpp @@ -19,13 +19,6 @@ int main() { BOOST_TEST(a1[2] == 2); BOOST_TEST(a1[3] == 3); } - { - boost::shared_ptr a1 = boost::make_shared({0, 1, 2, 3}); - BOOST_TEST(a1[0] == 0); - BOOST_TEST(a1[1] == 1); - BOOST_TEST(a1[2] == 2); - BOOST_TEST(a1[3] == 3); - } { boost::shared_ptr a1 = boost::make_shared({ {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0] == 0); @@ -33,6 +26,29 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } + { + boost::shared_ptr a1 = boost::make_shared(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 a1 = boost::make_shared(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 +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + { + boost::shared_ptr a1 = boost::make_shared({0, 1, 2, 3}); + BOOST_TEST(a1[0] == 0); + BOOST_TEST(a1[1] == 1); + BOOST_TEST(a1[2] == 2); + BOOST_TEST(a1[3] == 3); + } { boost::shared_ptr a1 = boost::make_shared({ {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0] == 0); @@ -47,20 +63,6 @@ int main() { BOOST_TEST(a1[1][0] == 0); BOOST_TEST(a1[1][1] == 1); } - { - boost::shared_ptr a1 = boost::make_shared(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 a1 = boost::make_shared(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); - } { boost::shared_ptr a1 = boost::make_shared({ {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0][0] == 0);