title: Complex initialization of const fields
body: <p>Consider a class like this one:</p>
  
  <pre><code>class MyReferenceClass
  {
  public:
      MyReferenceClass();
      const double ImportantConstant1;
      const double ImportantConstant2;
      const double ImportantConstant3;
  private:
      void ComputeImportantConstants(double *out_const1, double *out_const2, double *out_const3);
  }
  </code></pre>
  
  <p>There is a routine (ComputeImportantConstants) that computes three constants at runtime. Suppose the computation is fairly complex, and inherently produces all three values at once. Moreover, the results depend on build configuration, so hardcoding the results isn't an option.</p>
  
  <p>Is there a sensible way to store these computed values in the corresponding const double fields of the class?</p>
  
  <p>If not, can you suggest a more natural way to declare such a class in C++?</p>
  
  <p>In C# I would use a static class with a static constructor here, but that isn't an option in C++. I have also considered making ImportantConstant1..3 either non-const fields or function calls, but both seem inferior.</p>
  
  <p>The only way to initialize const fields that I found is to <a href="https://stackoverflow.com/questions/1423696/c-class-with-const-field-how-to-initialize-it-in-constructor">use initializer lists</a>, but it doesn't seem possible to pass the results of a multi-output computation in such a list.</p>