| Home | Libraries | People | FAQ | More

## Macro BOOST_COMPUTE_FUNCTION

BOOST_COMPUTE_FUNCTION

## Synopsis

    // In header: <boost/compute/function.hpp>

    BOOST_COMPUTE_FUNCTION(return_type, name, arguments, source)

## Description

Creates a function object with `name` and `source`.

The function declaration and signature are automatically created using the `return_type`, `name`, and `arguments` macro parameters.

The source code for the function is interpreted as OpenCL C99 source code which is stringified and passed to the OpenCL compiler when the function is invoked.

For example, to create a function which squares a number:

    BOOST_COMPUTE_FUNCTION(float, square, (float x),
    {
        return x * x;
    });

And to create a function which sums two numbers:

    BOOST_COMPUTE_FUNCTION(int, sum_two, (int x, int y),
    {
        return x + y;
    });

See Also: BOOST_COMPUTE_CLOSURE()

Parameters: |
`arguments` | A list of arguments for the function.
`name` | The name of the function.
`return_type` | The return type for the function.
`source` | The OpenCL C source code for the function.