Le mardi 22 mai 2007 04:50, vous avez écrit :
> Dear Sir,
>
> Could you do me a favor please?
> In my application, I create dynamically many dense matrices using new
> operator such like:
>
> Q = new gmm::dense_matrix< double >(N,M);
>
> and using delete operator to release them.
>
> My question is: Is it guaranteed that the objects are perfectly
> destroyed by using simple delete operator?
>

Yes, except if an error or an exception is thrown between the new and the 
delete (or in a function called). It is better to use an safe pointer like

std::auto_ptr<gmm::dense_matrix< double > > Q = new gmm::dense_matrix< double 
>(N,M);

The pointed object is automatically deleted. (but the copy of these pointers 
is problematic. If you need to copy the pointers, you have to use smart 
pointers such as boost ones).

In fact, it depends on the reason you need pointers. If, for instance, you 
need an arbitrary number of matrices, you can use a std::vector< 
gmm::dense_matrix< double > > which is safer.

Yves.

-------------------------------------------------------------------------
  Yves Renard ([EMAIL PROTECTED])       tel : (33) 04.72.43.80.11
  Pole de Mathematiques, INSA de Lyon          fax : (33) 04.72.43.85.29
  Institut Camille Jordan - CNRS UMR 5208
  20, rue Albert Einstein
  69621 Villeurbanne Cedex, FRANCE
  http://math.univ-lyon1.fr/~renard
-------------------------------------------------------------------------

_______________________________________________
Getfem-users mailing list
[email protected]
https://mail.gna.org/listinfo/getfem-users

Reply via email to