Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost] [review][constrained_value] compile-time lambdas
From: Stjepan Rajko (stjepan.rajko_at_[hidden])
Date: 2008-12-12 01:58:43


On Thu, Dec 11, 2008 at 6:00 PM, Gordon Woodhull <gordon_at_[hidden]> wrote:
>
> I was hoping that we will also be possible to specify lambdas at compile
> time, which is more efficient because boost::function incurs cost equivalent
> to a virtual method call (it prohibits inlining and dereferences a pointer).
> And there is the cost of storing the function pointer too...
>
> I am imagining things like constrained_value<int, decltype(_1>0 &&
> !bind(isnan,_1))>.
>
> In my perfect imaginary world this would be a zero-size predicate which is
> default constructable because it carries no data. Thus the expression
> doesn't need to be duplicated on construction and is stored entirely in the
> constrained_value typedef.
>
> 0 might have to be construct<mpl::integral_c<0> >() :-D
>
> I'm sure there are 1000 things wrong with this, just fantasizing... I guess
> this also falls into the bin of "what's the perfect predicate library?"

I was able to do something like this with phoenix:
http://thread.gmane.org/gmane.comp.parsers.spirit.general/12018

There were some challenges, but what did work worked nicely.

Stjepan


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