title: Pass an array (variable) as template argument
body: <pre><code>typedef int INT5[5] ;
      template&lt;INT5 i5&gt;
      void fun()
      {
          for (auto i : i5)
          {
              cout &lt;&lt; i &lt;&lt; endl;
          }
      }
  
      void test()
      {
          int i5[5] = { 2,3,1,2,4 };
          fun&lt;i5&gt;();//error
      }
  </code></pre>
  
  <p>I want to pass an array as a template argument, but failed.</p>
  
  <blockquote>
    <p>error C2672: '__ExplicitVarTypeTest::fun': no matching overloaded
    function found </p>
    
    <p>error C2971: '__ExplicitVarTypeTest::fun': template parameter 'i5':
    'i5': a variable with non-static storage duration cannot be used as a
    non-type argument</p>
  </blockquote>
  
  <p>Someone give me a solution to pass the varible as a fun's argument rather than the template's argument. But in my situation, I can't change the function's argument. because it's a callback function.</p>
  
  <p>Actually, I need to do this</p>
  
  <pre><code>typedef char MyCharMap[UINT8_MAX];
      template&lt;MyCharMap keymap&gt;
      LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
      {
          //MSDN说了，nCode&lt;0（HC_ACTION）的都用CallNextHookEx返回
          if (nCode &gt;= HC_ACTION)
          {
              KBDLLHOOKSTRUCT* pStruct = (KBDLLHOOKSTRUCT*)lParam;
              if (keyMap[pStruct-&gt;vkCode])
              {
                  switch (wParam)
                  {
                  case WM_KEYDOWN:
                      keybd_event(keyMap[pStruct-&gt;vkCode], 0, 0, 0);
                      break;
                  case WM_KEYUP:
                      keybd_event(keyMap[pStruct-&gt;vkCode], 0, KEYEVENTF_KEYUP, 0);
                      break;
                  default:
                      throw "other key event";
                  }
              }
              return TRUE;
          }
          //传给系统中的下一个钩子   
          return CallNextHookEx(keyHook, nCode, wParam, lParam);
      }
  
  SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc&lt;keymap1&gt;, theApp.m_hInstance, NULL);
  SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc&lt;keymap2&gt;, theApp.m_hInstance, NULL);
  </code></pre>