remove_reference
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Removes the reference qualifiers, including the left-value reference T& and right-value reference T&&, from a given type during program compilation. This API can be used for type conversion during compilation.
Prototype
1 2 | template <typename Tp> struct remove_reference; |
Parameters
Parameter |
Description |
|---|---|
Tp |
Types to be processed, including basic types (such as int and float), composite types (such as array and pointer), user-defined types (such as class and struct), and types qualified with left-value reference & or right-value reference && |
Restrictions
None
Returns
remove_reference is a struct that provides a nested type, which represents the type after the reference qualifiers are removed. This type can be accessed through remove_reference<Tp>::type.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // Test non-reference type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<int>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<double>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<char>::type, char>)); // Test lvalue reference type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<int&>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<double&>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<char&>::type, char>)); // Test rvalue reference type ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<int&&>::type, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<double&&>::type, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference<char&&>::type, char>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<int>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<double>, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<int&>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<double&>, double>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<int&&>, int>)); ascendc_assert((AscendC::Std::is_same_v<AscendC::Std::remove_reference_t<double&&>, double>)); |