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,184 of 33,346   
   James K. Lowden to Richard Phillips   
   Re: RAII advice (for a RAII newbie)   
   31 Aug 13 12:53:37   
   
   From: jklowden@speakeasy.net   
      
   On Fri, 30 Aug 2013 12:28:52 -0700 (PDT)   
   Richard Phillips  wrote:   
      
   > // GOOD (RAII)   
   > {   
   > 	CleanupType cleanup;   
   > 	dosomething();   
   > }   
      
   better:   
      
   void dosomething() {   
   	CleanupType cleanup;   
   	/* do what needs doing */   
   }   
      
   or perhaps   
      
   CleanupType::CleanupType {   
   	/* acquire ... */   
   	dosomething();   
   }   
      
   That way, assuming CleanupType is correctly done, dosomething() is   
   reliable, and the caller need not concern himself with how the   
   resources are acquired.   
      
   --jkl   
      
      
   --   
         [ 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