Allow shared_ptr implementation to be selected.

Fixes #6.
Apply patch from Lars that aliases static_pointer_cast.