FIX: Error C2783 - Cannot Deduce Non-Type Template Parameter (165803)



The information in this article applies to:

  • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
  • Microsoft Visual C++, 32-bit Professional Edition 5.0

This article was previously published under Q165803

SYMPTOMS

The sample code in the MORE INFORMATION section causes the compiler error C2783:
'declaration' : could not deduce template argument for 'identifier'

RESOLUTION

The workaround is to avoid argument deduction by specifying the template-parameter-list when calling the function template.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Microsoft Visual C++ version 6.0.

MORE INFORMATION

The following sample code demonstrates the problem and the workaround:

SAMPLE

      /* Compile options needed: none
      */ 

      template <int I>
      struct C
      {
          int a[I] ;
      };

      template <int I>
      int F(C<I> a)
      {
          return I ;
      }

      int main ()
      {
          int i;
          C<4>  CObj ;

          i  = F(CObj);

          // Workaround: Comment the line above.
          // Uncomment the following line
          // i = F<4>(CObj);

          return 0 ;
      }
				

Modification Type:MinorLast Reviewed:7/5/2005
Keywords:kbBug kbfix kbVC600fix KB165803