title: got "cannot appear in a constant-expression" when using template
body: <pre><code>template &lt; int &gt;  
    class CAT  
    {};  
  
    int main()  
    {  
       int i=10;  
       CAT&lt;(const int)i&gt; cat;  
       return 0; //here I got error: ‘i’ cannot appear in a constant-expression  
    }  
  </code></pre>
  
  <p>even    </p>
  
  <pre><code>   int i=10;  
     const int j=i;  
     CAT&lt;j&gt; cat; //this still can not work
  </code></pre>
  
  <p>but I have convert i to const int ,why compiler still report error ?<br>
    my platform is ubuntu,gcc version 4.4.3 </p>
  
  <p>Thanks,</p>
  
  <p>==============</p>
  
  <p>Thanks all for your input, but in some cases,I need a non-const variable , </p>
  
  <p>for example: </p>
  
  <pre><code>  //alloperations.h   
    enum OPERATIONS  
    {  
         GETPAGE_FROM_WEBSITE1,  
         GETPAGE_FROM_WEBSITE2,  
         ....  
    };  
  
  
    template&lt; OPERATIONS op &gt;  
    class CHandlerPara  
    {  
         static string parameters1;         
         static string parameters2;         
         ....  
         static void resultHandler();  
    };     
  
  
    //for different operations,we need a different parameter, to achieve this  
    //we specified parameters inside CHandler, for  example  
  
    template&lt;&gt;  
    string CHandlerPara&lt; GETPAGE_FROM_WEBSITE1 &gt;::parameters1("&amp;userid=?&amp;info=?..")  
  
    template&lt;&gt;  
    string CHandlerPara&lt; GETPAGE_FROM_WEBSITE1 &gt;::parameters2("...")  
  </code></pre>
  
  <p>other module will using this template to get corresponding parameter<br>
  and maybe specilize the resultHandler function for a special behavior  </p>