Created
July 21, 2018 05:02
-
-
Save kvk1920/78ac415c44cd4a042e13bd9bab42a79d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "sigslots.h" | |
using namespace std; | |
template <bool First = true, typename T, typename ...Args> | |
void Log(const T& t, const Args& ...args) { | |
cerr << t << ' '; | |
if constexpr (sizeof...(args)) | |
Log<false>(args...); | |
if constexpr (First) | |
cerr << endl; | |
}; | |
struct Class { | |
int x, y; | |
void X() { Log(x); } | |
void Y() { Log(y); } | |
}; | |
int main() { | |
Class x1y1, x2y3; | |
x1y1.x = x1y1.y = 1; | |
x2y3.x = 2; x2y3.y = 3; | |
signal<> sig; | |
sig.connect(&x1y1, &Class::X); | |
sig.emit(); | |
sig.connect(&x1y1, &Class::Y); | |
sig.disconnect(&x1y1, &Class::X); | |
sig.emit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment