Subject: [proto] The proper way to compose function returning expressions
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2012-04-23 16:01:43
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
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
expressions built from expression composition without incurring a huge
amount of copy ?
Proto list run by eric at boostpro.com