本文整理汇总了C++中callable函数的典型用法代码示例。如果您正苦于以下问题:C++ callable函数的具体用法?C++ callable怎么用?C++ callable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了callable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: default_factory
static PyObject*
default_factory( Member* member, PyObject* owner )
{
PyTuplePtr args( PyTuple_New( 0 ) );
if( !args )
return 0;
PyObjectPtr callable( newref( member->default_context ) );
return callable( args ).release();
}
开发者ID:enthought,项目名称:atom,代码行数:9,代码来源:memberfunctions.cpp
示例2: default_owner_method
static PyObject*
default_owner_method( Member* member, PyObject* owner )
{
if( !PyString_Check( member->default_context ) )
return py_type_fail( "default owner method name must be a string" );
PyObjectPtr callable( PyObject_GetAttr( owner, member->default_context ) );
if( !callable )
return 0;
PyTuplePtr args( PyTuple_New( 0 ) );
if( !args )
return 0;
return callable( args ).release();
}
开发者ID:enthought,项目名称:atom,代码行数:13,代码来源:memberfunctions.cpp
示例3: post_validate_owner_method
static PyObject*
post_validate_owner_method( Member* member, PyObject* owner, PyObject* oldvalue, PyObject* newvalue )
{
if( !PyString_Check( member->post_validate_context ) )
return py_type_fail( "post validate owner method name must be a string" );
PyObjectPtr callable( PyObject_GetAttr( owner, member->post_validate_context ) );
if( !callable )
return 0;
PyTuplePtr args( PyTuple_New( 2 ) );
if( !args )
return 0;
args.set_item( 0, newref( oldvalue ) );
args.set_item( 1, newref( newvalue ) );
return callable( args ).release();
}
开发者ID:enthought,项目名称:atom,代码行数:15,代码来源:memberfunctions.cpp
示例4: get_code
int get_code(unsigned* pycbuf, struct code_obj* pobj, int cur, int size)
{
int func_idx = 0;
int op_arg = 0;
int num_obj = 1;
int dealt = 0;
int len = length(pycbuf, cur-5);
int end = cur + len;
while (cur < end-1 && !(cur >= size)) {
if(!(callable(cur, pycbuf))) {
field_add(&(pobj->code), pycbuf[cur]);
if (have_arg(pycbuf[cur])) {
op_arg = get_op_arg(pycbuf, cur);
field_add(&(pobj->code), op_arg);
cur += 3;
} else {
cur += 1;
}
} else {
//printf("****:dealing function\n");
dealt = find_next_callable(pycbuf, cur, num_obj);
struct code_obj* pnew_obj = malloc(sizeof(*pnew_obj));
func_idx = get_fields(pycbuf, pnew_obj, dealt, size); /* get fields of the entire code object */
objects[func_idx]->val.pobj = pnew_obj;
objects[func_idx]->type = TYPE_CODE;
num_obj++;
cur += 9;
}
}
field_add(&(pobj->code), pycbuf[cur]);
return cur+1;
}
开发者ID:cshintov,项目名称:Learning-C,代码行数:32,代码来源:init.c
示例5: operator
void operator() (types... args)
{
for (auto& callable : this->callables)
{
callable(args...);
}
}
开发者ID:swq0553,项目名称:LightPixel,代码行数:7,代码来源:Signals.hpp
示例6: every
void every(const double delay, SharedPtr<Reactor> reactor,
Callback<Error> &&callback, std::function<bool()> &&stop_predicate,
Callback<> &&callable) {
reactor->call_soon([
=, callback = std::move(callback),
stop_predicate = std::move(stop_predicate),
callable = std::move(callable)
]() mutable {
if (delay <= 0.0) {
callback(ValueError());
return;
}
if (stop_predicate()) {
callback(NoError());
return;
}
callable();
reactor->call_later(delay, [
=, callback = std::move(callback),
stop_predicate = std::move(stop_predicate),
callable = std::move(callable)
]() mutable {
every(delay, reactor, std::move(callback),
std::move(stop_predicate), std::move(callable));
});
});
}
开发者ID:measurement-kit,项目名称:measurement-kit,代码行数:27,代码来源:every.cpp
示例7: make
static typename std::enable_if<!ndt::has_traits<KernelType>::value, callable>::type
make(const ndt::type &tp, StaticDataType &&static_data)
{
return callable(tp, detail::get_targets<KernelType>(), detail::get_ir<KernelType>(),
std::forward<StaticDataType>(static_data), &KernelType::alloc, &KernelType::data_init,
&KernelType::resolve_dst_type, &KernelType::instantiate);
}
开发者ID:corsy,项目名称:libdynd,代码行数:7,代码来源:callable.hpp
示例8: multidispatch
callable multidispatch(const ndt::type &self_tp,
const std::initializer_list<callable> &children,
const callable &default_child = callable())
{
return multidispatch<N>(self_tp, children.begin(), children.end(),
default_child);
}
开发者ID:Laeeth,项目名称:libdynd,代码行数:7,代码来源:multidispatch.hpp
示例9: UNWRAP
v8::Handle<v8::Value> Session::sendNativePdu(const v8::Arguments& args) {
UNWRAP(Session, wrap, args.This());
SwapScope scope(wrap, args);
if(0 == wrap->session_) {
return ThrowError("Session hasn't opened.");
}
if(2 != args.Length()) {
return ThrowError("Must pass pdu and cb arguments to sendNativePdu.");
}
v8::Handle<v8::Object> cb = args[1]->ToObject();
if (!cb->IsCallable()) {
return ThrowError("Must pass pdu and cb arguments to sendNativePdu.");
}
UNWRAP(Pdu, pdu, args[0]->ToObject());
std::auto_ptr<netsnmp_pdu> copy(pdu->is_owner()? pdu->release() : snmp_clone_pdu(pdu->native()));
std::auto_ptr<Callable> callable(new Callable(cb, args[0], copy.get()));
if(0 == snmp_sess_async_send(wrap->session_, copy.get(),
Callable::OnEvent, callable.get())) {
return ThrowError(snmp_api_errstring(wrap->arguments_.s_snmp_errno));
}
callable.release();
copy.release();
if(scope.hasException()) {
return scope.getException();
}
return v8::Undefined();
}
开发者ID:runner-mei,项目名称:snmp.js,代码行数:32,代码来源:session.cpp
示例10: operator
RT operator( )( )
{
PyGILState_STATE gstate = PyGILState_Ensure();
RT result = boost::python::extract<RT>( callable( ) );
PyGILState_Release( gstate );
return result;
}
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:7,代码来源:py_boost_function.hpp
示例11: main_with_catch
inline
int
main_with_catch(
int argc,
char const* argv[],
void (*callable)(int argc, char const* argv[]))
{
user_plus_system_time();
if (!check_fem_utils_int_types()) {
return 255;
}
try {
callable(argc, argv);
}
catch (fem::stop_info const& info) {
std::fflush(stdout);
std::fprintf(stderr, "%s\n", info.what());
std::fflush(stderr);
}
catch (std::exception const& e) {
std::fflush(stdout);
char const* what = e.what();
if (what == 0) what = "null";
std::fprintf(stderr, "std::exception what(): %s\n", what);
std::fflush(stderr);
return 1;
}
catch (...) {
std::fflush(stdout);
std::fprintf(stderr, "Terminated by unknown C++ exception.\n");
std::fflush(stderr);
return 2;
}
return 0;
}
开发者ID:OpenResearchComputation,项目名称:fable,代码行数:35,代码来源:main.hpp
示例12: test_thread_callable_object_no_arguments
void test_thread_callable_object_no_arguments()
{
callable_no_args func;
boost::thread callable(func);
callable.join();
BOOST_CHECK(callable_no_args::called);
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:7,代码来源:test_thread_launching.cpp
示例13: test_thread_callable_object_one_argument
void test_thread_callable_object_one_argument()
{
callable_one_arg func;
boost::thread callable(func,42);
callable.join();
BOOST_CHECK(callable_one_arg::called);
BOOST_CHECK_EQUAL(callable_one_arg::called_arg,42);
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:8,代码来源:test_thread_launching.cpp
示例14: callable
variant candidate_action_with_filters::do_filtering(ai::formula_ai* ai, variant& input, game_logic::const_formula_ptr formula)
{
game_logic::map_formula_callable callable(static_cast<const formula_callable*>(ai));
callable.add("input", input);
return formula::evaluate(formula, callable);
}
开发者ID:shikadilord,项目名称:wesnoth,代码行数:8,代码来源:candidates.cpp
示例15: _state
Thread::Thread(EventLoop& loop)
: _state(Thread::Ready)
, _detach(false)
, _impl(0)
{
_impl = new ThreadImpl();
_impl->init( callable(loop, &EventLoop::run) );
}
开发者ID:3Nigma,项目名称:frayon,代码行数:8,代码来源:Thread.cpp
示例16: apply
static inline
R
apply(const F& callable,
const msgpack::object * /* packed */,
Args&&... args)
{
return callable(std::forward<Args>(args)...);
}
开发者ID:bacek,项目名称:cocaine-core,代码行数:8,代码来源:slot.hpp
示例17: callable
int citizen::would_accept_job(const_job_ptr j, const money_market& m, const hex::tile& t, int rank) const
{
if(!wages_wanted_formula) {
return -1;
}
job_callable callable(*this, j, m, t, rank);
return wages_wanted_formula->execute(callable).as_int();
}
开发者ID:x2f,项目名称:wesciv,代码行数:9,代码来源:citizen.cpp
示例18: pycall__callable
SEXP pycall__callable(SEXP Rfun, SEXP Rargv_list, SEXP Rargv_dict) {
#ifdef REMBEDPY_DEBUG
Rprintf("callable\n");
#endif
Rcpp::S4 fun(Rfun);
PyObjPtr pcallable(Rcpp::wrap(fun.slot("ptr")));
boost::python::object& callable(*pcallable);
boost::python::list argv_list(RembedPy::extract_argv_list(Rargv_list));
boost::python::dict argv_dict(RembedPy::extract_argv_dict(Rargv_dict));
return RembedPy::pycall(callable, argv_list, argv_dict);
}
开发者ID:wush978,项目名称:RembedPy,代码行数:11,代码来源:py.cpp
示例19: pycall__funname
SEXP pycall__funname(SEXP Rmodule_name, SEXP Rfun_name, SEXP Rargv_list, SEXP Rargv_dict) {
#ifdef REMBEDPY_DEBUG
Rprintf("funname\n");
#endif
std::string
fun_name(Rcpp::as<std::string>(Rfun_name)),
module_name(Rcpp::as<std::string>(Rmodule_name));
boost::python::object callable(RembedPy::extract_pyobj(fun_name, module_name));
boost::python::list argv_list(RembedPy::extract_argv_list(Rargv_list));
boost::python::dict argv_dict(RembedPy::extract_argv_dict(Rargv_dict));
return RembedPy::pycall(callable, argv_list, argv_dict);
}
开发者ID:wush978,项目名称:RembedPy,代码行数:12,代码来源:py.cpp
示例20: call
//-------------------------------------------------------------------------------------------------
Value Function::call(const UserObject& object, const Args& args) const
{
// Check if the function is callable
if (!callable(object))
CAMP_ERROR(ForbiddenCall(name()));
// Check the number of arguments
if (args.count() < m_argTypes.size())
CAMP_ERROR(NotEnoughArguments(name(), args.count(), m_argTypes.size()));
// Execute the function
return execute(object, args);
}
开发者ID:Gohla,项目名称:camp,代码行数:14,代码来源:function.cpp
注:本文中的callable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论