title: Non-member initialization in constructor initializer list
body: <p>Confused? Me too...
  Consider the following </p>
  
  <pre><code>typedef std::map&lt;std::string , double&gt; Thresholds;
  
  class Foo 
  {
      public: 
          Foo( const double &amp; _toxicThres , const double &amp; _zeroThres )
      : thresholds
      (
          MapInitializer&lt;std::string , double&gt;()
              .Add("toxic" , _toxicThres)
              .Add("zero" , _zeroThres)
      )
  
      private:
         Thresholds thresholds; 
  };
  </code></pre>
  
  <p>The above works fine and initializes an <code>std::map</code> in the constructor's member initialisation list. Now consider this:</p>
  
  <pre><code>typedef std::map&lt;std::string , double&gt; Thresholds;
  struct CommonData
  {
      Thresholds thresholds;
  };
  
  class Foo //a mixin
  {
      public: 
          Foo( Thresholds &amp; thresholds , const double &amp; _toxicThres , const double &amp; _zeroThres )
      : thresholds
      (
          MapInitializer&lt;std::string , double&gt;()
              .Add("toxic" , _toxicThres)
              .Add("zero" , _zeroThres)
      )
  };
  
  class Bar //another mixin
  {
      public: 
          Bar( Thresholds &amp; thresholds , const double &amp; _warningThres , const double &amp; _zeroThres)
      : thresholds
      (
          MapInitializer&lt;std::string , double&gt;()
              .Add("warning" , _warningThres)
              .Add("zero" , _zeroThres)
      )
  };
  
  class OtherGasThreshold{/*...*/}; //yet another mixin, etc...
  
  template&lt;typename ThresholdMixin&gt; //Foo , Bar , or others ...
  class ThresholdSensor : public ThresholdMixin 
  {
      public:
          ThresholdSensor(double val1 , double val2) 
              : ThresholdMixin(cd.thresholds, val1 , val2)
          {}
  
      private:
          CommonData cd;
  };
  </code></pre>
  
  <p>Note that the <code>MapIniializer</code> code comes from <a href="https://stackoverflow.com/a/1674689/959179">here</a>, and is </p>
  
  <pre><code>template&lt;class K, class V&gt;
  class MapInitializer
  {
      std::map&lt;K,V&gt; m;
  public:
      operator std::map&lt;K,V&gt;() const 
      { 
          return m; 
      }
  
      MapInitializer&amp; Add( const K&amp; k, const V&amp; v )
      {
          m[ k ] = v;
          return *this;
      }
  };
  </code></pre>
  
  <p>Of course the above would not compile, but is there any way to init the map in <code>ThresholdSensor::CommonData</code> in one of the mixins during constructor init. ie can I pass by reference the map, init it in the mixins constructor?</p>