Vector subscripting operator []
The [] (subscripting) operator accesses individual elements
of a vector data type, similar to how array elements are accessed.
The vector data type is followed by a set of square brackets containing
the position of the element. The position of the first element is
0. The type of the result is the type of the elements contained in
the vector type.
Note: If the position specified is outside of the
valid range, the behavior is undefined.
Example:
vector unsigned int v1 = {1,2,3,4};
unsigned int u1, u2, u3, u4;
u1 = v1[0]; // u1=1
u2 = v1[1]; // u2=2
u3 = v1[2]; // u3=3
u4 = v1[3]; // u4=4Note: You can also access and manipulate
individual elements of vectors with the following intrinsic functions:
- vec_extract
- vec_insert
- vec_promote
- vec_splats