我正在尝试使用boost :: bind将curried函数链接在一起,并获得无法解决的编译器错误.我可以做的最简单的例子,无法编译:
#include <iostream>
#include <boost/bind.hpp>
class A
{
public:
template <typename F>
void g(F fn, char c)
{
fn(c);
}
void h(char c)
{
std::cout << c << std::endl;
}
template <typename F>
void f(F fn, char c)
{
boost::bind(&A::g<F>, this, fn, ::_1)(c);
}
};
int main(int argc, char** argv)
{
char c = 'a';
A a;
a.f(boost::bind(&A::h, &a, ::_1), c);
}
Run Code Online (Sandbox Code Playgroud)
失败并出现此错误:
In file included from /usr/include/boost/bind.hpp:22,
from test8.cpp:2:
/usr/include/boost/bind/bind.hpp: In member function ‘void boost::_bi::list3<A1, A2, A3>::operator()(boost::_bi::type<void>, …
Run Code Online (Sandbox Code Playgroud)