我创建了一个shared_ptr,它在运行时错误时给了我bad_weak_ptr错误。有人知道原因吗?我该如何解决该错误?
class base:enable_shared_from_this<base> {
public:
virtual void wtf() { shared_from_this(); };//bad_weak_ptr here
};
class c1 :public base {};
using basep = shared_ptr<base>;
void main() {
basep bp = make_shared<c1>();//shared_ptr here
bp->wtf();
}