reflection - Native types and Generics -


i want create native array , access managed code. don't want re write code different types, (int, long, float, double) therefore tried using generics.

typedef int ind;  generic <typename t> public ref class ntvarray {     void *pnt;     ind sz;  public:     ntvarray(ind length)     {         sz = sizeof(t);         pnt =  ::operator new(length*sz);     }      ~ntvarray()     {         ::operator delete(pnt);     }      void* pointer()     {         return pnt;     }      t getitem (ind index)     {         //c3229         return ((t*)pnt)[index];     }      void setitem (ind index, t value)     {         //c3229         ((t*)pnt)[index] = value;     } }; 

i getting error , know reason error,

error c3229: 't *' : indirections on generic type parameter not allowed

however there way using generics? other way this, may else other using generics?

no, can't using generics. can use templates. avoids code duplication, question emphasizes, won't allow run-time instantiation generics would.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -