While it is true that some of the examples on this website are contrived (and I'm not an expert by any means) this particular one is based off of a real world problem that I was trying to solve. Namely: typesafe serialization of function calls for a distributed system.
In my system I have a templated function description that is utilized by both the sender and receiver to make sure that they can both stay in sync and follow code changes. A reduced example:
const char MyFunctionName="myfunction"; const char MyFunctionDescription="An example function"; //MyFunction takes to parameters, an int and a string typdef ModuleFunction<MyFunctionName, MyFunctionDescription, int, std::string> MyFunction;
At other points in the code, a remote function call can now be made:
sendMessage(target, MyFunction(5, "Hello World"));
And received:
registerHandler(MyFunction(boost::function(this, &myFunction));
Etc.
And, the more I think about it, your solution could have worked in my situation.
In retrospect, however, I think that having a single parameter of type boost::tuple and using boost::tuple serialization would have been a better bet, and saved the need for this specific code in the first place.
Recent comments
2 hours 39 min ago
2 hours 40 min ago
12 hours 53 min ago
14 hours 21 min ago
14 hours 21 min ago
14 hours 21 min ago
21 hours 38 min ago
2 weeks 3 days ago
4 weeks 4 days ago
4 weeks 4 days ago