File: sharedptr.yo

package info (click to toggle)
c%2B%2B-annotations 10.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,536 kB
  • ctags: 3,247
  • sloc: cpp: 19,157; makefile: 1,521; ansic: 165; sh: 128; perl: 90
file content (20 lines) | stat: -rw-r--r-- 917 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 is called (cf. section ref(UNIQUEPTR)).


tt(Shared_ptr)s 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.