Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does valarray have contiguous memory alignment?

Does valarray have contiguous memory alignment?

I want to pass a valarray to a function (from IPPS), which only takes pointers, by passing &myValarray[0]. But therefore I should be sure, that valarray's memory alignment is contiguous.

Thanks!

like image 926
Massoud Avatar asked Jun 21 '12 16:06

Massoud


1 Answers

Assuming you're asking whether the memory managed by a valarray is guaranteed to be contiguous, then the answer is yes, at least if the object isn't const (C++03, §26.3.2.3/3 or C++11, §26.6.2.4/2):

The expression &a[i+j] == &a[i] + j evaluates as true for all size_t i and size_t j such that i+j is less than the length of the non-constant array a.

like image 99
Jerry Coffin Avatar answered Sep 21 '22 17:09

Jerry Coffin