I'm not sure of the best way to describe this, or how to create a minimal compilable example, but I want to use these four registerCallback methods in my own templated class. Rather than create four explicit methods in my own code, I'd like to do something like this:
class MyClass
{
private:
std::unique_ptr<Synchronizer<MyPolicy>> m_sync;
public:
Connection <what goes here?>()
{
return m_sync.registerCallback(<what goes here?>);
}
// Current workaround
Synchronizer<MyPolicy> &sync() { return *m_sync; }
Synchronizer<MyPolicy> const sync() const { return *m_sync; }
};
Usage would be something like:
std::unique_ptr<MyClass> sync = std::unique_ptr<MyClass>(new MyClass);
sync->registerCallback(boost::bind(&ThisClass::thisCallback,
this, _1, _2));
My current usage is to just to call the getter:
std::unique_ptr<MyClass> sync = std::unique_ptr<MyClass>(new MyClass);
sync->sync().registerCallback(boost::bind(&ThisClass::thisCallback,
this, _1, _2));
Is there template trickery that can solve my problem? I saw this page referenced in another question, but things seem to be complicated by the Synchronizer class having the copy constructor = delete.
Aucun commentaire:
Enregistrer un commentaire