Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2004-02-28 09:08:52

On 02/27/2004 11:01 PM, Brian McNamara wrote:
> On Fri, Feb 27, 2004 at 09:07:10PM -0600, Larry Evans wrote:
> >
> You mentioned a couple problems with the regexp code:
>>there's a pointer from subtype to supertype and back (more memory) and
>>the virtual functions in supertype must be delegated to in the subtype
>>(more programmer time).
> So I tried to find a solution where you didn't have to write any
> call-forwarding routines, and where the delegate doesn't have to store
> a pointer back to the original object. I used inheritance to solve one
> of the problems (no more need to write a forwarding function: "C"
> inherits "f"), and used an explicit extra "self" pointer parameter to
> solve the other problem (way to "get back" to the original object) as
> well as to recover the information intrinsically lost when switching
> from member functions to function objects.
Thanks. This clears up a lot.
> Now "C" can change the "object delegated to" just by assigning a
> different delegate object to its own "B" subobject:
> dynamic_cast<B&>(c) = b1; // delegate to b1
> ...
> dynamic_cast<B&>(c) = b2; // delegate to b2
But doesn't this copy b2's "values" into c's B part; hence,
c doesn't really delegate to b2. Adding:

   B::operator=(B const& b_){ f=b_.f;}

and running will show, I think, that c doesn't delegate to
b2 after the above assignment.
> That said, I admit I didn't look very carefully at the regexp code, so
> I may be missing some important aspect/intention of what you want to
> do with all of this. So let me know, both if my explanation above
> clarified what I was trying to do, and if it does or does not
Yes it does. Thanks again.
> accomplish what you're seeking.
No :( . The problem I'm trying to solve involves a "Dual Inheritance
Heirarchy" ( )
but avoids copying the whole tree by just copying a single pointer
to the root of the tree (as done by regexp_first_constructor )
but also applying a similar transformation to all the children
as done by, for example:


Maybe there's an existing design pattern for this, but I haven't yet
seen it or don't yet recognize it. However, there are near
matches, e.g. the intelligent children
( ).
This maybe an exact match, but I need more time to understand it
and my requirements to see the difference, if any.

Boost list run by bdawes at, gregod at, cpdaniel at, john at