我试了一下
{
std::function<void(int)> push;
queue<int> myqueue;
push = std::bind(static_cast<void (queue<int>::*)(int)>(&queue<int>::push), &myqueue,std::placeholders::_1);
push(8);
}
但这是行不通的
更简单的方法是使用一个lambda函数
{
queue<int> myqueue;
auto push = [&myqueue](int param) { myqueue.push(param); };
push(8); // myqueue - should be still reachable as it's captured by reference into a lambda capture lust
}