Boost logo

Boost Users :

Subject: Re: [Boost-users] [proto] const-ness of references
From: Manjunath Kudlur (keveman_at_[hidden])
Date: 2010-03-04 00:21:12


> proto::make_expr tries to enforce uniformity in the trees it returns. In
> particular, it wants all the child nodes to be in the same domain as the
> parent node it returns. When the domains don't match (as they don't in this
> case because int32_ is in the default_domain), it passes the child through
> the domain's generator.

I follow you up to here.

> The result gets stored by value instead of by
> reference as you're requesting.

I lost you here. In my case, I pass program_() and boost::ref(a0) as
children to make_expr. My generator would match otherwise(_) rule (I
don't have it in the program I sent, but suppose I add it to
program_generator). So the result is the expression unmodified, no?
What gets stored by value, where, like you say?

> The fix is quite simple. Define int32_ as follows:
>
>  typedef proto::literal<Var<int>, program_domain> int32_;
>
> That puts it in the program_domain.

I gave this a try, and it works fine.

> Also, you should note that your generator is broken. It only handles the
> function<terminal,terminal> case. Passing any other expression to it
> violates its preconditions. You need an otherwise<_> in there.

> (BTW, I just added a default constructor to literal to make your code
> compile.)

Thanks.
Manjunath


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