cppannotations/yo/stl/uniqueplain.yo

20 lines
863 B
Text

We've already seen the third hi(unique_ptr: empty) form to create an
tt(unique_ptr) object: Without arguments an empty tt(unique_ptr) object is
constructed not pointing to a particular block of memory:
verb(
unique_ptr<type> identifier;
)
In this case the hi(unique_ptr: 0-pointer) underlying pointer is set to
tt(0) (zero). Although the tt(unique_ptr) object itself is not the pointer,
its value em(can) be compared to tt(0) to see if it has been
initialized. E.g., code like
verb(
unique_ptr<int> ip;
if (!ip)
cout << "0-pointer with a unique_ptr object" << endl;
)
will produce the shown text. Alternatively, the member
hi(unique_ptr<>::get()) tt(get()) is available. This member function,
as well as the other member functions of the class tt(unique_ptr) are
described in the next section.