array::reinterpret_as 方法
回傳一個包含所有在 array 物件裏的元素的一維陣列。
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 的 array_view 或常值 array_view 物件,其元素型別從 T 轉為 ElementType 且其秩由 N 降為 1 。
備註
有時候將 N 維陣列的資料視為線性的陣列,且可能以不是型別安全的方式重新轉譯元素型別,仍是適當的。您可以使用此方法來達成這個目的。下列程式碼提供一個範例。
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
**命名空間:**並行