PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > RAII (Resource Acquisition Is Initialization) pattern limitations
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
RAII (Resource Acquisition Is Initialization) pattern limitations

Réponse
 
LinkBack Outils de la discussion
Vieux 26/12/2007, 07h58   #1
George2
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RAII (Resource Acquisition Is Initialization) pattern limitations

Hello everyone,


Through my testing and study of RAII (Resource Acquisition Is
Initialization) pattern, I think it can solve resource release issue
in the following two situations,

1. Local function object (on stack);
2. Object (either on heap or stack) pointer by auto_ptr;

But it has the limitation that the object pointed by a normal pointer
and allocated on heap (using new or new[]) can not be automatically
released, either the function returns normally or during exception
stack unwinding. Is that correct?


thanks in advance,
George
  Réponse avec citation
Vieux 26/12/2007, 09h09   #2
Barry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: RAII (Resource Acquisition Is Initialization) pattern limitations

George2 wrote:
> Hello everyone,
>
>
> Through my testing and study of RAII (Resource Acquisition Is
> Initialization) pattern, I think it can solve resource release issue
> in the following two situations,
>
> 1. Local function object (on stack);
> 2. Object (either on heap or stack) pointer by auto_ptr;
>


The name of this idiom literally suggests such usage, and of course the
"limitation"

> But it has the limitation that the object pointed by a normal pointer
> and allocated on heap (using new or new[]) can not be automatically
> released,


do you mean GC?

either the function returns normally or during exception
> stack unwinding. Is that correct?


if you returning an auto_ptr, there's no such issue, as copy constructor
of auto_ptr guarantees no throw.
anyway, I still not quite understand what you mean.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h15.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11705 seconds with 10 queries