File: sharedarrays.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (12 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
The tt(shared_ptr) class can also be used to handle dynamically allocated
arrays of objects. To use it on arrays simply use the square brackets when
specifying the tt(shared_ptr's) type. Here is an example:
    verbinclude(//code examples/sharedarray.cc)

When the tt(shared_ptr) itself is initialized with an array of pointers, then
a em(deleter) must be used to delete the memory the pointers point at. In that
case the deleter is responsible for returning the memory to the common pool,
using tt(delete[]) when eventually deleting the array of pointers:
    verbinclude(//SHAREDARRAY examples/sharedarray2.cc)