Reply to comment

Yeah, good point

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.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post PHP code. You should include <?php ?> tags.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.