FIX: Error C2783 - Cannot Deduce Non-Type Template Parameter

Article translations Article translations
Article ID: 165803 - View products that this article applies to.
This article was previously published under Q165803
Expand all | Collapse all

On This Page


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


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


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.


The following sample code demonstrates the problem and the workaround:


      /* 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 ;


Article ID: 165803 - Last Review: July 5, 2005 - Revision: 1.1
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
kbbug kbfix kbnoupdate kbvc600fix KB165803
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from