mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-18 10:06:54 +01:00
06e2f86bdd
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@231 f6dd340e-d3f9-0310-b409-bdd246841980
62 lines
3 KiB
Text
62 lines
3 KiB
Text
The following hi(unique_ptr: operators) operators are defined for the class
|
|
tt(unique_ptr):
|
|
itemization(
|
|
ithtq(unique_ptr<>::operator=())
|
|
(unique_ptr &unique_ptr<Type>operator=(unique_ptr<Type> &other))
|
|
(This operator will transfer the memory pointed to by the i(rvalue)
|
|
tt(unique_ptr) object to the i(lvalue) tt(unique_ptr) object using em(move
|
|
semantics). So, the rvalue object em(loses) the memory it pointed at, and
|
|
turns into a 0-pointer.)
|
|
ithtq(unique_ptr<>::operator bool() const)
|
|
(unique_ptr &unique_ptr<Type>operator bool() const)
|
|
(This operator returns tt(false) if the tt(unique_ptr) does not point
|
|
to memory (i.e., its tt(get()) member, see below, returns 0). Otherwise,
|
|
tt(true) is returned.)
|
|
ithtq(unique_ptr<>::operator*())
|
|
(Type &unique_ptr<Type>operator*())(This operator returns a reference to
|
|
the information stored in the tt(unique_ptr) object. It acts like a normal
|
|
pointer i(dereference) operator.)
|
|
ithtq(unique_ptr<>::operator->())
|
|
(Type *unique_ptr<Type>operator->())(This operator returns a pointer to
|
|
the information stored in the tt(unique_ptr) object. Through this operator
|
|
members of a stored object can be selected. For example:
|
|
verb(
|
|
unique_ptr<string> sp(new string("hello"));
|
|
|
|
cout << sp->c_str() << endl;
|
|
)
|
|
)
|
|
)
|
|
The following i(member functions) are defined for tt(unique_ptr) objects:
|
|
itemization(
|
|
ithtq(unique_ptr<>::get())(Type *unique_ptr<Type>::get())(This member does
|
|
the same as tt(operator->()): it returns a pointer to the information stored
|
|
in the tt(unique_ptr) object. This pointer can be inspected: if it's zero the
|
|
tt(unique_ptr) object does not point to any memory. This member cannot be used
|
|
to let the tt(unique_ptr) object point to (another) block of memory.)
|
|
|
|
ithtq(unique_ptr<>::get_deleter())
|
|
(Deleter &unique_ptr<Type>::get_deleter())(This member returns a
|
|
reference to the i(deleter class) object used by the tt(unique_ptr).)
|
|
|
|
ithtq(unique_ptr<>::release())(Type *unique_ptr<Type>::release())
|
|
(This member returns a pointer to the information stored in the
|
|
tt(unique_ptr) object, which loses the memory it pointed at (and changes into a
|
|
i(0-pointer)). The member can be used to transfer the information stored in
|
|
the tt(unique_ptr) object to a plain tt(Type) pointer. It is the
|
|
i(responsibility of the programmer) to i(delete) the memory returned by this
|
|
member function.)
|
|
|
|
ithtq(unique_ptr<>::reset())(void unique_ptr<Type>::reset(Type *))
|
|
(This member may also be called em(without) argument, to delete the
|
|
memory stored in the tt(unique_ptr) object, or with a pointer to a
|
|
i(dynamically allocated) block of memory, which will thereupon be the
|
|
memory accessed by the tt(unique_ptr) object. This member function can
|
|
be used to assign a new hi(unique_ptr: assigning new content) block of
|
|
memory (new content) to an tt(unique_ptr) object.)
|
|
|
|
ithtq(unique_ptr<>::swap())
|
|
(void unique_ptr<Type>::swap(unique_ptr<Type> &&))
|
|
(This member is used to swap two identically typed tt(unique_ptr)s.)
|
|
|
|
)
|