在使用shared_ptr时跑到报错terminate called after throwing an instance of 'std::bad_weak_ptr
我的类名是这样的class CRtpInstance :public std::enable_shared_from_this<CRtpInstance>,记得使用enable_shared_from_this要用public继承,但这不是报错的原因
是因为使用shared_from_this()时,this指针不是shared_ptr,应该先保证自己是shared_ptr才调用
例子:
shared_ptr<CRtpInstance > temp = make_shared<CRtpInstance >();
funExample(shared_from_this());