Boost logo

Boost :

From: Chris Weed (chrisweed_at_[hidden])
Date: 2006-09-25 14:05:51


This sounds very interesting. I did like to try this out.
Chris

On 9/25/06, Eric Niebler <eric_at_[hidden]> wrote:
>
> Generic programming is fairly well understood. Concepts define
> requirements, types model concepts, generic code manipulates models via
> valid expressions for that concept, etc. Also pretty well understood is
> how to define customization points so that arbitrary types can be made
> to model a concept non-intrusively.
>
> But these techniques seem to break down for object construction. Consider:
>
> template< class Inner >
> struct facade
> {
> facade( /* what here? */ )
> : inner_( /* and what here? */ )
> {}
> private:
> Inner inner_;
> };
>
> How does facade know how to initialize inner_? The answer affects how
> facade itself should be initialized.
>
> One possibility is that facade defines N constructors that take up to N
> arguments, and just forwards them to inner_. That might work in this
> narrow case, but what if facade has 2 inner objects of different types?
> How should constructor arguments get dispatched to the different
> sub-objects? In general, facade has no way of knowing. Is this a problem
> others have run into? What sorts of techniques are people using?
>
> I have come up with a little generic object construction utility using
> Boost.Parameter that works for me. It allows you to non-intrusively
> associate named parameters with a type for the purpose of construction,
> and a way to forward a (possibly filtered) argument pack on to
> sub-objects. Is there general interest in such a utility?
>
> --
> Eric Niebler
> Boost Consulting
> www.boost-consulting.com
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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