Re: [Boost-users] [boost] [review][constrained_value] compile-time lambdas

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

On Thu, Dec 11, 2008 at 6:00 PM, Gordon Woodhull <gordon@woodhull.com> 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

From: Stjepan Rajko
I was able to do something like this with phoenix: http://thread.gmane.org/gmane.comp.parsers.spirit.general/12018
Looks good. Is BOOST_TYPEOF already supported by Lambda or Phoenix libraries? And does the type of the expression store the values used, so a default-constructed lambda is identical to the one used in BOOST_TYPEOF? Best regards, Robert
participants (3)
-
Gordon Woodhull
-
Robert Kawulak
-
Stjepan Rajko