lundi 2 mars 2015

about the type of raw pointer inside unique_ptr

I read the book [The C++ Standard Library Second Edition] and found the section below:



namespace std {
template <typename T, typename D>
class unique_ptr<T[], D>
{
public:
typedef ... pointer; // may be D::pointer
typedef T element_type;
typedef D deleter_type;
...
};
}


The element type T might be void so that the unique pointer owns an object with an unspecified type, like void* does. Note also that a type pointer is defined, which is not necessarily defined as T*. If the deleter D has a pointer typedef, this type will be used instead. In such a case, the template parameter T has only the effect of a type tag, because there is no member as part of class unique_ptr<> that depends on T; everything depends on pointer. The advantage is that a unique_ptr can thus hold other smart pointers.


I still cant not understand the purpose of "everything depends on pointer" after i reading this section.Is there anyone could provide some samples kindly?Thanks.


Aucun commentaire:

Enregistrer un commentaire