Boost logo

Boost :

Subject: [boost] [compute] Define user functions using lambda expressions
From: Asbjørn (lordcrc_at_[hidden])
Date: 2014-12-22 16:54:39


Hi,

I'm probably missing something obvious, but how would I go about making a custom
function using a lambda expression? Say I want to declare some function "sqr"
which returns "_1 * _1", and then use this in a transform() lambda expression, ie

   transform(..., 2.0 * sqr(_1) - 3.0 * _1 + 5.0, ...);

to evaluate 2x^2 - 3x + 5.

If I try to use BOOST_COMPUTE_FUNCTION() I can't use the resulting function in a
lambda expression it seems.

Cheers
- Asbjørn


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