is_void
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Checks whether a type is the void type during program compilation. This API can be used for type checking and conditional processing during compilation.
Prototype
1 2 | template <typename Tp> struct is_void; |
Parameters
Parameter |
Description |
|---|---|
Tp |
Types to be checked, including basic data types, composite data types, modifier types, template classes, and user-defined types |
Restrictions
None
Returns
The static constant member value of is_void is used to obtain the returned Boolean value. The values of is_void<Tp>::value are as follows:
- true: Tp is of the void type.
- false: Tp is not of the void type.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // Custom test type struct MyStruct{}; // Function of the void type using FuncType = void(int); // Mismatch scenario AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<int>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<void*>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<FuncType>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<MyStruct>::value); // Matching scenario AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<void>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<const void>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<volatile void>::value); AscendC::printf("AscendC::Std::is_void::value:%d\n", AscendC::Std::is_void<const volatile void>::value); |
// Execution result AscendC::Std::is_void::value:0 AscendC::Std::is_void::value:0 AscendC::Std::is_void::value:0 AscendC::Std::is_void::value:0 AscendC::Std::is_void::value:1 AscendC::Std::is_void::value:1 AscendC::Std::is_void::value:1 AscendC::Std::is_void::value:1
Parent topic: Type Traits