|
Proto : |
Subject: [proto] Deep copy while keeping references in terminals
From: Bart Janssens (bart.janssens_at_[hidden])
Date: 2011-07-02 19:44:55
Hello,
In the framwork I'm developing, I need to deep-copy expressions to
store them in some sort of wrapper objects. This works fine in most
cases, but when terminals are copied the value they refer to seems to
be copied as well. In the following expression, "tau" is a POD struct
with some coefficients that need to be computed, and compute_tau is a
proto terminal, where the grammar is used to give meaning to the
operator() :
compute_tau(u, tau)
The problem is that I use this tau in other expressions that are
defined later on, so every expression needs to refer to the same tau,
but it seems that after proto::deep_copy, each expression has his own
tau.
Is there an easy way around this? Note that I also like to use things
like tau.ps, with ps a double in the tau struct directly in
expressions.
Cheers,
-- Bart
Proto list run by eric at boostpro.com