← Back to team overview

dolfin team mailing list archive

smart pointers

 

What does everyone think about using some of the smart pointers from
Boost? Instead of

  int* nodes = new int[element.spacedim()];
  element.nodemap(nodes, *cell, mesh);
  /*
     Do something
  */
   delete [] nodes;

we would have

  boost::scoped_array<int> nodes( new int[element.spacedim()] );
  element.nodemap(nodes.get(), *cell, mesh);
  /*
     Do something
  */

In the end, it's pretty similar to std::vector, except it's a bit more
efficient since it's not designed to change size and we can access the
underlying pointer with get().

Garth


Follow ups