#include <atomic>
#include <functional>
class ParserBase {
public:
virtual void Process () = 0;
}; // class ParserBase
class Base {
public:
Base();
void SetRuning(bool running){
running_.store(running);
}
void Process() {}
private:
class InnerBase : public ParserBase {
public:
InnerBase() = delete;
InnerBase(Base* runer) : runer_(runer) {}
void Process() override { runer_->Process();}
private:
Base* runer_ = nullptr;
} inner_base_;
private:
std::atomic<bool> running_{false};
}; // class Base
Base::Base():inner_base_(this) {
auto other_set_running_function = std::bind(&Base::SetRuning, this, std::placeholders::_1);
ParserBase* parser = &inner_base_;
}
int main() {
Base base;
return 0;
}
InnerClass
最新推荐文章于 2024-08-16 23:08:28 发布