Using boost::bind with __fastcall

89 views Asked by At

I have a function void __fastcall ClassName::FunctionName().

I want to create a boost function pointing to that function, using boost::bind. Is this possible? Writing boost::bind(&ClassName::FunctionName, this) gives compile error "member function must be called or its address taken".

A possible workaround is to create a wrapper function, but this is undesirable because it creates useless extra code:

void ClassName::FunctionName2(){
    FunctionName();
}
...
boost::bind(&ClassName::FunctionName2, this);
1

There are 1 answers

0
VLL On BEST ANSWER

This can be solved by enabling support for __fastcall with a macro:

#define BOOST_MEM_FN_ENABLE_FASTCALL
#include <boost/bind.hpp>

After this, boost::bind syntax works as expected.

This is a non-portable extension, and therefore not enabled by default. Boost::bind documentation.