関数オブジェクト(AuthenticateNotifyFunc)が渡されることを期待しているc ++関数があります:
class lc_Authenticate
{
public:
typedef enum {
kAbort,
kContinue
} lc_AuthenticateStatus;
typedef std::tr1::function<lc_AuthenticateStatus (const string &msg)> AuthenticateNotifyFunc;
bool Authenticate(lc_AuthenticateParams ¶ms,
AuthenticateNotifyFunc notifyFunc);
}
マネージ C++ プロジェクト内で、上記の関数に渡すパラメーターを定義しようとしています。
public ref class Form1 : public System::Windows::Forms::Form
{
public:
lc_Authenticate::lc_AuthenticateStatus UpdateStatus(const string &msg)
{
<<DO SOMETHING>>
return(lc_Authenticate::kContinue);
}
void test()
{
string appKey, appSecret;
appKey = GetString(this->appKeyTextBox->Text);
appSecret = GetString(this->appSecretTextBox->Text);
lc_Authenticate dbauth;
lc_AuthenticateParams params(appKey, appSecret);
// DOESN'T COMPILE won't let me take address of member function
// or know about _1
lc_Authenticate::AuthenticateNotifyFunc func =
std::tr1::bind(&Form1::UpdateStatus, this, _1);
dbauth.Authenticate(params, func);
}
};
そのため、渡された関数が静的関数であるかメンバー関数であるかを気にしないように、関数を C++ メソッドに渡す汎用メソッドを実装しようとしています。そして、マネージコードからこれを行う方法がわかりません。