add_pointer
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Adds the pointer qualifier to a specified type during program compilation. This API can be used for type conversion during compilation.
Prototype
1 2 | template <typename Tp> struct add_pointer; |
Parameters
Parameter |
Description |
|---|---|
Tp |
Types to be processed, including basic types (such as int and float), composite types (such as array and reference), and pointer-qualified types |
Restrictions
None
Returns
add_pointer is a struct that provides a nested type, which represents the type after the pointer qualifier is added. This type can be accessed through add_pointer<Tp>::type.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // 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**>)); |