Saturday 15 September 2012

c++ - boost member function pointers -


I am very new to boost libraries.

I was trying to achieve something for a graphical program

I wanted to complete it without having some fixed global class object.

To explain in code:

/ P>

  class callback holder {public: zero dostf (zero) {// etc}}}; Zero bind () {glutIdleFunc ((new callback holder ()) - & gt; dustff); }   

I know that boost: this is possible through the use of the Tie and Promotion :: Function.

An issue that I saw, though was boosting: Work back to the normal function pointer.

How will you complete it?

You do not convert from a normal function pointer to boost :: function You can not change from a member function pointer to a normal function pointer. There are measures for accepting callback, where you can provide user data.

Unfortunately the misleading interface does not allow you to provide user data. This means that you are stuck with the worst solution, using a global variable and a common task.

  class callback holder {public: dostf (zero) without {// etc}}}; Callback holder * g_callbackHolder = NULL; Zero call_callback_holder (zero) {if (g_callbackHolder) g_callbackHolder-> Dustf (); } Zero bind () {g_callbackHolder = new callback holder (); GlutIdleFunc (and call_callback_holder); }    

No comments:

Post a Comment