C++11: reference_wrapper

Look at this piece of code:

#include <iostream>
#include <functional>

using namespace std;
using namespace std::placeholders;

void add(int a, int b, int& r)
{
	r = a + b;
}

int main()
{
	int result = 0;
	
	auto f = bind(add, _1, 20, result);
	
	f(80);
	
	cout << result << endl;
	return 0;
}

Continue reading “C++11: reference_wrapper”

Advertisements