title: Initialize const member variables
body: <p>I have C++ code that boils down to something like the following:</p>
  
  <pre><code>class Foo{
      bool bar;
      bool baz;
      Foo(const void*);
  };
  Foo::Foo(const void* ptr){
      const struct my_struct* s = complex_method(ptr);
      bar = calculate_bar(s);
      baz = calculate_baz(s);
  }
  </code></pre>
  
  <p>Semantically, the bar and baz member variables should be const, since they should not change after initialization. However, it seems that in order to make them so, I would need to initialize them in an initialization list rather than assign them. To be clear, I understand <em>why</em> I need to do this. The problem is, I can't seem to find any way to convert the code into an initialization list without doing one of the following undesirable things:</p>
  
  <ul>
  <li>Call <code>complex_method</code> twice (would be bad for performance)</li>
  <li>Add the pointer to the Foo class (would make the class size needlessly large)</li>
  </ul>
  
  <p>Is there any way to make the variables const while avoiding these undesirable situations?</p>