The operator void*
function is a type casting function, so you can write:
smart_ptr foo;
void* ptr = foo; // The compiler will call `operator void*` here
or even
if( foo) { // `operator void*` called to test boolean expression
//...
}
The functions
const T& operator*() const;
const T* operator->() const;
are const
, so you can call them on a const smart_ptr
. Because they return pointer/reference
to const
object, this object can't be changed.