File: uniquearrays.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 (19 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
When a tt(unique_ptr) is used to store arrays the dereferencing operator makes
little sense but with arrays tt(unique_ptr) objects benefit from index
operators. The distinction between a single object tt(unique_ptr) and a
tt(unique_ptr) referring to a dynamically allocated array of objects is
realized through a template specialization.

With dynamically allocated arrays the following syntax is available:
    itemization(
    it() the index (tt([])) notation is used to specify that the smart
        pointer controls a dynamically allocated em(array). Example:
            verb(unique_ptr<int[]> intArr(new int[3]);)

it() the index operator can be used to access the array's
        elements. Example:
            verb(intArr[2] = intArr[0];)

)
    In these cases the smart pointer's destructors call
tt(delete[]) rather than tt(delete).