Hi!
I am trying to export some libraries that are written in C++ to a DLL with the /clr option so it can be used in C#. I have some troubles to fully understand the how to export templates and generics to a CLR library. I have been searching the web for days for a good answer and I only find blogs that explain the goods and bads between generics and templates. And that is not the answer I am looking for.
For example, I have this code in C++, compiled in a DLL and exported to a C# project.
namespace MyDLL { generic<class T> public ref class GenericRefClass { public: T value; } template<class T> public ref class TemplateRefClass { public: T value; } generic<class T> public value class GenericValueClass { public: T value; } template<class T> public value class TemplateValueClass { public: T value; } }
When I import MyDLL to a C# project I only see GenericRefClass and GenericValueClass. Is like the templates are not implemented in the library.
in ECMA 334 pag. 74 says
"C# generics will immediately be familiar to users of generics in Eiffel or Ada, or to users of templates in C++."
Written like that is like generics in C# are the same as templates in C++. But it should be wrong.
I know that templates are resolved during compilation and generics during run time. So, does that means that there is no way that templates could be interchangable through a dll Or is there another way
Because there is a HUGE problem. How can I reuse the boost libraries http://www.boost.org/ that are mostly templates in a C# project
Thanks in advance.