Namespaces
Variants
Views
Actions

std::experimental::shared_ptr

From cppreference.com
 
 
Technical specifications
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals 2 TS)
Extensions for parallelism (parallelism TS)
Extensions for concurrency (concurrency TS)
Concepts (concepts TS)
Ranges (ranges TS)
Special mathematical functions (special math TR)
 
 
 
Defined in header <experimental/memory>
template< class T > class shared_ptr;
(library fundamentals TS)

std::experimental::shared_ptr is a modified version of std::shared_ptr that adds support for arrays.

Contents

[edit] Member types

Member type Definition
element_type std::remove_extent_t<T>

[edit] Member functions

constructs new shared_ptr
(public member function) [edit]
Observers
returns the stored pointer
(public member function) [edit]
dereferences the stored pointer
(public member function) [edit]
provides index access to the array
(public member function) [edit]

[edit] Non-member functions

applies static_cast, dynamic_cast, const_cast, or reinterpret_cast to the stored pointer
(function template) [edit]

[edit] Helper classes

hash support for std::experimental::shared_ptr
(class template specialization) [edit]


Members and non-members identical to std::shared_ptr

Member functions

The following member functions work with std::experimental::shared_ptr instead of std::shared_ptr and std::experimental::weak_ptr instead of std::weak_ptr. The behavior is otherwise identical.

destructs the owned object if no more shared_ptrs link to it
(public member function of std::shared_ptr) [edit]
assigns the shared_ptr
(public member function of std::shared_ptr) [edit]
Modifiers
replaces the managed object
(public member function of std::shared_ptr) [edit]
swaps the managed objects
(public member function of std::shared_ptr) [edit]
Observers
returns the number of shared_ptr objects referring to the same managed object
(public member function of std::shared_ptr) [edit]
(deprecated)
checks whether the managed object is managed only by the current shared_ptr instance
(public member function of std::shared_ptr) [edit]
checks if the stored pointer is not null
(public member function of std::shared_ptr) [edit]
provides owner-based ordering of shared pointers
(public member function of std::shared_ptr) [edit]

Non-member functions

These non-member functions are declared in the std::experimental namespace, and work with std::experimental::shared_ptr rather than std::shared_ptr, but otherwise behaves identically to the corresponding C++14 function.

creates a shared pointer that manages a new object
(function template) [edit]
creates a shared pointer that manages a new object allocated using an allocator
(function template) [edit]
returns the deleter of specified type, if owned
(function template) [edit]
compares with another shared_ptr or with nullptr
(function template) [edit]
outputs the value of the stored pointer to an output stream
(function template) [edit]
specializes the std::swap algorithm
(function template) [edit]
specializes atomic operations for std::shared_ptr
(function template) [edit]

Helper class templates

These class templates are declared in the std::experimental namespace, and work with std::experimental::shared_ptr and std::experimental::weak_ptr rather than std::shared_ptr and std::weak_ptr, but otherwise behaves identically to the corresponding C++14 class template.

provides mixed-type owner-based ordering of shared and weak pointers
(class template) [edit]
allows an object to create a shared_ptr referring to itself
(class template) [edit]

[edit] Example