File: sharedptr.yo

package info (click to toggle)
c%2B%2B-annotations 11.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,952 kB
  • sloc: cpp: 20,008; makefile: 1,502; ansic: 165; sh: 121; perl: 90
file content (20 lines) | stat: -rw-r--r-- 945 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
In addition to the class tt(unique_ptr) the class
hi(shared_ptr)tt(std::shared_ptr<Type>) is available, which is a reference
counting smart pointer.

Before using tt(shared_ptrs) the tthi(memory) header file must be included.

The shared pointer automatically destroys its contents once its reference
count has decayed to zero. As with tt(unique_ptr), when defining a
tt(shared_ptr<Base>) to store a newly allocated tt(Derived) class object, the
returned tt(Base *) may be cast to a tt(Derived *) using a tt(static_cast):
polymorphism isn't required, and when resetting the tt(shared_ptr) or when the
tt(shared_ptr) goes out of scope, no slicing occurs, and tt(Derived)'s
destructor (or, if configured: deleter) is called (cf. section
ref(UNIQUEPTR)).

tt(Shared_ptrs) support copy and move constructors as well as standard and
move overloaded assignment operators.

Like tt(unique_ptrs, shared_ptrs) may refer to dynamically allocated arrays.