I have a c array which contains valarrays as shown in the following code snipper,
#include <iostream>
#include <valarray>
#include <math.h>
using namespace std;
typedef uint uint32_t;
typedef std::valarray<uint32_t> uivector;
int main()
{
uivector a[] = { uivector(uint32_t(1),8), uivector(uint32_t(2),4), uivector(uint32_t(3),5) };
}
Now how do I access, say, the third element of the second valarray
(the value there is 2
), without making any copies and in a single line statement? Is it possible to overload the []
operator to achieve the same? something like a[1][2]
?