Boost logo

Boost :

From: Maurizio Vitale (mav_at_[hidden])
Date: 2007-05-23 09:47:09


Eric Niebler <eric_at_[hidden]> writes:

> Well, it's not ideal for that because it requires a runtime function
> call. But then again, so do proto's operator overloads. This is the sort
> of thing where you would want to leverage the POD-ness of proto's expr<>
> type. Consider:
>
> // 1 + "hello"
> proto::plus<
> proto::terminal<int>::type
> , proto::terminal<char const *>::type
> >::type const int_plus_string = {{1}, {"hello"}};
>
> This thing requires no runtime initialization. And if you peek at
> libs/xpressive/proto/test/lambda.cpp, check out the lambda<> expression
> wrapper. It shows a way to extend a proto expression type without losing
> POD-ness, so you can make the above still work.
>

I'll take a look at the lambda example again, but in this particular case I'll
probably stay with the deep_copy approach: I'll have maybe 10-20 of those expressions
and they'll be initialized at startup and I think explicit expressions make
the intent clearer.

But unless I find other problems, I'll try to make my expressions PODs. That should
be good regardless.

> If you'd rather go the deep copy route, you don't need to wait for me to
> fix proto::deep_copy(). You can accomplish the same thing with a proto
> transform. Here is some code to get you started. It deep-copies a proto
> expression, and wraps everything in a myexpr<> wrapper.

Thanks for the code. I'll use the fixed deep_copy, but it is always educational.

Regards,

        Maurizio


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk