diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp
index 4a7de24..0c17edd 100644
--- a/include/boost/smart_ptr/allocate_shared_array.hpp
+++ b/include/boost/smart_ptr/allocate_shared_array.hpp
@@ -29,12 +29,12 @@ namespace boost {
T2* p2 = 0;
std::size_t n1 = size * boost::detail::array_total
Free Functions
Example
- History
+ History
Originally the Boost function templates make_shared
and
allocate_shared
were for efficient allocation of single
@@ -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,31 +48,33 @@
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... Args>
- shared_ptr<T[M][N]> make_shared(initializer_list<T> list);
-
template<typename T, typename A, typename... Args>
shared_ptr<T[]> allocate_shared(const A& allocator, initializer_list<T> list);
+#endif
+
+#if !defined(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[][N]> make_shared(size_t size, 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, 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[][N]> allocate_shared(const A& allocator, size_t size, initializer_list<T> list);
+ shared_ptr<T[][N]> allocate_shared(const A& allocator, size_t size, const T (&list)[N]);
template<typename T, typename A, typename... Args>
- shared_ptr<T[M][N]> allocate_shared(const A& allocator, initializer_list<T> list);
+ shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]);
#endif
template<typename T>
@@ -141,25 +143,25 @@ template<typename T, typename A, typename... Args>
from the initializer list.
template<typename T, typename... Args> - shared_ptr<T[N]> make_shared(initializer_list<T> list); + shared_ptr<T[N]> make_shared(const T (&list)[N]); template<typename T, typename A, typename... Args> - shared_ptr<T[N]> allocate_shared(const A& allocator, initializer_list<T> list);+ shared_ptr<T[N]> allocate_shared(const A& allocator, const T (&list)[N]);
Description: These overloads of the utilities above are for a fixed size array.
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> - 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, size_t size, const T (&list)[N]);
Description: These overloads initialize inner array elements from the initializer list.
template<typename T, typename... Args> - shared_ptr<T[M][N]> make_shared(initializer_list<T> list); + shared_ptr<T[M][N]> make_shared(const T (&list)[N]); template<typename T, typename A, typename... Args> - shared_ptr<T[M][N]> allocate_shared(const A& allocator, initializer_list<T> list);+ shared_ptr<T[M][N]> allocate_shared(const A& allocator, const T (&list)[N]);
Description: These overloads of the utilities above are for a fixed size array.
diff --git a/test/allocate_shared_array_init_test.cpp b/test/allocate_shared_array_init_test.cpp index 6411aa8..1ff437f 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_ptra1 = 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 +#if !defined(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 03a2d7e..8645179 100644 --- a/test/allocate_shared_arrays_create_test.cpp +++ b/test/allocate_shared_arrays_create_test.cpp @@ -11,6 +11,13 @@ int main() { #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + 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); @@ -18,6 +25,15 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } +#endif +#if !defined(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); @@ -25,13 +41,6 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } - { - boost::shared_ptr a1 = boost::allocate_shared (std::allocator (), {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}); BOOST_TEST(a1[0][0] == 0); @@ -46,6 +55,13 @@ int main() { 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}); + 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 (), { {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..fd61caf 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 +#if !defined(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 e468378..eb08759 100644 --- a/test/make_shared_arrays_create_test.cpp +++ b/test/make_shared_arrays_create_test.cpp @@ -8,10 +8,16 @@ */ #include #include -#include int main() { #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + { + 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); @@ -19,6 +25,15 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } +#endif +#if !defined(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); @@ -26,13 +41,6 @@ int main() { BOOST_TEST(a1[1][0] == 2); BOOST_TEST(a1[1][1] == 3); } - { - boost::shared_ptr a1 = boost::make_shared ({ 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}); BOOST_TEST(a1[0][0] == 0); @@ -47,6 +55,13 @@ int main() { BOOST_TEST(a1[1][1][0] == 2); BOOST_TEST(a1[1][1][1] == 3); } + { + boost::shared_ptr a1 = boost::make_shared ({ 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 ({ {0, 1}, {2, 3} }); BOOST_TEST(a1[0][0][0] == 0);