Search code examples
c++boostboost-function

Invoking a boost::function through boost::function_base


I have an unordered_map of functions that should be called on an object when an XML file is parsed.
I have found that boost::function has a base class named boost::function_base, however as expected I cannot invoke it because I don't have the signuture of the function.
Since all of those functions are setter functions, I can guarantee that they return void and have only one parameter of an unknown type.
Is there any better way to resolve the type other then an if-else-if branch which I am trying to avoid?


Solution

  • Use a boost::variant is the best way to go. How could you possibly invoke a function with an unknown parameter type, anyway?