Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Storing an Expression Template as a Data Member
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2011-01-08 09:06:12


Hi Eric,

> > Does the fact that I store formula_ by value (as in
> line ***) shoot the trouble of dangling references?
>
> No, the problem still exists. You're storing the outer-most node by
> value, but all the inner nodes (temporary objects constructed while
> building the expression) are held by reference. At the very least, the
> constructor of MyClass needs to pass the incoming expression through
> deep_copy.

So, what about the following?

#define DEFINE_MY_CLASS(name, exp) \
MyClass<result_of::deep_copy<BOOST_TYPEOF(exp)>::type> name(deep_copy(exp))

> That article takes a sequence of function calls and turns them into a
> single callable object. You're taking a sequence of function calls and
> are turning them into a callable object.

I see. OK, so you're basically saying that the >> syntax can be avoided and that we can use simple function object composition instead with no need for Protofication. In that case, I need to say that this >> syntax is just a part of the larger syntax which fits very naturally to the application I'm developing for.

Thanks a lot. :)
--Hossein


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net