title: Assign CRTP static members at runtime
body: <p>I have a set of classes which I am extending using the CRTP to do a mixin-style so that each type can have separate static member variables. All of the classes inherit from GdsDataObject. There are 36 separate classes that do this, and they do not have uniform class mixins. This is an example of one of the classes, names GdsAircraft.</p>
  
  <pre><code>template &lt;typename T&gt;
  class GdsMixinLOD
  {
  protected:
    static unsigned int min_lod;
    static unsigned int max_lod;
  }
  
  template &lt;typename T&gt; unsigned int GdsMixinLOD&lt;T&gt;::min_lod = 10;
  template &lt;typename T&gt; unsigned int GdsMixinLOD&lt;T&gt;::max_lod = 1000;
  
  class GdsAircraft :
    public GdsDataObject,
    public GdsMixinLOD&lt;GdsAircraft&gt;,
    public GdsMixinShared&lt;GdsAircraft&gt;  // Mixin shared by all classes
  {
    ...
  }
  </code></pre>
  
  <p>At runtime I load configuration options from a file and set the static member variables using those values. Right now I use a loop to detect the data type the option is meant for and then call one or more template functions to assign the values. I have to manually call additional functions for classes that have additional mixins.</p>
  
  <pre><code>template&lt;typename GdsType_T&gt;
  void setGdsStaticConfigLODValues(const OptionTokens &amp;options)
  {
    for(auto &amp;data_type_option : options) {
      if(data_type_option.first == "MIN_LOD") {
        GdsType_T::min_lod = boost::lexical_cast&lt;unsigned int&gt;(options.second);
      } else if(data_type_option.first == "MIN_LOD") {
        GdsType_T::min_lod = boost::lexical_cast&lt;unsigned int&gt;(options.second);
      }
    }
  }
  
  template&lt;typename GdsType_T&gt;
  void setGdsStaticConfigSharedValues(const OptionTokens &amp;options)
  {
    for(auto &amp;data_type_option : options) {
      // Loop just like in setGdsStaticConfigLODValues function
    }
  }
  </code></pre>
  
  <p>I want to do all this with a single template function instead of having to write a separate function for every mixin and manually keep track of which classes have what mixins. The single function should somehow be able to set static variables for classes that actually have those variables.</p>