std::bind 用法

#include <string>
#include <functional>
#include <iostream>
using namespace std;

class Worker
{
public:
	static Worker* Get()
	{
		static Worker ff;
		return &ff;
	}

	string Process(string& data)
	{
		printf("%s\n", data.c_str());
		return "welcom";
	}
private:
	Worker();
	~Worker();
};

Worker::Worker()
{
}

Worker::~Worker()
{
}

int main()
{
	string data("hello world");	
	auto f = std::bind(&Worker::Process, Worker::Get(), std::placeholders::_1);    
	cout<<f(data)<<endl;	
	return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章