I have a Functor which I need to send to a function which receives a function pointer as a parameter (such as CreateThread).
Can I convert it to a static method address somehow? And if not, how can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you can’t convert a class-type object to a function pointer.
However, you can write a non-member wrapper function that calls the member function on the right instance. Many APIs, including
CreateThread, allow you to provide a pointer that it will give back to you when it calls your callback (forCreateThread, this is thelpParameterparameter). For example: