
16 Nov
2007
16 Nov
'07
3:35 p.m.
Emil Dotchevski a écrit :
I'll make one last attempt... :)
Let's say I have a vector< flyweight<string> > container. Let's also assume that, based on the value of the stored string object, I want to allocate the flyweight differently. No problem, right? All I have to do is write a custom factory, and change my container's value type: vector< flyweight<string,tag<my_factory> > >. So, my_factory inspects the string value passed to it, and uses the appropriate allocation strategy.
But what if I can't hard-code the factory behavior? What if I want to allow user code to choose how each individual flyweight<string> is to be allocated?
Why not make a factory that does dynamic dispatch?