Is there a good way in C ++ to implement (or fake) a type for a common vector of vectors?
Ignore the problem when a vector of vectors is a good idea (unless there is something equivalent, which is always better). Suppose that he accurately models the problem and that the matrix does not accurately model the problem. Suppose also that template functions that take these parameters as parameters need to be controlled by the structure (for example, by calling push_back), so they cannot just take on a common type that supports [][] .
What I want to do:
template<typename T> typedef vector< vector<T> > vecvec; vecvec<int> intSequences; vecvec<string> stringSequences;
but of course this is not possible, since typedef cannot be programmed.
#define vecvec(T) vector< vector<T> >
is close and will preserve type duplication in every templated function that works with vecvecs, but will not be popular with most C ++ programmers.
c ++ stl
Steve Jessop Nov 16 '08 at 15:26 2008-11-16 15:26
source share