Question

I need help with some old C++ code from/for DLL wich was written in borland c++ builder 6, I must recompile it in VS2008 or VS2010. Since all our test have shown that MSVC optimizes code more than 4 times better(for speed) then borland builder does... And our software has kind of real-time requirements. I have rewritten and/or wrapped a lot of VCL code with std or win32api functions mainly classes for AnsiString, events, threads, lists, so most of code compiles and works well ...

But I came to a barrier that I do not know how to solve alone, so I am begging you for any kind of help.

I have no clue how can I implement something which could simulate __closure keyword. I know this is borland c++ builder specific keyword and allows programmer to use generic pointer to member function. I know this is not possible in native c++, since pointer to member function isn't regular function pointer, but something like member_function_pointer=function_pointer-this. So __closure must save this and member_function_pointer. But I don't know how to achieve this. Nor how would this could be possible since classes in our code don't know each other and this would violate all principles of nice object oriented programming principles.

I am sorry for my rusty English:S Thank you for Your time and help.

Was it helpful?

Solution

Either std::bind or boost::bind should do the trick. Also see the questions "std::bind a member function to an object pointer" and "boost::bind and class member function". You may also want to look at boost::function or std::function as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top