array::reinterpret_as Method

Reinterprets the array through a one-dimensional array_view, which optionally may have a different value type than the source 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

The data type of the returned data.

An array_view or const array_view object that is based on the array, with the element type reinterpreted from T to ElementType and the rank reduced from N to 1.

Sometimes it is convenient to view a multi-dimensional array as if it is a linear, one-dimensional array, possibly with a different value type than the source array. You can use this method to achieve this.

Caution note Caution

Reinterpreting an array object by using a different value type is a potentially unsafe operation. We recommend that you use this functionality carefully.

The following code provides an example.

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);

Header: amp.h

Namespace: Concurrency

Show: