
Marco Costalba wrote:
Indeed in the above link I fail to see the mapping framework between class identifiers and actual creators/factories for that class, or put in other words I don't see the dispatcher.
It's not there, because it's just trivial to implement with what we already have in Boost and the standard library (as shown in the previous post) e.g. using 'std::map' for the mapping and 'boost::function' for the type erasure. See http://www.sgi.com/tech/stl/Map.html http://www.boost.org/doc/html/function.html
A similar approach could be done with http://dispatcher.sourceforge.net/ -- only this time it's not required that the function registered is a "factory". It could very well be any function registered.
Same with the code I posted. The factories are just adapters to make a construction expressions first-class function objects which are then type-erased and stored in 'boost::function's... So it seems a 'dispatcher<Key,Sig>' is pretty much like a 'std::map<Key,boost::function<Sig> >' ;-). Regards, Tobias