X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/6b6af45b9896cf5a87be2cec6239b7d254db2e10..6fb30a67f78730c733f64429f327e360ea2acaf3:/ev%20%20.h/software/libev.git/blobdiff_plain/6b6af45b9896cf5a87be2cec6239b7d254db2e10..6fb30a67f78730c733f64429f327e360ea2acaf3:/ev++.h?ds=sidebyside diff --git a/ev++.h b/ev++.h index 604340e..ac63970 100644 --- a/ev++.h +++ b/ev++.h @@ -28,6 +28,7 @@ namespace ev { ev_set_cb (static_cast(this), cb); } + // method callback template void set (K *object) { @@ -41,6 +42,7 @@ namespace ev { (obj->*method) (*static_cast(w), revents); } + // const method callback template void set (const K *object) { @@ -54,6 +56,7 @@ namespace ev { (static_cast(w->data)->*method) (*static_cast(w), revents); } + // function callback template void set (void *data = 0) { @@ -66,6 +69,20 @@ namespace ev { function (*static_cast(w), revents); } + // simple callback + template + void set (K *object) + { + set_ (object, method_noargs_thunk); + } + + template + static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) + { + K *obj = static_cast(w->data); + (obj->*method) (); + } + void operator ()(int events = EV_UNDEF) { return ev_cb (static_cast(this))