Smart pointers also typically overload operator * as well as operator -> so that they may be used to refer to nonclass types.
除了重载operator->外,智能指针通常还重载operator *, 从而可以用它们指向不是类的类型,如下所示:
CheckedPtr ip = new int;
*ip = 12; // same as ip.operator *() = 12
(*s).draw(); // use on ptr to class, too
Smart pointers are used pervasively in C++ programming, from resource handles to STL iterators, to reference counting pointers, to wrappers around pointers to member functions, and on and on.
智能指针在C++编程中广泛使用,从资源句柄到STL迭代器,再到引用计数指针,再到围绕成员函数的指针的包装器,等等。
ref
《C++ COMMON KNOWLEDGE: ESSENTIAL INTERMEDIATE PROGRAMMING》