cpp/experimental/shared ptr/shared ptr

Constructs new from a variety of pointer types that refer to an object to manage.

For the purposes of the description below, a pointer type is said to be compatible with a pointer type  if either  is convertible to  or  is the array type  and  is  (where cv is some set of cv-qualifiers).

@1-2@ Constructs a with no managed object, i.e. empty

@3-7@ Constructs a with  as the pointer to the managed object. If is an array type,  must be convertible to. If is an array type,  must be convertible to. Otherwise, must be convertible to. Additionally:


 * @3@ Uses a delete-expression (, if is not an array type;  if  is an array type) as the deleter.  must be a complete type. That delete expression must be well formed, have well-defined behavior and not throw any exceptions.


 * @4-5@ Uses the specified deleter as the deleter. The expression  must be well formed, have well-defined behavior and not throw any exceptions.  must be, and its copy constructor and destructor must not throw exceptions.


 * @6-7@ Same as, but additionally uses a copy of  for allocation of data for internal use.  must be a , and its copy constructor and destructor must not throw exceptions.

@8@ The aliasing constructor: constructs a which shares ownership information with, but holds an unrelated and unmanaged pointer. Even if this is the last of the group to go out of scope, it will call the destructor for the object originally managed by. However, calling on this will always return a copy of. It is the responsibility of the programmer to make sure that this remains valid as long as this shared_ptr exists, such as in the typical use cases where  is a member of the object managed by  or is an alias (e.g., downcast) of

@9@ Constructs a which shares ownership of the object managed by. If manages no object,  manages no object too. The template overload doesn't participate in overload resolution if is not compatible with.

@10@ Move-constructs a from. After the construction, contains a copy of the previous state of,  is empty. The template overload doesn't participate in overload resolution if is not compatible with.

@11@ Constructs a which shares ownership of the object managed by. must be compatible with. Note that may be used for the same purpose: the difference is that this constructor throws an exception if the argument is empty, while  constructs an empty  in that case.

@12@ Constructs a that stores and owns the object formerly owned by. must be convertible to. After construction, is empty.

@13@ Constructs a which manages the object currently managed by. The deleter associated with is stored for future deletion of the managed object. manages no object after the call. This overload doesn't participate in overload resolution if is not compatible with. If is a reference type, equivalent to. Otherwise, equivalent to

Exceptions
@3@ std if required additional memory could not be obtained. May throw implementation-defined exception for other errors. The applicable delete-expression ( if is not an array type,  otherwise) is called if an exception occurs.

@4-7@ std if required additional memory could not be obtained. May throw implementation-defined exception for other errors. is called if an exception occurs.

@11@ std if. The constructor has no effect in this case.

@12@ std if required additional memory could not be obtained. May throw implementation-defined exception for other errors. This constructor has no effect if an exception occurs.

@13@ If an exception is thrown, the constructor has no effects.