【发布时间】:2014-05-30 20:36:39
【问题描述】:
boost::function<void()> test_func;
struct test_t
{
boost::function<void(int)> foo_;
void test()
{
// This works as expected
test_func = boost::bind(test_t::foo_, 1);
}
};
int main(int argc, _TCHAR* argv[])
{
test_t test;
test.test();
// error C2597: illegal reference to non-static member 'test_t::foo_'
test_func = boost::bind(test_t::foo_, &test, 1);
const auto a = 0;
return 0;
}
代码有什么问题?为什么代码 test_func = boost::bind(test_t::foo_, &test, 1);在 test_t::test() 中编译并在 main() 中给出错误?
谢谢
【问题讨论】:
标签: c++ boost-bind boost-function