Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost] [review][constrained_value] compile-time lambdas
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2008-12-11 20:00:13


>> I guess we have to wait for decltype to be able to use lambda
>> expressions as predicates here?
>
> Why? There are already examples with lambda predicates in the docs.

Yes, constrained_value does support lambdas at runtime using runtime
boost::function.

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?"


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