cpp/memory/shared ptr/pointer cast

Creates a new instance of std whose stored pointer is obtained from 's stored pointer using a cast expression.

If is empty, so is the new  (but its stored pointer is not necessarily null). Otherwise, the new will share ownership with the initial value of, except that it is empty if the  performed by  returns a null pointer.

Let be, then the resulting std's stored pointer will be obtained by evaluating, respectively:

@1-2@ . @3-4@ (If the result of the  is a null pointer value, the returned  will be empty.) @5-6@ . @7-8@

The behavior of these functions is undefined unless the corresponding cast from to  is well formed:

@1-2@ The behavior is undefined unless is well formed. @3-4@ The behavior is undefined unless is well formed. @5-6@ The behavior is undefined unless is well formed. @7-8@ The behavior is undefined unless is well formed.