remove_cv
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Removes the const or volatile qualifier or removes both simultaneously from the input template parameter type during program compilation. This API can be used for type conversion during compilation.
Prototype
1 2 | template <typename Tp> struct remove_cv; |
Parameters
Parameter |
Description |
|---|---|
Tp |
Types to be processed, including basic types (such as int and float), composite types (such as array, pointer, and reference), user-defined types (such as class and struct), and types qualified with const, volatile, or both const and volatile |
Restrictions
None
Returns
remove_cv is a struct that provides a nested type, which represents the type after the const-qualified and volatile-qualified types are removed. This type is accessed through remove_cv<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 23 24 25 26 27 28 | // Test non-const and non-volatile type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<int>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<double>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<char>::type, char>)); // Test const type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const int>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const double>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const char>::type, char>)); // Test volatile type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<volatile int>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<volatile double>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<volatile char>::type, char>)); // Test const and volatile type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const volatile int>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const volatile double>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv<const volatile char>::type, char>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<int>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<double>, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<const int>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<const double>, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<volatile int>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<volatile double>, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<const volatile int>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_cv_t<const volatile double>, double>)); |