There is a function, accepting 2D-array:
void foo ( double ** p )
{ /*writing some data into p*/ }
I wouldn’t like to pass raw 2D array into this function because i don’t want to manage memory calling new and delete. Also i wouldn’t like to change function signature to void foo ( std::vector< std::vector<double> >& ). And i can’t make foo as a template function (in my project it’s a COM-interface method).
I would like to pass some RAII object decoring it raw-one, like
void foo ( double * p ){}
std::vectore<double> v(10);
p( &v[0] );
Is there way to do this for 2D-arrays? I tried
std::vector< std::vector<int> > v;
foo( &v[0][0] )
and
std::vector< std::tr1::shared_ptr<int> > v;
but i get compile errors error C2664 - cannot convert parameter.
Also, can one be sure that raw address arithmetics inside the function works ok in this case?
No C++11, the sizes of 2D-array are known.
One possible solution is to change:
to