#include <iostream>
#include <boost/bind.hpp>
struct FCall3Templ {
template<typename ARG1, typename ARG2>
ARG1 operator()(ARG1 arg1, ARG2 arg2) {
return arg1+arg2;
}
};
int main() {
boost::bind<int>(FCall3Templ(), 45, 56)(); // call 1
boost::bind<double>(FCall3Templ(), 45.0, 56.0)(); // call 2
return 0;
}
I'm posting the same code that you can find here .
I'm relatively new to meta-programming, boost::bind and operator overloading, but i don't get get what this code does in some portion of the code and i have this questions:
- why using
operator()
without specifying the label for that operator? What is overloading/defining? - how i'm supposed to catch and store the value returned by the 2 calls using an assignment with
T var = ?
? - what does it mean the fact that the last
()
is empty in both calls ? Is the call for the operator? So what is the name for this technique/operator? - why using the operator overloading this way and not using just a method?
Thanks.