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,194 of 33,346    |
|    Seungbeom Kim to Miles Bader    |
|    Re: Initialization and trivial construct    |
|    25 Apr 12 12:10:15    |
   
   From: musiphil@bawi.org   
      
   On 2012-04-23 21:22, Miles Bader wrote:   
   > brangdon@cix.compulink.co.uk (Dave Harris) writes:   
   >> o Unable to add more code between initialisations (so it doesn't   
   >> scale).   
   >   
   > This is absolutely my main complaint about initializer lists -- I find   
   > it a very common case that I want to calculate an intermediate value   
   > based on the constructor arguments, and then use that value to   
   > initialize several data members. The initializer-list form makes this   
   > quite annoying.   
      
   For example,   
      
   A::A(double x, double y)   
   {   
    double r = hypot(x, y);   
    this->x = x / r;   
    this->y = y / r;   
   }   
      
   In this example, 'hypot(x, y)' represents an expensive function call   
   whose return value is to be used in initializing subsequent members.   
      
   Is there a good way to do the same with an initialization list?   
      
   --   
   Seungbeom Kim   
      
      
    [ 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