   Partial Template Specialization WTF
  I am working with VC++ 2003 and I get an error which makes no sense to me, and the MSDN pages are not helping at all. If someone would be kind enough to suggest a fix...template <size_t A>void foo(){}template <>void foo<0>(){}template <size_t A, size_t B>void bar(){}template <size_t A>void bar<A, 0>(){}The error is as follows:error C2768: 'bar' : illegal use of explicit template argumentsIt applies to my attempt at a partial specialization of the second function. While I can specialize foo, which has one template argument, it seems impossible to specialize bar over one of its template arguments.   
  You cannot partially specialize a function template.Workaround:template<size_t A, size_t B>struct bar_helper{   static void bar();};template<size_t A, size_t B>void bar_helper<A,B>::bar(){}template<size_t A>void bar_helper<A,0>::bar(){}template <size_t A, size_t B>void bar(){   bar_helper<A,B>::bar()};Quote:Original post by FrunyWorkaround:You can't define a member function of a partially specialized type template unless the partial specialization of the type is defined, so for the above code to work, prior to your second bar member function defintion you'd need to do:template<size_t A>struct bar_helper< A, 0 >{   static void bar();};Another alternative would be to use SFINAE to avoid requiring a helper struct. If you have boost installed, this can easily be done with enable_if:#include <boost/utility/enable_if.hpp>template <size_t A, size_t B>typename ::boost::disable_if_c<(B==0)>::type bar(){  // Definition if B != 0}template <size_t A, size_t B>typename ::boost::enable_if_c<(B==0)>::type bar(){  // Definition if B == 0}