Last active
December 12, 2015 03:58
-
-
Save rowanj/4710388 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "Bind.hpp" | |
namespace OTR | |
{ | |
template <typename Object> | |
int objectID(Object const& object) | |
{ | |
return reinterpret_cast<intptr_t>(&object); | |
} | |
template <typename Sig, typename Func> | |
void bindID(Sig const& sig, Func func) | |
{ | |
sig.connect(OTR::bind(func, objectID(sig))); | |
} | |
template <typename Sig, typename Func, typename A1> | |
void bindID(Sig const& sig, Func func, A1 a1) | |
{ | |
sig.connect(OTR::bind(func, objectID(sig), a1)); | |
} | |
template <typename Sig, typename Func, typename A1, typename A2> | |
void bindID(Sig const& sig, Func func, A1 a1, A2 a2) | |
{ | |
sig.connect(OTR::bind(func, objectID(sig), a1, a2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These could return the
boost::signals2::connection
returned by theconnect( )
method if you want to be able to disconnect from the callee.