diff --git a/test_class_static_delegate.cpp b/test_class_static_delegate.cpp new file mode 100644 index 0000000..cbd7267 --- /dev/null +++ b/test_class_static_delegate.cpp @@ -0,0 +1,34 @@ +#include "delegate.h" +#include + +class Local +{ +public: + Local() = default; + + static Delegate s_d; + + void do_something() { s_d(1, 2); } +}; + +Delegate Local::s_d; + +static void s_lb(int a, int b) { std::cout << (a + b) << std::endl; } + +class Library_Bind +{ +public: + Library_Bind() { Local::s_d.add(s_lb); } +}; + +int main(int argc, char **argv) +{ + Local *l = new Local; + Library_Bind *lb = new Library_Bind; + + l->do_something(); + + Local::s_d.remove(s_lb); + + return 0; +}