Поделиться через


array_view::reinterpret_as Method

Reinterprets the array_view through a one-dimensional array_view, which as an option can have a different value type than the source array_view.

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

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

Parameters

  • _Value_type2
    The data type of the new array_view object.

Return Value

An array_view object or a const array_view object that is based on this array_view, with the element type converted from T to _Value_type2, and the rank reduced from N to 1.

Remarks

Sometimes it is convenient to view a multi-dimensional array as a linear, one-dimensional array, which may have a different value type than the source array. You can achieve this on an array_view by using this method.

Warning

Reinterpeting an array_view object by using a different value type is a potentially unsafe operation. This functionality should be used with care.

Here's 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);

Requirements

Header: amp.h

Namespace: Concurrency

See Also

Reference

array_view Class