no suitable user-defined conversion from "std::_Binder<std::_Unforced, void (Test::*)(int p_test), Test *, int>" to "std::function<void (Test::*)(int)>" exists
だから私は間違いがどこにあるのか本当にわかりません。私は昨年の夏から関数ポインタを使用していませんでしたが、この例はstd :: functionとstd :: bindを学習していた時に元に戻りました。クラスメンバーへのC++関数ポインタ
#include <iostream>
#include <string>
#include <functional>
class Test
{
public:
void display(int p_test)
{
std::cout << p_test;
}
};
void main()
{
Test t1;
std::function<void(Test::*)(int)> test = std::bind(&Test::display, &t1, 1);
}
'std :: bind()'の代わりに 'auto'とラムダ関数を使います。 – user0042