C++/CLI/C# Map generic types to template types -


when writing cli code interface between c++ , c#, have convert types in function calls can used in c# or c++. example, std::string doesn't exist in c#, have convert string^ , vice versa.

now want wrap c++ class exposes templated function c# via interface should expose similar generic method. wrote cli ref class implements c# interface , holds pointer instance of c++ class:

// c# public interface isomeclass {     void somemethod<t>(t param); }  //cli public ref class : isomeclass { public:     generic<typename t>     virtual void somemethod(t param) {         _nativeptr->nativemethod<t>(param); // :(     }     // implementation details... };  // c++ class somenativeclass { public:     template<typename t>     void nativemethod(t&& nativeparam) { /*bla*/ } }; 

in specific case (using visual studio 2013), makes compiler crash. though don't think supposed crash, can guess not supposed work, after can't pass c# types directly c++ function. want mechanism through can convert generic type 't' c++ template type 'u'. tried using template metaprogramming, not work c# generics in cli, since generic classes can't specialized.

is there way make work?


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -