Learn R Programming

RcppXPtrUtils (version 0.1.2)

checkXPtr: Check an XPtr's Signature

Description

Check the signature (i.e., arguments and return type) of the output of cppXPtr, which is an external pointer wrapped in an object of class XPtr. If the user-supplied C++ function does not match the signature, the wrapper throws an informative error.

Usage

checkXPtr(ptr, type, args = character(), call. = TRUE)

Arguments

ptr

an object of class XPtr compiled with cppXPtr.

type

the return type.

args

a list of argument types.

call.

logical, indicating if the call should become part of the error message.

See Also

cppXPtr

Examples

Run this code
# NOT RUN {
# takes time to compile
ptr <- cppXPtr("double foo(int a, double b) { return a + b; }")
checkXPtr(ptr, "double", c("int", "double")) # returns silently
try(checkXPtr(ptr, "int", c("double", "std::string"))) # throws error
# }

Run the code above in your browser using DataLab