Export (0) Print
Expand All
Expand Minimize

Compiler Error C2918

Error Message

'name' : illegal use of local type in type instantiation

You cannot instantiate a function based on a function template based on a local type. Types used to instantiate must have external linkage.

The following sample generates C2918:

// C2918.cpp
// compile with: /Za /c
template<class T> 
void f(T t) {};

template<class T> 
void g(T t) {};
struct Y {};

void g() {
   struct X {};

   X x;
   f(x);   // C2918

   Y y;
   g(y);
}

Community Additions

ADD
Show:
© 2014 Microsoft