Having only "something::something<....>" at our disposal it may prove difficult to provide an accurate answer. Some classes provide methods which must return pointers to some data (for example, a pointer to a dynamically allocated copy of the same instance). Some issues may arise from this:
- Must the client release the associated memory when they are done using the pointer (not all pointers point to dynamically allocated data)? Should the answer be yes, how must the client go about releasing it (free() / delete / delete / something else entirely)?
- Assuming that the associated memory must be released, the class author could provide lengthy documentation on how to go about doing this. Rather than assume the client will remember to do this (and do it even when confronted with exceptions), the class author can choose to force the usage of the RAII idiom by returning some type of smart pointer instead of the fast pointer. This way, the client can concentrate on using the resource.
Now then, assume that what is being returned is a smart pointer of some sort. A typedef helps by localizing the choice of the smart pointer type (which is a good thing).
If so, how can I directly reference what the "thing" pointer points to? Say, if I wanted to use one of SomethingElse's class functions on the SomethingElse that "thing" points to?
Again, it is difficult to say for sure without knowing the precise code, but it is likely that you are able to do what you want just as you would do it with a raw pointer:
something::SomethingElse::Ptr thing(new something::SomethingElse);
Generally it is recommended that resource handling classes also provide a method for clients to obtain access to the fast pointer. std::auto_ptr, boost::shared_ptr, boost::scoped_ptr and others name this method "get()".