shared_ptr in factory