[announce] Dynamic object factory v3

Yet another object factory announce! Sorry to announce another version, but I think "this is the last one" (tm) ;-) Small, easy to read, self-contained, feature complete, compiler friendly, and really really nice (at least for my coding style taste). I spent a lot of time polishing this toy. IMHO could be an example of C++ template programming for beginners/intermediate users. Interested people could find it in boost vault under the name factory_24_2_08.zip, of course any feedback is welcomed. Thanks for your attention Marco

Marco Costalba wrote:
Yet another object factory announce!
Sorry to announce another version, but I think "this is the last one" (tm) ;-)
Small, easy to read, self-contained, feature complete, compiler friendly, and really really nice (at least for my coding style taste).
I spent a lot of time polishing this toy. IMHO could be an example of C++ template programming for beginners/intermediate users.
Interested people could find it in boost vault under the name factory_24_2_08.zip, of course any feedback is welcomed.
Thanks for your attention Marco _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hi Marco. Very nice little toy. I promptly implemented it in one of my own inheritance hierarchies, and it works out of the box. Nice! I don't deal in raw pointers in application code though (well, if I can avoid it), so I added methods to the dispatcher template to return shared_ptrs instead. get_shared_by_key was the name I hacked up. But like I said; very nice little toy! :-) /Brian Ravnsgaard Riis

On Sun, Feb 24, 2008 at 9:34 PM, Brian Ravnsgaard Riis <brian@ravnsgaard.net> wrote:
I don't deal in raw pointers in application code though (well, if I can avoid it), so I added methods to the dispatcher template to return shared_ptrs instead. get_shared_by_key was the name I hacked up.
Hi Brian, thanks for your words. Actually the choice to mimic a standard operator new is mainly due to - Keep it simple and with well known behaviour, as a toy should be - Do not impose a choice on a particular smart pointer, but let the user wrap the returned pointer in his/her preferred one. Of course the smart pointer class could be passed in as a template parameter, but this complicates the implementation and so goes against one of my main goals with this factory. Marco

on Sun Feb 24 2008, "Marco Costalba" <mcostalba-AT-gmail.com> wrote:
On Sun, Feb 24, 2008 at 9:34 PM, Brian Ravnsgaard Riis <brian@ravnsgaard.net> wrote:
I don't deal in raw pointers in application code though (well, if I can avoid it), so I added methods to the dispatcher template to return shared_ptrs instead. get_shared_by_key was the name I hacked up.
Hi Brian,
thanks for your words.
Actually the choice to mimic a standard operator new is mainly due to
- Keep it simple and with well known behaviour, as a toy should be
- Do not impose a choice on a particular smart pointer, but let the user wrap the returned pointer in his/her preferred one. Of course the smart pointer class could be passed in as a template parameter, but this complicates the implementation and so goes against one of my main goals with this factory.
You should return std::auto_ptr, which -- unlike shared_ptr -- doesn't impose any permanent choice but is also safe. -- Dave Abrahams Boost Consulting http://boost-consulting.com

On Thu, Mar 13, 2008 at 2:37 AM, David Abrahams <dave@boost-consulting.com> wrote:
You should return std::auto_ptr, which -- unlike shared_ptr -- doesn't impose any permanent choice but is also safe.
Thanks for your suggestion, I will change that probably with an additional code simplification that I've found as soon as I have finished with extending the other toy I posted (Multi-signature overload function) to support pointer-to-member function. The patch I've added seems already to work, so I would think it's almost ready modulo some extensive testing. Marco
participants (3)
-
Brian Ravnsgaard Riis
-
David Abrahams
-
Marco Costalba