I have a class which currently contains N vectors of int
and M vectors of double like below;
probably in future vectors of other types (e.g. bool) will be addedCode:template< int N, int M > class VectorCollection { std::vector<int> ivec[N]; std::vector<double> dvec[M]; };
to class. I want to have a simple interface which give access to
interior vectors based on the types of int,double,...
like below
data<int,0>(i) should return ivec[0][i];Code:template< int N, int M > class VectorCollection { // vectors as above public: template< class T, int K > T& data(i); };
data<double,1>(i) should return dvec[1][i] and so
But I do not know how to implement this. It seems very difficult.
Could anyone help me on this?
Thanks a lot




Reply With Quote
