[aspectc-user] construction advice

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Fri May 20 09:02:43 CEST 2005


Hi,

Adolfo Gustavo Serra Seca Neto wrote:
> Hi,
> 
> Is it possible to change the object "returned" by a constructor?
> 
> Suppose there is the following base code:
> 
> Formula *f1 = new Formula("A");
> Formula *f2 = new Formula("A");
> 
> I want an aspect such that f1==f2. This is related to the Flyweight 
> pattern.
> Is this possible?
> 
> Thanks in advance,
> 
> Adolfo Neto

you could use an introduction to insert an 'operator new()' into Formula.

If the class already has a new operator an execution advice (around 
advice without tjp->proceed()) would do the job.

Note that in the current version of AspectC++ you have to chance to 
check whether the class already has a new operator or not.

I hope this helps,

Olaf



More information about the aspectc-user mailing list