cpp/memory/shared ptr/allocate shared

@1@ Constructs an object of type and wraps it in a std using  as the parameter list for the constructor of. The object is constructed as if by the expression, where is an internal  pointer to storage suitable to hold an object of type  and  is a copy of the allocator rebound to. The storage is typically larger than in order to use one allocation for both the control block of the shared pointer and the  object. The std constructor called by this function enables with a pointer to the newly constructed object of type. All memory allocation is done using a copy of, which must satisfy the requirements. @2,3@ Same as, but the object constructed is a possibly-multidimensional array whose every non-array element is initialized as if by the expression where  of type  is the copy of the allocator rebound to manage objects of type. The overload creates an array of size  along its first dimension. The array elements are initialized in ascending order of their addresses, and when their lifetime ends are destroyed in the reverse order of their original construction. @4,5@ Same as, but the elements of the array are initialized from the default value. If is not itself an array type, then this is performed as if by the same allocator expression as in, except that the allocator is rebound to the. Otherwise, this is performed as if by initializing every non-array element of the (possibly multidimensional) array with the corresponding element from using the same allocator expression as in, except that the allocator is rebound to the type. The overload creates an array of size  along the first dimension. The array elements are initialized in ascending order of their addresses, and when their lifetime ends are destroyed in the reverse order of their original construction. @6@ Same as if  is not an array type and  if  is, except that the created object is default-initialized. @7@ Same as, except that the individual array elements are default-initialized.

For, the object are destroyed via the expression , where  is a pointer to the object and  is a copy of the allocator passed to , rebound to the type of the object being destroyed.

Return value
std of an instance of type.

Exceptions
Can throw the exceptions thrown from or from the constructor of. If an exception is thrown, has no effect.