From: brangdonj@googlemail.com   
      
   In article , pasa@lib.hu (Balog Pal) wrote:   
   > > It is quite hard to optimise these calls away because the new   
   > > expression involves a call to operator new which may have been   
   > > replaced by one that has some extra (observable)   
   > > functionality. The same is true for the delete expression.   
   >   
   > Hmm, an excellent point. And smells like a defect to the standard or   
   > at least a good opportunity for improvement.   
   >   
   > To me that case is the same as copy-elision.   
      
   Copy-elision is a pretty clear win. It means eliminating overhead   
   altogether. Replacing heap allocation with stack allocation is not the   
   same. If the user has a small stack and a large heap, they might   
   /want/ to use the heap. If the code uses recursion heavily, we can   
   imagine cases where heap-based allocation works, and stack-based fails   
   from running out of stack. Given that the user requested heap-based by   
   using operator new(), it would arguably be a bug for the compiler to   
   presume it knew better. Especially for C++, which still has aspersions   
   for granting low-level control to the programmer.   
      
   -- Dave Harris, Nottingham, UK.   
      
      
   --   
    [ 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)   
|