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 32,388 of 33,346   
   Dave Abrahams to All   
   Re: Techniques to avoid minimal scope in   
   08 Jun 12 12:01:06   
   
   From: dave@boostpro.com   
      
   on Fri Jun 08 2012, Seungbeom Kim  wrote:   
      
   > On 2012-06-07 12:02, Dave Abrahams wrote:   
   >> on Wed Jun 06 2012, "Martin B." <0xCDCDCDCD-AT-gmx.at> wrote:   
   >>>   
   >>> Mathias, Dave - I fail to see how an algorithm could help. I really   
   >>> don't get it.   
   >>>   
   >>> Can you provide an example where an algorithm based solution avoids   
   >>> the inefficiencies associated with declaring the temporary complex   
   >>> object inside the loop body?   
   >>   
   >> The implementor of the algorithm simply avoids declaring temporary   
   >> objects in his loops.  The algorithm implementor is not (or should   
   >> not be) subject to your guideline.  In fact, the guideline should   
   >> probably be rewritten in the form, "avoid doing XXX, or if you must,   
   >> encapsulate it."  That's pretty much the right form for most things   
   >> one might want to generally prohibit, like casts.   
   >   
   > What does an algorithm change with regard to the lifetime of   
   > temporaries?  Naturally, the functor may declare its own local   
   > variable in the scope of the function to be called, or it may try to   
   > use a variable that's supplied externally to the functor. In either   
   > case, I don't see any fundamental differences from the situations with   
   > the manually-written loops.   
      
   The algorithm implementor creates whatever temporaries she wants,   
   wherever she wants them.  The user of the algorithm can then stick to   
   the guideline.  Does that help explain?   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ 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