title: c++ How to initialize static variables of a partial template specialization
body: <p>How should I initialize a static variable for a partial specialization?  </p>
  
  <pre><code>template &lt;bool A=true, bool B=false&gt;
  struct from {
      const static std::string value; 
  };
  
  // no specialization - works
  template &lt;bool A, bool B&gt;
  const std::string from&lt;A, B&gt;::value = "";
  
  // partial specialization - does not compile -  
  // Error: template argument list following class template name must list parameters in the order used in template parameter list
  // Error: from&lt;A,B&gt;' : too few template arguments
  template &lt;bool B&gt;
  const std::string from&lt;true, B&gt;::value = "";
  
  // full specialization - works
  const std::string from&lt;false, true&gt;::value = "";
  </code></pre>
  
  <p>Why doesn't the partial work?</p>
  
  <p>EDIT: I found a solution based on <a href="https://stackoverflow.com/questions/7670374/partial-template-specialization-for-initialization-of-static-data-members-of-tem">Partial template specialization for initialization of static data members of template classes</a></p>
  
  <p>I need to repeat the declaration for the partial specialization before it allowed me to initialize the static variable:</p>
  
  <pre><code>template &lt;bool B&gt;
  struct from&lt;true, B&gt; {
      const static std::string value; 
  };
  </code></pre>
  
  <p>Again, the question is why?</p>