Boost logo

Boost :

From: Stephen Torri (storri_at_[hidden])
Date: 2007-09-18 12:34:40


On Tue, 2007-09-18 at 17:07 +0200, Marco Costalba wrote:
> The 'components' in your factory are wrappers around default
> constructor, i.e. they take no arguments (this is a great way to
> simplify all the stuff ;-)
>
> So in this case a simple template could be enough:
>
> template<class T>
> static T* def_ctor_wrapper() { return new T(); }
>
> and you can instantiate it where you need without replicating all the
> 'Component* Create()' stuff inside each object.
>
> If you plan to support more then default c'tors, i.e if you plan to
> support passing arguments to your Create() functions probably you need
> to reconsider all the design, and complicate it a bit BTW ;-)
>
> I have sent to this mailing list a couple of weeks ago some examples
> of a factory that does this (and much more) in case you are
> interested.
>
> Original posted factory uses pure C++ with no libraries, I'm now
> converting it to use boost::fusion, just a way to learn myself this
> nice library.
>
> Marco

Can you send me the code example?

Stephen


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk