Skip to content

Instantly share code, notes, and snippets.

@kvk1920
Created July 21, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvk1920/78ac415c44cd4a042e13bd9bab42a79d to your computer and use it in GitHub Desktop.
Save kvk1920/78ac415c44cd4a042e13bd9bab42a79d to your computer and use it in GitHub Desktop.
#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