Skip to content

Instantly share code, notes, and snippets.

@rowanj
Last active December 12, 2015 03:58
Show Gist options
  • Save rowanj/4710388 to your computer and use it in GitHub Desktop.
Save rowanj/4710388 to your computer and use it in GitHub Desktop.
#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));
}
}
@rowanj
Copy link
Author

rowanj commented Feb 4, 2013

These could return the boost::signals2::connection returned by the connect( ) method if you want to be able to disconnect from the callee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment