本文整理汇总了C++中ndt::type::is_variadic方法的典型用法代码示例。如果您正苦于以下问题:C++ type::is_variadic方法的具体用法?C++ type::is_variadic怎么用?C++ type::is_variadic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ndt::type
的用法示例。
在下文中一共展示了type::is_variadic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolve
ndt::type resolve(base_callable *DYND_UNUSED(caller), char *data, call_graph &cg, const ndt::type &dst_tp,
size_t nsrc, const ndt::type *src_tp, size_t nkwd, const array *kwds,
const std::map<std::string, ndt::type> &tp_vars) {
const ndt::callable_type *child_tp =
reinterpret_cast<data_type *>(data)->child->get_type().template extended<ndt::callable_type>();
bool first = reinterpret_cast<data_type *>(data)->first;
reinterpret_cast<data_type *>(data)->first = false;
bool state = reinterpret_cast<data_type *>(data)->state;
bool res_ignore = reinterpret_cast<data_type *>(data)->res_ignore;
bool dst_variadic = dst_tp.is_variadic();
// Do a pass through the src types to classify them
bool src_all_strided = true, src_all_strided_or_var = true;
for (size_t i = 0; i < nsrc; ++i) {
intptr_t src_ndim = src_tp[i].get_ndim() - child_tp->get_pos_type(i).get_ndim();
switch (src_tp[i].get_id()) {
case fixed_dim_id:
break;
case var_dim_id:
src_all_strided = false;
break;
default:
// If it's a scalar, allow it to broadcast like
// a strided dimension
if (src_ndim > 0) {
src_all_strided_or_var = false;
}
break;
}
}
bool var_broadcast = !src_all_strided;
for (size_t i = 0; i < nsrc; ++i) {
var_broadcast &= src_tp[i].get_id() == var_dim_id ||
(src_tp[i].get_id() == fixed_dim_id &&
src_tp[i].extended<ndt::fixed_dim_type>()->get_fixed_dim_size() == 1);
}
if ((dst_variadic || (dst_tp.get_id() == fixed_dim_id || res_ignore)) && src_all_strided) {
static callable f = make_callable<elwise_callable<fixed_dim_id, fixed_dim_id, no_traits, N>>();
static callable g = make_callable<elwise_callable<fixed_dim_id, fixed_dim_id, state_traits, N>>();
if (!first && state) {
return g->resolve(this, data, cg, dst_tp, nsrc, src_tp, nkwd, kwds, tp_vars);
} else {
return f->resolve(this, data, cg, dst_tp, nsrc, src_tp, nkwd, kwds, tp_vars);
}
} else if (((dst_variadic) || dst_tp.get_id() == var_dim_id) && (var_broadcast || src_all_strided)) {
static callable f = make_callable<elwise_callable<var_dim_id, fixed_dim_id, no_traits, N>>();
return f->resolve(this, data, cg, dst_tp, nsrc, src_tp, nkwd, kwds, tp_vars);
} else if (src_all_strided_or_var) {
static callable f = make_callable<elwise_callable<fixed_dim_id, var_dim_id, no_traits, N>>();
return f->resolve(this, data, cg, dst_tp, nsrc, src_tp, nkwd, kwds, tp_vars);
}
std::stringstream ss;
ss << "Cannot process lifted elwise expression from (";
for (size_t i = 0; i < nsrc; ++i) {
ss << src_tp[i];
if (i != nsrc - 1) {
ss << ", ";
}
}
ss << ") to " << dst_tp;
throw std::runtime_error(ss.str());
}