title: Default value for template function argument
body: <p>Caution: I don't have C++11</p>
  
  <p>I need a default value for a template function parameter, but it seems c++ 
  will skip deduction for default parameters...</p>
  
  <pre><code>struct mode1 {};
  struct mode2 {};
  
  template &lt;typename T&gt;
  void myFunc(int value, T mode = mode1())
  {
      if(std::is_same&lt;T, mode1&gt;::value)
      {
          std::cout &lt;&lt; "foo";
      }
      else if(std::is_same&lt;T, mode2&gt;::value)
      {
          std::cout &lt;&lt; "bar";
      }
  }
  </code></pre>
  
  <p>But how can i achieve, that this call will work:</p>
  
  <pre><code>myFunc(20); /* Defaults to mode1 */
  </code></pre>
  
  <p>Why i will use this? Because of optimization...
  In my real life scenario, i would use this for this piece of code:</p>
  
  <pre><code>template &lt;typename TokenType&gt;
          HGStringBasic Tokenize(const _ElemT* tokens, size_type uTokenIndex, size_type uIndex = 0, size_type uEndIndex = npos, TokenType tokenType = tokenTypeChar()) const
          {           
              size_type uPosInStr;
              size_type uCurrToken;
  
              if(uEndIndex == npos)
              {
                  uEndIndex = this-&gt;Length();
              }
  
              for( uCurrToken = 0 ; uIndex &lt; uEndIndex ; (uIndex = uPosInStr+1), (++uCurrToken) )
              {
                  if(std::is_same&lt;TokenType, tokenTypeChar&gt;::value)
                      uPosInStr = this-&gt;PosBrk(tokens, uIndex);
                  else if(std::is_same&lt;TokenType, tokenTypeString&gt;::value)
                      uPosInStr = this-&gt;Pos(tokens, uIndex);
  
                  if(uCurrToken == uTokenIndex) 
                  {                       
                      if(uPosInStr == npos)
                          return this_type(&amp;m_data[uIndex], uEndIndex - uIndex);
                      return this_type(&amp;m_data[uIndex], (uPosInStr &lt; uEndIndex ? uPosInStr : uEndIndex) - uIndex);
                  }
                  if(uPosInStr == npos)
                      break;
              }
              return this_type();
          }
  </code></pre>