Hi,
in my code the class CFactory has a non-type template parameter TStaticMemberFct which is a static function of a different class that should get called when Wrapper() is called via a CInterruptDelegate object.
But it seems that Wrapper() gets already called when it is passed as the CInterruptDelegate constructor argument. Is there a way to avoid this?

CFactory:

template<void (*TStaticMemberFct)()>
class CFactory
{
  private:
    static void Wrapper(void* object)
    {
      TStaticMemberFct();
    }

  public:
    static CInterruptDelegate Bind()
    {
      return CInterruptDelegate(&CFactory::Wrapper, 0);
    }
};
class CInterruptDelegate 
{ 
  public:
    typedef void (*typeFctPtr)(void*);

    CInterruptDelegate(typeFctPtr f_tfnWrapper, void* f_pvSubscriber) 
      : m_tfnWrapper(f_tfnWrapper), m_pvSubscriber(f_pvSubscriber) 
    {
    }

    void operator () () const
    {
      (*m_tfnWrapper)(m_pvSubscriber);
    }

    void IsrCall(void)
    {
      (*m_tfnWrapper)(m_pvSubscriber);
    }

  private:
    typeFctPtr m_tfnWrapper;
    void* m_pvSubscriber;
};

Thanks in advance,
Mirco

I don't have that problem at all using your classes. Can you post a complete program that exhibits the issue?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.