How to bind plus<int> and make calculation in C++

1 Answer

0 votes
#include <iostream>
#include <functional>

using std::cout;
using std::endl;

int main()
{
	auto plus5 = std::bind(std::plus<int>(), std::placeholders::_1, 5);
	
	cout << plus5(8) << endl; // 5 + 8
}

/*
run:

13

*/

 



answered Jan 25, 2018 by avibootz
edited Jan 25, 2018 by avibootz
...