BOOST_COMPUTE_CLOSURE
// In header: <boost/compute/closure.hpp>
BOOST_COMPUTE_CLOSURE(return_type, name, arguments, capture, source)
Creates a closure function object with name
and source
.
For example, to create a function which checks if a 2D point is contained in a circle of a given radius:
// radius variable declared in C++ float radius = 1.5f; // create a closure function which returns true if the 2D point // argument is contained within a circle of the given radius BOOST_COMPUTE_CLOSURE(bool, is_in_circle, (const float2_ p), (radius), { return sqrt(p.x*p.x + p.y*p.y) < radius; }); // vector of 2D points boost::compute::vector<float2_> points = ... // count number of points in the circle size_t count = boost::compute::count_if( points.begin(), points.end(), is_in_circle, queue );
See Also:
BOOST_COMPUTE_FUNCTION()
Parameters: |
|