template<typename Fn, typename Reverse>
minilua::UnaryNumericFunctionHelper struct

Helper for creating reversible numeric unary function.

With this helper you don't have to manually match the Values you just have to provide functions that take Number values and return Number values for:

  1. the normal function you want to write
  2. the reverse function for propagating the changed result to the parameter

Usage (using the deduction guide):

function sqrt_impl(const CallContext& ctx) -> Value {
    return minilua::UnaryNumericFunctionHelper{
        [](Number param) { return std::sqrt(param.as_float()); },
        [](Number new_value, Number old_param) { return new_value.as_float() *
new_value.as_float(); },
     }(ctx);
}

Note the call at the end.

It's also possible to directly use the UnaryNumericFunctionHelper as the argument to Function because it is callable with a CallContext argument.

See also: BinaryNumericFunctionHelper.