none
How do I bind an array_view to a const c-array?

    Question

  • How do I bind an array_view to a native array that is const in the scope. See the following example:

    void ThisWorks( VECTORTYPE* const_array )
    {
        concurrency::array_view<
    VECTORTYPE, 2> amp_output_color (width, height, const_array );
    }

    void ThisDoesnt( const VECTORTYPE* const_array )
    {
        concurrency::array_view<VECTORTYPE, 2> amp_output_color (width, height, const_array );
    }

    Is there a way to make this work?
    lundi 16 avril 2012 05:49

Réponses

  • Hi Ian,

    To bind a const pointer to an array_view, you would need to bind it to array_view<const T, N>.  So that the array_view only provides read access, thus respect the const-ness of the pointer. 

    So what you need is:

    concurrency::array_view<const VECTORTYPE, 2> amp_output_color (width, height, const_array ); 

    Thanks,

    Weirong



    lundi 16 avril 2012 06:42