home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 33,182 of 33,346   
   Thomas Richter to Richard Phillips   
   Re: RAII advice (for a RAII newbie)   
   30 Aug 13 14:51:05   
   
   From: thor@math.tu-berlin.de   
      
   On 30.08.2013 21:28, Richard Phillips wrote:   
      
   > Why is the 2nd (RAII) approach superior to the third approach?  I   
   > presume there's more to it than "appearance"?  While the third   
   > approach looks more complicated, it doesn't have to worry about a   
   > "CleanupType"...   
      
   Robustness, especially under program modifications. If you have such a   
   resource acquisition in just one place, that's probably ok, but then   
   you must be careful when working on the sources whether you move   
   anything into the function, namely within or outside of the catch, in   
   specific if you need to allocate another resource later.   
      
   If you need the same or similar resources in several places, it is   
   rather error-prone to write the same try-catch clause whenever you   
   need this resource. Instead, just use this administration class that   
   keeps the resource, and you don't need to worry anymore if exceptions   
   propagate out of the function.   
      
   Greetings,   
   	Thomas   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca