[Proto] Computing type in expression

I have an expression wrapper class tied to a domain and a grammar. Everythign works ok except for the fact it seems I can't compute type inside the expression class that depends on the expression type itself. I end up with tons of incomplete type error in proto/fusion.hpp. The example is a bit big, i'm still working on a small repro but basically, what I do is using the expression framework from ym last mail is to have a value_type on expression which represent the value_type of the expression element. Regards

On 6/15/2010 8:49 AM, joel falcou wrote:
I have an expression wrapper class tied to a domain and a grammar. Everythign works ok except for the fact it seems I can't compute type inside the expression class that depends on the expression type itself. I end up with tons of incomplete type error in proto/fusion.hpp.
The example is a bit big, i'm still working on a small repro but basically, what I do is using the expression framework from ym last mail is to have a value_type on expression which represent the value_type of the expression element.
template<class Expr> struct wrap : proto::extends<Expr, wrap<Expr> > { // Expr is complete here // wrap is not typedef typename some_fun<wrap>::type value_type; // NO typedef typename some_fun<Expr>::type value_type; // YES }; Does that help? -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
template<class Expr> struct wrap : proto::extends<Expr, wrap<Expr> > { // Expr is complete here // wrap is not
typedef typename some_fun<wrap>::type value_type; // NO typedef typename some_fun<Expr>::type value_type; // YES };
Does that help?
Makes perfect sense, feel a bit stupid now :E I will try to get that working out ;) Thanks for the head up

On 6/15/2010 9:17 AM, joel falcou wrote:
Eric Niebler wrote:
template<class Expr> struct wrap : proto::extends<Expr, wrap<Expr> > { // Expr is complete here // wrap is not
typedef typename some_fun<wrap>::type value_type; // NO typedef typename some_fun<Expr>::type value_type; // YES };
Does that help?
Makes perfect sense, feel a bit stupid now :E I will try to get that working out ;)
Thanks for the head up
Don't feel stupid; there are contexts in which you actually *can* use wrap in type computations within wrap itself, so it's easy to get confused. template<class Expr> struct wrap : proto::extends<Expr, wrap<Expr> > { template<struct Sig> struct result { typedef typename some_fun<wrap>::type type; //OK! }; }; The difference is that by the time result gets instantiated somewhere else in your program, wrap will be complete. This will work fine until you try to instantiate result from within wrap itself (e.g. to compute the return type of a nullary operator() overload). Then it blows up with very mysterious errors. It's tricky. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
Don't feel stupid; there are contexts in which you actually *can* use wrap in type computations within wrap itself, so it's easy to get confused.
template<class Expr> struct wrap : proto::extends<Expr, wrap<Expr> > { template<struct Sig> struct result { typedef typename some_fun<wrap>::type type; //OK! }; };
I ended with that anyway as the result_type of a NT² expression depends on how you access them as we support floating point indexing that perform linear interpolation, ranges and more. So in the end , the geenral value_type was a bad idea whiel result_of compliance was OK.
The difference is that by the time result gets instantiated somewhere else in your program, wrap will be complete. This will work fine until you try to instantiate result from within wrap itself (e.g. to compute the return type of a nullary operator() overload). Then it blows up with very mysterious errors. It's tricky I saw that :€
participants (2)
-
Eric Niebler
-
joel falcou