CANN/asc-devkit add_pointer类型特性
2026/7/28 0:15:11 网站建设 项目流程

add_pointer

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持

功能说明

在程序编译时,为指定类型添加指针限定符,可以用于在编译时进行类型转换。

函数原型

template <typename Tp> struct add_pointer;

参数说明

表1模板参数说明

参数名含义
Tp需要处理的类型,包括基本类型(如int、float等)、复合类型(如数组、引用)以及带有指针限定符的类型。

约束说明

返回值说明

add_pointer是一个结构体,其提供一个嵌套类型type,表示添加指针限定符后的类型。通过add_pointer<Tp>::type来访问该类型。

调用示例

// Test basic type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<int>::type, int*>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<float>::type, float*>)); // Test void type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<void>::type, void*>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<const void>::type, const void*>)); // Test reference type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<int&>::type, int*>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<const int&>::type, const int*>)); // Test function type using FuncType = void(); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<FuncType>::type, FuncType*>)); // Test array type using ArrayType = int[]; ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<ArrayType>::type, ArrayType*>)); // Test pointer type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::add_pointer<int*>::type, int**>));

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询