#include <functional>
#include <map>
#include <string>
#include <iostream>
int add(int i, int j) { return i +j; }
struct divide {
int operator()(int denominator, int divider) {
return denominator / divider;
}
};
int main()
{
auto mod = [](int i, int j) { return i %j; };
std::map<std::string, std::function<int (int, int)> > binops = {
{"+", add},
{"-", std::minus<int>()},
{"*", [](int i, int j){ return i * j; }},
{"/", divide()},
{"%", mod},
};
std::cout << "16 + 4 = " << binops["+"](16, 4) << std::endl;
std::cout << "16 - 4 = " << binops["-"](16, 4) << std::endl;
std::cout << "16 * 4 = " << binops["*"](16, 4) << std::endl;
std::cout << "16 / 4 = " << binops["/"](16, 4) << std::endl;
std::cout << "16 % 4 = " << binops["%"](16, 4) << std::endl;
return 0;
}