[proto] Deep copy question
Hello,
I define the copy constructor for my class and print out out a message
when it is called. See the following program. When I have
"proto::terminal::type a", and try to call
BOOST_PROTO_AUTO(pr, a), I see that the copy constructor is called two
times. Why is the object getting copied twice during the deep copy?
When I have "proto::literal a", I see that the copy
constructor is getting called twice during the declaration of 'a'
itself, and twice when I try to call BOOST_PROTO_AUTO(pr, a). I was
under the impression that objects are held by reference inside
expressions. Why are they copied twice in the proto::literal case?
Actually, I am looking for some advice on the following: I know that
when I have proto::terminal, the underlying object is
created once, and held by reference *everywhere* it is appears in a
large complex expression. But as soon as I try to do a deep_copy of
the expression (as in BOOST_PROTO_AUTO), the underlying object is
copied once for *every* appearance in the expression. How do I make it
such the underlying object doesn't copied many times? I want to have
the copied expression also to have the property that the original
expression had, i.e., everywhere an underlying object is referenced,
they all refer to the same object. I will be grateful for any advice.
#include
On Fri, Mar 5, 2010 at 7:14 PM, Manjunath Kudlur
Actually, I am looking for some advice on the following: I know that when I have proto::terminal, the underlying object is created once, and held by reference *everywhere* it is appears in a large complex expression. But as soon as I try to do a deep_copy of the expression (as in BOOST_PROTO_AUTO), the underlying object is copied once for *every* appearance in the expression. How do I make it such the underlying object doesn't copied many times? I want to have the copied expression also to have the property that the original expression had, i.e., everywhere an underlying object is referenced, they all refer to the same object. I will be grateful for any advice.
Oops, I just discovered this question has been asked before in this list. Please ignore.. Manjunath
participants (1)
-
Manjunath Kudlur