Changed auto_ptr to shared_ptr due to deprecation