title: Template with constant expression: error C2975 with VC++2008
body: <p>I am trying to use elements of meta programming, but hit the wall with the first trial.
  I would like to have a comparator structure which can be used as following:</p>
  
  <pre><code>intersect_by&lt;ID&gt;(L1.data, L2.data, "By ID: ");
  intersect_by&lt;IDf&gt;(L1.data, L2.data, "By IDf: ");
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>  struct ID{};// Tag used for original IDs
      struct IDf{};// Tag used for the file position  
      //following Boost.MultiIndex examples  
      template&lt;typename Tag,typename MultiIndexContainer&gt;
      void intersect_by(
      const MultiIndexContainer&amp; L1,const MultiIndexContainer&amp;    L2,std::string msg,
        Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms */
      )
      {
       /* obtain a reference to the index tagged by Tag */
  
       const typename boost::multi_index::index&lt;MultiIndexContainer,Tag&gt;::type&amp; L1_ID_index=
       get&lt;Tag&gt;(L1);
       const typename boost::multi_index::index&lt;MultiIndexContainer,Tag&gt;::type&amp; L2_ID_index=
       get&lt;Tag&gt;(L2);
  
        std::set_intersection(
        L1_ID_index.begin(), 
        L1_ID_index.end(), 
        L2_ID_index.begin(), 
        L2_ID_index.end(),
        std::inserter(s, s.begin()), strComparator&lt;Tag&gt;() // Here I get the C2975 error
        );
        }
  
      template&lt;int N&gt; struct strComparator;
      template&lt;&gt; 
      struct strComparator&lt;0&gt;{
      bool operator () (const particleID&amp; id1, const particleID&amp; id2) const
      {
       return id1.ID&lt;id2.ID;
      }
      };
      template&lt;&gt; 
      struct strComparator&lt;1&gt;{ 
      bool operator () (const particleID&amp; id1, const particleID&amp; id2) const
      {
       return id1.IDf&lt;id2.IDf; 
      }
  
      };
  </code></pre>
  
  <p>What I am missing?</p>
  
  <p>kind regards
  Arman.</p>
  
  <p>Sorry I did not copy the full error message.
  Full error:</p>
  
  <pre><code>&gt;Compiling...
  1&gt;trace_ids.cpp
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2975: 'strComparator' : invalid template argument for 'N', expected compile-time constant expression
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(144) : see reference to function template instantiation 'void intersect_by&lt;ID,particlesID_set&gt;(const MultiIndexContainer &amp;,const MultiIndexContainer &amp;,std::string,Tag *)' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            MultiIndexContainer=particlesID_set,
  1&gt;            Tag=ID
  1&gt;        ]
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2955: 'strComparator' : use of class template requires template argument list
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2784: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&amp;)[_Size],_Pr)' : could not deduce template argument for '_OutElem (&amp;)[_Size]' from 'std::insert_iterator&lt;_Container&gt;'
  1&gt;        with
  1&gt;        [
  1&gt;            _Container=particlesID_set
  1&gt;        ]
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4064) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if&lt;!std::_Is_checked_iterator&lt;_OutIt&gt;::_Result,_OutIt&gt;::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4004) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&amp;)[_Size])' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3993) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if&lt;std::_Is_checked_iterator&lt;_OutIt&gt;::_Result,_OutIt&gt;::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3983) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2975: 'strComparator' : invalid template argument for 'N', expected compile-time constant expression
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(146) : see reference to function template instantiation 'void intersect_by&lt;IDf,particlesID_set&gt;(const MultiIndexContainer &amp;,const MultiIndexContainer &amp;,std::string,Tag *)' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            MultiIndexContainer=particlesID_set,
  1&gt;            Tag=IDf
  1&gt;        ]
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2955: 'strComparator' : use of class template requires template argument list
  1&gt;        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2784: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&amp;)[_Size],_Pr)' : could not deduce template argument for '_OutElem (&amp;)[_Size]' from 'std::insert_iterator&lt;_Container&gt;'
  1&gt;        with
  1&gt;        [
  1&gt;            _Container=particlesID_set
  1&gt;        ]
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4064) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if&lt;!std::_Is_checked_iterator&lt;_OutIt&gt;::_Result,_OutIt&gt;::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4004) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&amp;)[_Size])' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3993) : see declaration of 'std::set_intersection'
  1&gt;c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if&lt;std::_Is_checked_iterator&lt;_OutIt&gt;::_Result,_OutIt&gt;::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
  1&gt;        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3983) : see declaration of 'std::set_intersection'
  1&gt;Build log was saved at "file://c:\Documents and Settings\arm2arm\Mes documents\Visual Studio 2008\Projects\mstgraph\trace_ids\Debug\BuildLog.htm"
  1&gt;trace_ids - 12 error(s), 0 warning(s)
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>