File: defining.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 (27 lines) | stat: -rw-r--r-- 1,394 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
20
21
22
23
24
25
26
27
There are three ways to hi(unique_ptr: defining) define tt(unique_ptr)
objects. Each definition contains the usual tt(<type>) specifier between
angle brackets:
    itemization(
    it() The default constructor simply creates a tt(unique_ptr) object that
does not point to a particular block of memory. Its pointer is initialized to
0 (zero):
        verb(unique_ptr<type> identifier;)

This form is discussed in section ref(UNIQUEPLAIN).
    it() The em(move constructor)  initializes an tt(unique_ptr) object.
Following the use of the move constructor its tt(unique_ptr) argument no
longer points to the dynamically allocated memory and its pointer data member
is turned into a zero-pointer:
        verb(unique_ptr<type> identifier(another unique_ptr for type);)

This form is discussed in section ref(UNIQUEMOVE).
    it() The form that is used most often initializes a tt(unique_ptr) object
to the block of dynamically allocated memory that is passed to the object's
constructor. Optionally ti(deleter) can be provided. A (free) function (or
function object) receiving the tt(unique_ptr)'s pointer as its argument can be
passed as deleter. It is supposed to return the dynamically allocated
memory to the common pool (doing nothing if the pointer equals zero).
        verb(unique_ptr<type> identifier (new-expression [, deleter]);)

This form is discussed in section ref(UNIQUENEW).
    )