function template
<memory>
std::make_shared
template <class T, class... Args> shared_ptr<T> make_shared (Args&&... args);
Make shared_ptr
This function uses
::new to allocate storage for the object. A similar function, allocate_shared, accepts an allocator as argument and uses it to allocate the storage.Parameters
- args
- List of elements passed to T's constructor.
Args is a list of zero or more types.
Return Value
A shared_ptr object that owns and stores a pointer to a newly allocated object of type T.Example
|
|
Output:
*foo: 10 *bar: 20 *baz: 30 40
See also
- allocate_shared
- Allocate shared_ptr (function template)
- shared_ptr::shared_ptr
- Construct shared_ptr (public member function)
- shared_ptr::operator=
- shared_ptr assignment (public member function)