I have a c++ templated class:
template<class T>
class A {
void test (T temp) { }
};
But i need to wrap it in CLI so it can be used in c#.
Example:
CLI:
template<class T>
ref class AWrap {
private:
A* a;
public:
void test (T temp) {
a->test<T>(temp);
}
};
C#:
Awrap blah = new AWrap();
blah<int>(3);
If I make a CLI templated ref class
, which call the templated c++ method, will the primitive types generate the right c++ templated code on compilation ?->
What you are using in C# are generics, not templates. There is no way of specializing a C++/CLI template from C#.
来源:https://stackoverflow.com/questions/4735507/primitive-types-pass-template-parameter-between-c-and-cli