Export (0) Print
Expand All
Expand Minimize
0 out of 5 rated this helpful - Rate this topic

Compiler Error C2252

Error Message

cannot explicitly instantiate template in current scope

The compiler detected a problem with an explicit instantiation of a template. For example, you cannot explicitly instantiate a template in a function.

The following sample generates C2252:

// C2252.cpp
class A {
   template <class T>
   int getit(int i , T * it ) {
      return i;
   template int A::getit<double>(int i, double * it);   // C2252
   // try the following line instead
   // template <> int A::getit<double>(int i, double * it);


int main() {
   // cannot explicitly instantiate in function
   template int A::getit<long>(int i, long * it);   // C2252
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.