Let's say we have a bunch of functions
like sum and sqr defined on a proto domain to return
expression of tag sum_ and sqr_ in this domain. One day we want to
make a norm2(x) function
which is basically sum(sqr(x)).
My feeling is that I should be able to write it using sqr and sum
expressions.
Alas it seems this results in dandling reference, crash and some
sad pandas.
Then I remember about proto::deep_copy but I have a worries. x is
usually a terminal
holding a huge matrix like value and I just don't want this huge
matrix to be copied.
What's the correct way to handle such a problem ? How can I build
new function returning
expressions built from expression composition without incurring a
huge amount of copy ?