Extract shared_ptr related operations as base tempalte class.