Re: [Boost-users] boost & c-style calback issue
Your approach is exactly what we don't want, since it makes it an object-based based solution rather than instance-based. We are using a functor (therefor the oprerator()) so that the solution remains instance-based.
Is your application threaded? If so couldn't you use thread_specific_ptr
for emulating a instance-based functor?
class A;
class B;
class C
{
public:
C()
{
instance().push_back(this);
}
~C()
{
instance().pop_back();
}
int operator()(A* a, B* b)
{
// Do your stuff.
}
static int wrapper(A* a, B* b)
{
return instance().back()->operator()(a, b);
}
private:
C(const C& rhs);
C& operator=(const C& rhs);
static this_vector& instance()
{
this_vector* t = ptr.get();
if (!t)
{
t = new this_vector();
ptr.reset(t);
}
return *t;
}
typedef std::vector
participants (1)
-
Anders Dalvander