← Back to team overview

dolfin team mailing list archive

std::vector and pointers

 

I didn't realise until recently that storage in std::vector is guaranteed by the C++ standard to be contiguous (versus only being contiguous in all known implementations). Using this, I think that we can have safer and cleaner code by using more std::vector in the linear algebra interface. For example, we could have

  GenericVector::get(std::vector<double>& );
  GenericVector::set(const std::vector<double>& );

instead of

  GenericVector::get(double* x);
  GenericVector::set(const double* x);

For backends that want a pointer to an array, we can pass &x[0]. Any opinions?

Garth


Follow ups