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

Function functor

include/chaiscript/dispatchkit/function_call.hpp:42–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 /// \param[in] funcs the set of functions to dispatch on.
41 template<typename FunctionType>
42 std::function<FunctionType> functor(const std::vector<Const_Proxy_Function> &funcs, const Type_Conversions_State *t_conversions)
43 {
44 const bool has_arity_match = std::any_of(funcs.begin(), funcs.end(),
45 [](const Const_Proxy_Function &f) {
46 return f->get_arity() == -1 || size_t(f->get_arity()) == chaiscript::dispatch::detail::Arity<FunctionType>::arity;
47 });
48
49 if (!has_arity_match) {
50 throw exception::bad_boxed_cast(user_type<Const_Proxy_Function>(), typeid(std::function<FunctionType>));
51 }
52
53 FunctionType *p=nullptr;
54 return detail::build_function_caller_helper(p, funcs, t_conversions);
55 }
56
57 /// Build a function caller for a particular Proxy_Function object
58 /// useful in the case that a function is being pass out from scripting back

Callers

nothing calls this directly

Calls 5

get_arityMethod · 0.80
bad_boxed_castClass · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected