Is it a vector of vectors or a vector of pointers to vectors? Your code should work as advertised:
typedef std::vector<int> vec_int;
typedef std::vector<vec_int> multi_int;
multi_int m(10, vec_int(10));
m.at(2).at(2) = ;
m[2][1] = ;
But your code is as follows:
typedef std::vector<vec_int*> multi_int;
multi_int* m;
If you have pointers, you first need to dereference them to use operator[]:
(*(*m)[2])[2] = /* ... */;
It can be ugly. May temporarily use links:
multi_int& mr = m;
(*mr[2])[2] = ;
. , :
template <typename T>
typename T::value_type& access_ptr(T* pContainer,
unsigned pInner, unsigned pOuter)
{
return (*(*pContainer)[pInner])[pOuter]);
}
access_ptr(m, 2, 2) =
. , , . , boost .
, . at operator[] , at . .