On Mon, Oct 23, 2006 at 02:57:27PM +0200, Garth N. Wells wrote:
> 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
To me, it looks like code obfuscation. If you compare the two ways of
writing, you remove
"int*", "delete [] nodes"
and add
"boost::scoped_array<int>", ".get()", ".get()" (get in two places here)
There are probably places where we could make good use of smart
pointers, but here it looks to me like it just adds complexity.
In our experience, just taking care of sizes is not usually enough. We