本文整理汇总了C++中ndt::type::at_single方法的典型用法代码示例。如果您正苦于以下问题:C++ type::at_single方法的具体用法?C++ type::at_single怎么用?C++ type::at_single使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ndt::type
的用法示例。
在下文中一共展示了type::at_single方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
groupby_type::groupby_type(const ndt::type& data_values_tp,
const ndt::type& by_values_tp)
: base_expr_type(groupby_type_id, expr_kind,
sizeof(groupby_type_data), sizeof(void *), type_flag_none,
0, 1 + data_values_tp.get_ndim())
{
m_groups_type = by_values_tp.at_single(0).value_type();
if (m_groups_type.get_type_id() != categorical_type_id) {
stringstream ss;
ss << "to construct a groupby type, the by type, " << by_values_tp.at_single(0);
ss << ", must have a categorical value type";
throw runtime_error(ss.str());
}
if (data_values_tp.get_ndim() < 1) {
throw runtime_error("to construct a groupby type, its values type must have at least one array dimension");
}
if (by_values_tp.get_ndim() < 1) {
throw runtime_error("to construct a groupby type, its values type must have at least one array dimension");
}
m_operand_type = ndt::make_cstruct(ndt::make_pointer(data_values_tp), "data",
ndt::make_pointer(by_values_tp), "by");
m_members.arrmeta_size = m_operand_type.get_arrmeta_size();
const categorical_type *cd = m_groups_type.extended<categorical_type>();
m_value_type = ndt::make_cfixed_dim(cd->get_category_count(),
ndt::make_var_dim(data_values_tp.at_single(0)));
m_members.flags = inherited_flags(m_value_type.get_flags(), m_operand_type.get_flags());
}
示例2:
/**
* Given some metadata for the groupby type, return metadata
* for a single element of the data_values array.
*/
const char *get_data_value_metadata(const char *metadata) const {
// First at_single gets us to the pointer<array<data_value>> type
ndt::type d = m_operand_type.at_single(0, &metadata);
// Second at_single gets us to the data_value type
d.at_single(0, &metadata);
return metadata;
}
示例3:
/**
* Given some arrmeta for the groupby type, returns the
* arrmeta for the pointer type that points at the data
* values.
*
* \param arrmeta An instance of groupby type arrmeta.
*
* \returns The pointer<data_values_type> arrmeta within the
* groupby arrmeta.
*/
pointer_type_arrmeta *get_data_values_pointer_arrmeta(char *arrmeta) const {
m_operand_type.at_single(0, const_cast<const char **>(&arrmeta));
return reinterpret_cast<pointer_type_arrmeta *>(arrmeta);
}