Rice  3.0.0
Functions
protect.hpp File Reference

A collection of functions (overloaded on number of arguments) for calling C functions that might raise Ruby exceptions. More...

#include "Object_defn.hpp"
#include "protect.ipp"

Go to the source code of this file.

Functions

template<typename Fun , typename ... ArgT>
VALUE Rice::protect (Fun fun, ArgT const &... args)
 Call the C function f with arguments (arg1, arg2, ...). More...
 

Detailed Description

A collection of functions (overloaded on number of arguments) for calling C functions that might raise Ruby exceptions.

Function Documentation

◆ protect()

template<typename Fun , typename ... ArgT>
VALUE Rice::protect ( Fun  fun,
ArgT const &...  args 
)

Call the C function f with arguments (arg1, arg2, ...).

E.g.:

VALUE x = protect(rb_ary_new);
protect(rb_ary_push, x, INT2NUM(42));
VALUE protect(Fun fun, ArgT const &... args)
Call the C function f with arguments (arg1, arg2, ...).

Note that this function makes copies of all of its arguments; it does not take anything by reference. All of the copies are const so that protect will not work if f takes a non-const reference to any of its arguments (though you can use non-const pointers).

Examples
map/map.cpp.

References Rice::protect().

Referenced by Rice::protect().