diff --git a/make_shared_array.html b/make_shared_array.html index 3437e9e..6959ca1 100644 --- a/make_shared_array.html +++ b/make_shared_array.html @@ -5,7 +5,7 @@
-Introduction
@@ -29,103 +29,69 @@
allowing finer control.
namespace boost { - template<typename U> // U = T[] + template<typename U> // U is T[] shared_ptr<U> make_shared(size_t size); - template<typename U, typename A> // U = T[] + template<typename U, typename A> // U is T[] shared_ptr<U> allocate_shared(const A& allocator, size_t size); + + template<typename U> // U is T[N] + shared_ptr<U> make_shared(); -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template<typename U, typename... Args> // U = T[] - shared_ptr<U> make_shared(size_t size, Args&&... args); + template<typename U, typename A> // U is T[N] + shared_ptr<U> allocate_shared(const A& allocator); + + template<typename U> // U is T[] + shared_ptr<U> make_shared(size_t size, const T& value); - template<typename U, typename... Args> // U = T[N] - shared_ptr<U> make_shared(Args&&... args); + template<typename U, typename A> // U is T[] + shared_ptr<U> allocate_shared(const A& allocator, size_t size, const T& value); - template<typename U, typename A, typename... Args> // U = T[] - shared_ptr<U> allocate_shared(const A& allocator, size_t size, Args&&... args); + template<typename U> // U is T[N] + shared_ptr<U> make_shared(const T& value); - template<typename U, typename A, typename... Args> // U = T[N] - shared_ptr<U> allocate_shared(const A& allocator, Args&&... args); -#endif + template<typename U, typename A> // U is T[N] + shared_ptr<U> allocate_shared(const A& allocator, const T& value); -#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) - template<typename U, typename... Args> // U = T[N] - shared_ptr<U> make_shared(const T (&list)[N]); - - template<typename U, typename... Args> // U = T[][N] - shared_ptr<U> make_shared(size_t size, const T (&list)[N]); - - template<typename U, typename... Args> // U = T[M][N] - shared_ptr<U> make_shared(const T (&list)[N]); - - template<typename U, typename A, typename... Args> // U = T[N] - shared_ptr<T[> allocate_shared(const A& allocator, const T (&list)[N]); - - template<typename U, typename A, typename... Args> // U = T[][N] - shared_ptr<U> allocate_shared(const A& allocator, size_t size, const T (&list)[N]); - - template<typename U, typename A, typename... Args> // U = T[M][N] - shared_ptr<U> allocate_shared(const A& allocator, const T (&list)[N]); - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - template<typename U, typename... Args> // U = T[] - shared_ptr<U> make_shared(initializer_list<T> list); - - template<typename U, typename A, typename... Args> // U = T[] - shared_ptr<U> allocate_shared(const A& allocator, initializer_list<T> list); -#endif - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template<typename U> // U = T[] - shared_ptr<U> make_shared(size_t size, T&& value); - - template<typename U> // U = T[N] - shared_ptr<U> make_shared(T&& value); - - template<typename U, typename A> // U = T[] - shared_ptr<U> allocate_shared(const A& allocator, size_t size, T&& value); - - template<typename U, typename A> // U = T[N] - shared_ptr<U> allocate_shared(const A& allocator, T&& value); -#endif -#endif - - template<typename U> // U = T[] + template<typename U> // U is T[] shared_ptr<U> make_shared_noinit(size_t size); - template<typename U> // U = T[N] - shared_ptr<U> make_shared_noinit(); - - template<typename U, typename A> // U = T[] + template<typename U, typename A> // U is T[] shared_ptr<U> allocate_shared_noinit(const A& allocator, size_t size); - template<typename U, typename A> // U = T[N] + template<typename U> // U is T[N] + shared_ptr<U> make_shared_noinit(); + + template<typename U, typename A> // U is T[N] shared_ptr<U> allocate_shared_noinit(const A& allocator); }
template<typename U, typename... Args> // U = T[] -shared_ptr<U> make_shared(size_t size, Args&&... args); +template<typename U> // U is T[] +shared_ptr<U> make_shared(size_t size); -template<typename U, typename A, typename... Args> // U = T[] -shared_ptr<U> allocate_shared(const A& allocator, size_t size, Args&&... args);+template<typename U, typename A> // U is T[] +shared_ptr<U> allocate_shared(const A& allocator, size_t size); + +template<typename U> // U is T[N] +shared_ptr<U> make_shared(); + +template<typename U, typename A> // U is T[N] +shared_ptr<U> allocate_shared(const A& allocator);
-Requires: The expression -
+new(pointer) T(forward<Args>(args)...)
, where -pointer
is avoid*
pointing to storage - suitable to hold an object of typeT
, shall be - well-formed.A
shall be an Allocator, as - described in section 20.1.5 (Allocator requirements) - of the C++ Standard. The copy constructor and destructor of -A
shall not throw.new(pointer) T()
, wherepointer
is a +void*
pointing to storage suitable to hold an object + of typeT
, shall be well-formed.A
+ shall be an Allocator, as described in section 20.1.5 + (Allocator requirements) of the C++ Standard. + The copy constructor and destructor ofA
shall not + throw.Effects: Allocates memory suitable for an array of type
+T
and sizesize
and constructs an array of objects in it via the placement new expression -new(pointer) T()
or -new(pointer) T(args...)
. -allocate_shared
uses a copy of -allocator
to allocate memory. If an exception is thrown, - has no effect.new(pointer) T()
.allocate_shared
uses + a copy ofallocator
to allocate memory. If an + exception is thrown, has no effect.Returns: A
@@ -137,121 +103,63 @@ shared_ptr<U> allocate_shared(const A& allocator, size_t size, Args&am the returnedshared_ptr
instance that stores and owns the address of the newly constructed array of typeT
and sizesize
.shared_ptr
and an array of typeT
of sizesize
in a single allocation. This provides efficiency to equivalent to an intrusive smart array - pointer. -The prototypes shown above are used if your compiler supports r-value - references and variadic templates. They perfectly forward the -
-args
parameters to the constructors of -T
for each array element.Otherwise, you can use the overloads which take only the array size - (and the allocator in case of
+ pointer.allocate_shared
) and do not - take any constructor arguments. These overloads invoke the default - constructor ofT
for each array element.
template<typename U, typename... Args> // U = T[N] -shared_ptr<U> make_shared(Args&&... args); +template<typename U> // U is T[] +shared_ptr<U> make_shared(size_t size, const T& value); -template<typename U, typename A, typename... Args> // U = T[N] -shared_ptr<U> allocate_shared(const A& allocator, Args&&... args);---Description: These overloads of the utilities above are for a - fixed size array.
-template<typename U, typename... Args> // U = T[] -shared_ptr<U> make_shared(initializer_list<T> list); +template<typename U, typename A> // U is T[] +shared_ptr<U> allocate_shared(const A& allocator, size_t size, const T& value); -template<typename U, typename A, typename... Args> // U = T[] -shared_ptr<U> allocate_shared(const A& allocator, initializer_list<T> list);---Description: These overloads initialize the array elements - from the initializer list.
-template<typename U, typename... Args> // U = T[N] -shared_ptr<U> make_shared(const T (&list)[N]); +template<typename U> // U is T[N] +shared_ptr<U> make_shared(const T& value); -template<typename U, typename A, typename... Args> // U = T[N] -shared_ptr<U> allocate_shared(const A& allocator, const T (&list)[N]);---Description: These overloads of the utilities above are for a - fixed size array.
-template<typename U, typename... Args> // U = T[][N] -shared_ptr<U> make_shared(size_t size, const T (&list)[N]); - -template<typename U, typename A, typename... Args> // U = T[][N] -shared_ptr<U> 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 U, typename... Args> // U = T[M][N] -shared_ptr<U> make_shared(const T (&list)[N]); - -template<typename U, typename A, typename... Args> // U = T[M][N] -shared_ptr<U> allocate_shared(const A& allocator, const T (&list)[N]);---Description: These overloads of the utilities above are for a - fixed size array.
-template<typename U> // U = T[] -shared_ptr<U> make_shared(size_t size, T&& value); - -template<typename U, typename A> // U = T[] -shared_ptr<U> allocate_shared(const A& allocator, size_t size, T&& value);+template<typename U, typename A> // U is T[N] +shared_ptr<U> allocate_shared(const A& allocator, const T& value);
-Description: These overloads initialize array elements with the given value.
template<typename U> // U = T[N] -shared_ptr<U> make_shared(T&& value); - -template<typename U, typename A> // U = T[N] -shared_ptr<U> allocate_shared(const A& allocator, T&& value);-
--Description: These overloads of the utilities above are for a - fixed size array.
-
template<typename U> // U = T[] +template<typename U> // U is T[] shared_ptr<U> make_shared_noinit(size_t size); -template<typename U, typename A> // U = T[] -shared_ptr<U> allocate_shared_noinit(const A& allocator, size_t size);+template<typename U, typename A> // U is T[] +shared_ptr<U> allocate_shared_noinit(const A& allocator, size_t size); + +template<typename U> // U is T[N] +shared_ptr<U> make_shared_noinit(); + +template<typename U, typename A> // U is T[N] +shared_ptr<U> allocate_shared_noinit(const A& allocator);
-Description: These overloads do not perform any value initialization of elements.
-
template<typename U> // U = T[N] -shared_ptr<U> make_shared_noinit(); - -template<typename U, typename A> // U = T[N] -shared_ptr<U> allocate_shared_noinit(const A& allocator);-
--Description: These overloads of the utilities above are for a - fixed size array.
-
An example of each overload of make_shared for arrays:
+ +Some examples of each overload of make_shared for arrays:
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size); -boost::shared_ptr<point[]> a2 = boost::make_shared<point[]>(size, x, y); -boost::shared_ptr<point[5]> a3 = boost::make_shared<point[5]>(x, y); -boost::shared_ptr<int[]> a4 = boost::make_shared<int[]>({1, 2, 3}); -boost::shared_ptr<int[3]> a5 = boost::make_shared<int[3]>({1, 2, 3}); -boost::shared_ptr<int[][3]> a6 = boost::make_shared<int[][3]>(size, {1, 2, 3}); -boost::shared_ptr<int[5][3]> a7 = boost::make_shared<int[5][3]>({1, 2, 3}); -boost::shared_ptr<point[]> a8 = boost::make_shared<point[]>(size, {x, y}); -boost::shared_ptr<point[5]> a9 = boost::make_shared<point[5]>({x, y}); -boost::shared_ptr<int[]> a10 = boost::make_shared_noinit<int[]>(size); -boost::shared_ptr<int[5]> a11 = boost::make_shared_noinit<int[5]>();+boost::shared_ptr<int[8]> a2 = boost::make_shared<int[8]>(); +boost::shared_ptr<int[][2]> a3 = boost::make_shared<int[][2]>(size); +boost::shared_ptr<int[4][2]> a4 = boost::make_shared<int[4][2]>(); +boost::shared_ptr<int[]> a5 = boost::make_shared<int[]>(size, 1); +boost::shared_ptr<int[8]> a6 = boost::make_shared<int[8]>(1); +boost::shared_ptr<int[][2]> a7 = boost::make_shared<int[][2]>(size, {1, 2}); +boost::shared_ptr<int[4][2]> a8 = boost::make_shared<int[4][2]>({1, 2}); +boost::shared_ptr<int[]> a9 = boost::make_shared_noinit<int[]>(size); +boost::shared_ptr<int[8]> a10 = boost::make_shared_noinit<int[8]>(); +boost::shared_ptr<int[][2]> a11 = boost::make_shared_noinit<int[][2]>(size); +boost::shared_ptr<int[4][2]> a12 = boost::make_shared_noinit<int[4][2]>();
November 2012. Glen Fernandes contributed implementations of make_shared and allocate_shared for arrays.
$Date: 2012-10-30 10:12:25 -0800 (Tue, 30 Oct 2012) $
-Copyright 2012 Glen Fernandes. Distributed under the Boost - Software License, Version 1.0. See accompanying file - LICENSE_1_0.txt or copy at - - http://www.boost.org/LICENSE_1_0.txt.
+$Date: 2014-01-20 11:10:00 -0800 (Mon, 20 Jan 2014) $
+Copyright 2012-2014 Glen Fernandes. Distributed under the + Boost Software License, Version 1.0. See accompanying file + LICENSE_1_0.txt or copy at + + http://www.boost.org/LICENSE_1_0.txt.