MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / bind_function

Method bind_function

include/chaiscript/dispatchkit/bootstrap.hpp:256–271  ·  view source on GitHub ↗

Create a bound function object. The first param is the function to bind the remaining parameters are the args to bind into the result

Source from the content-addressed store, hash-verified

254 /// Create a bound function object. The first param is the function to bind
255 /// the remaining parameters are the args to bind into the result
256 static Boxed_Value bind_function(const std::vector<Boxed_Value> &params)
257 {
258 if (params.empty()) {
259 throw exception::arity_error(0, 1);
260 }
261
262 Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
263
264 if (f->get_arity() != -1 && size_t(f->get_arity()) != params.size() - 1)
265 {
266 throw exception::arity_error(static_cast<int>(params.size()), f->get_arity());
267 }
268
269 return Boxed_Value(Const_Proxy_Function(std::make_shared<dispatch::Bound_Function>(std::move(f),
270 std::vector<Boxed_Value>(params.begin() + 1, params.end()))));
271 }
272
273
274 static bool has_guard(const Const_Proxy_Function &t_pf)

Callers

nothing calls this directly

Calls 7

get_arityMethod · 0.80
arity_errorClass · 0.70
Boxed_ValueClass · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected