diff --git a/a8/a8.h b/a8/a8.h index 94a8448..9e5d599 100644 --- a/a8/a8.h +++ b/a8/a8.h @@ -49,4 +49,16 @@ struct Context \ }; \ return std::make_shared();}() +#define A8_MAKE_SMART_ANON_STRUCT_SHARED(...) \ +[] () \ +{ \ +struct Context : public std::enable_shared_from_this \ +{ \ + __VA_ARGS__; \ + std::function _destory_cb; \ + std::weak_ptr GetWp() { return shared_from_this();}; \ + ~Context() { if (_destory_cb) { _destory_cb(); };}; \ +}; \ +return std::make_shared();}() + const float A8_PI = 3.1415926f;