-
- Downloads
Implement pseudo-operator[] for MultiTypeBlockVector
This method mimicks the behavior of normal vector access with square brackets like, e.g., v[5] = 1. The problem is that the return type is different for each value of the argument in the brackets. Therefore we implement a trick using std::integral_constant. To access the first entry of a MultiTypeBlockVector named v write MultiTypeBlockVector<A,B,C,D> v; std::integral_constant<int,0> _0; v[_0] = ... The name '_0' used here as a static replacement of the integer number zero is arbitrary. Any other variable name can be used. If you don't like the separate variable, you can writee MultiTypeBlockVector<A,B,C,D> v; v[std::integral_constant<int,0>()] = ...
Please register or sign in to comment