Sdílet prostřednictvím


Chyba kompilátoru C2179

'type' : Argument atributu nemůže použít parametry typu

Poznámky

Parametr obecného typu je vyřešen za běhu. Parametr atributu však musí být vyřešen v době kompilace. Proto nelze použít parametr obecného typu jako argument atributu.

Příklad

Následující příklad vygeneruje C2179.

// C2179.cpp
// compile with: /clr
using namespace System;

public ref struct Attr : Attribute {
   Attr(Type ^ a) {
      x = a;
   }

   Type ^ x;
};

ref struct G {};

generic<typename T>
public ref class Z {
public:
   Type ^ d;
   [Attr(T::typeid)]   // C2179
   // try the following line instead
   // [Attr(G::typeid)]
   T t;
};