[Proto] Recreating an expression
Hi to all proto experts, I have a grammar whose only goal is to build a type: template <class Expr> struct ActionBuilder with an operator() which simply calls: proto::eval(Expr(),my_context); Unfortunately, I have an expression like: boost::proto::exprns_::expr<boost::proto::tag::plus,boost::proto::argsns_::list2<const A&,const B&> > And the compiler is unhappy about finding no appropriate default constructor (I suppose because of the references). deep_copy is probably not usable inside a grammar definition, so is there an easy way of getting rid of the references (if they are really the problem) or do I have to go and get my MPL canon? I am really just interested in having the recreated expression use a new instance of A and B, not the original ones. Thanks, Christophe _________________________________________________________________ Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx
christophe henry wrote:
Hi to all proto experts,
I have a grammar whose only goal is to build a type: template <class Expr> struct ActionBuilder with an operator() which simply calls: proto::eval(Expr(),my_context); Unfortunately, I have an expression like: boost::proto::exprns_::expr<boost::proto::tag::plus,boost::proto::argsns_::list2<const A&,const B&> > And the compiler is unhappy about finding no appropriate default constructor (I suppose because of the references). deep_copy is probably not usable inside a grammar definition, so is there an easy way of getting rid of the references (if they are really the problem) or do I have to go and get my MPL canon? I am really just interested in having the recreated expression use a new instance of A and B, not the original ones. I see nothing special about this expression. Can you giv soem more code and a call example.
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
christophe henry wrote:
Hi to all proto experts,
I have a grammar whose only goal is to build a type: template <class Expr> struct ActionBuilder with an operator() which simply calls: proto::eval(Expr(),my_context);
You're trying to default-construct an object containing reference data members. Yeah, that's not going to work.
Unfortunately, I have an expression like: boost::proto::exprns_::expr<boost::proto::tag::plus,boost::proto::argsns_::list2<const A&,const B&> > And the compiler is unhappy about finding no appropriate default constructor (I suppose because of the references).
proto::expr doesn't have any constructors at all. It's POD. But even if it did, you're right about the references.
deep_copy is probably not usable inside a grammar definition,
Sure it is, if you use _deep_copy (which is a typedef for proto::functional::deep_copy, an ordinary callable function object).
so is there an easy way of getting rid of the references (if they are really the problem) or do I have to go and get my MPL canon? I am really just interested in having the recreated expression use a new instance of A and B, not the original ones.
Hard to tell without more context, but I think _deep_copy is what you want in your grammar. HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (3)
-
christophe henry
-
Eric Niebler
-
joel