CppFunction

Contents

CppFunction#

template<typename R>
FunctionHandler<CppFunctionHandler<R>> YR::CppFunction(const std::string &funcName)#

Create a FunctionHandler for invoking a C++ function by name.

// C++ function to be invoked
int PlusOne(int x)
{
    return x + 1;
}

YR_INVOKE(PlusOne);

// C++ code to invoke the function
int main(void)
{
    YR::Config conf;
    YR::Init(conf);
    auto ref = YR::CppFunction<int>("PlusOne").Invoke(1);
    int res = *YR::Get(ref);   // get 2
    return 0;
}

Template Parameters:

R – The return type of the C++ function.

Parameters:

funcName – The name of the C++ function to invoke.

Returns:

A FunctionHandler object that can be used to execute the C++ function. The return type can be accessed through the CppFunctionHandler template class.