Skip to content

Commit

Permalink
Create test_class_static_delegate.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlotRain authored Apr 9, 2024
1 parent 59887c3 commit 56417ac
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test_class_static_delegate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "delegate.h"
#include <iostream>

class Local
{
public:
Local() = default;

static Delegate<void(int, int)> s_d;

void do_something() { s_d(1, 2); }
};

Delegate<void(int, int)> 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;
}

0 comments on commit 56417ac

Please sign in to comment.