Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-12-18 07:44:29


Hello Larry,

thank you for your positive review.

Larry Evans wrote:
> On 12/17/07 04:22, John Torjo wrote:
> > Hi all,
> >
> > Today starts the formal Fast-Track review of the
> > Boost.Functional/Factory library.
>
> [snip]
>
> > What to include in Review Comments
> > ==================================
> >
> [snip]
>
> > * What is your evaluation of the documentation?
>
> Good, however, it should include some hint about how to overcome
> the Lvalue constraint on the arguments that's mentioned in the
> docs:

Yes good point. It should mention there's Functional/Forward (I think I
left it out because I didn't know whether Forward was going to be
accepted into Boost).

>
> > * What is your evaluation of the potential usefulness of the
> > library?
>
> Very. I'm thinking it could be used as a replacement for Abraham's
> new_ as shown in the attachment to:
>
> http://lists.boost.org/Archives/boost/2007/12/131251.php
>
> I think it could also be used for similar factories which, for
> example, want to decorate the source object with some hidden features,
> e.g. a refcount. The containing smart_ptr would know about that and
> somehow retrieve it and avoid the extra overhead of a detached
> refcount as in, for example, shared_ptr.

I'm not sure that I completely understand your suggestion.

However it sounds like something that's probably implemented by (or at
least easily implementable with) Joaquin M. Lopez' Flyweight library.

In case you don't need state in the factory itself, you might get away
with something like

     map< string, function< smart_ptr1<T>(args) > > factories;
     // ...
     factories["foo"] = factory< smart_ptr2<U> >();
     factories["bar"] = factory< smart_ptr2<V> >();

given conversion sequences

     smart_ptr1<U> --> smart_ptr2<U>
     smart_ptr1<V> --> smart_ptr2<V>

.

Regards,
Tobias


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