array::reinterpret_as 方法

返回一维数组,其中包含所有的元素中数组对象。

template <
   typename _Value_type2                     
>
array_view<_Value_type2,1> reinterpret_as()restrict(amp,cpu);
                     
template <
   typename _Value_type2                     
>
array_view<const _Value_type2,1> reinterpret_as() const restrict(amp,cpu);

参数

  • _Value_type2
    返回的数据的数据类型。

返回值

array_view或 const array_view基于对象array,与元素类型重新解释从T到ElementType和秩从减少 N 为 1。

备注

有时最好查看数据的 N-二维数组作为一个线性的数组,也可能不包含键入的元素类型的安全 reinterpretation。您可以使用此方法来实现这一点。以下代码提供了一个示例。

struct RGB { float r; float g; float b; };

array<RGB,3>  a = ...; 
array_view<float,1> v = a.reinterpret_as<float>(); 

assert(v.extent == 3*a.extent);

要求

标题: amp.h

命名空间: 并发

请参见

参考

array 类