Kompilatorfel C2140

"type" : en typ som är beroende av en generisk typparameter tillåts inte som ett argument för kompilatorns inbyggda typdrag "egenskap"

Anmärkningar

En ogiltig typspecifikator överfördes till ett typattribut.

Mer information finns i Kompilatorstöd för typegenskaper.

Exempel

I följande exempel genereras C2140.

// C2140.cpp
// compile with: /clr /c
template <class T>

struct is_polymorphic {
   static const bool value = __is_polymorphic(T);
};

class x {};

generic <class T>
ref class C {
   void f() {
      System::Console::WriteLine(__is_polymorphic(T));   // C2140
      System::Console::WriteLine(is_polymorphic<T>::value);   // C2140

      System::Console::WriteLine(__is_polymorphic(x));   // OK
      System::Console::WriteLine(is_polymorphic<x>::value);   // OK
   }
};