I was reading C++ reference and came across std::plus function with an example. Which is pretty straight forward, its simply adds lhs and rhs. The code was:
#include <functional>
#include <iostream>
int main()
{
std::string a = "Hello ";
const char* b = "world";
std::cout << std::plus<>{}(a, b) << '\n';
}
output: Hello world
I changed it to
#include <functional>
#include <iostream>
int main()
{
int a = 5;
int b = 1;
std::cout << std::plus<int>{}(a, b) << '\n';
}
output : 6
Now I made
foo vector = 10 20 30 40 50
bar vector = 11 21 31 41 51
I called:
std::transform (foo.begin(), foo.end(), bar.begin(), foo.begin(), std::plus<int>());
and it gave 21 41 61 81 101 which I understand it is adding up both foo and bar. But how it was passed to std::plus function?