From: dave@boostpro.com   
      
   on Wed Jun 06 2012, "Martin B." <0xCDCDCDCD-AT-gmx.at> wrote:   
      
   > On 06.06.2012 06:31, Dave Abrahams wrote:   
   >> on Tue Jun 05 2012, Mathias Gaunard wrote:   
   >>   
   >>> On Jun 5, 3:43 am, "Martin B."<0xCDCDC...@gmx.at> wrote:   
   >>>   
   >>>> # Question First   
   >   
   >>>>   
   >>>> Is there an elegant solution in C++ to prevent one from having to   
   >>>> declare complex object variables that are only used within a loop   
   >>>> outside of the loop for efficiency reasons?   
   >>>   
   >>> No. The only alternative I can think of is to not use loops, but   
   >>> rather algorithms.   
   >>   
   >> By which I think you mean "yes" :-). Algorithms are an elegant   
   >> abstraction that can hide the lack-of-elegance that may be required to   
   >> achieve efficiency.   
   >>   
   >   
   > 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.   
      
   --   
   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)   
|