I’m evaluating binding a C++ project of mine in .NET, attracted by the possibility F# offers. My project uses templates massively, so it’s not uncommon to have something like this:
template <typename T, class Iterator = BufferIterator<T> >
class Buffer
{
public:
[...]
private:
[...]
};
My question is: How tight is the integration with C++ in .NET? Is it possible to bind my project to fully support C++ templates and other C++ TMP features?
Links to material and a couple of example would be very appreciated.
Thanks in advance,
A.
C++ templates are usable on both native and managed types within a C++/CLI project.
Instantiations of templated C++/CLI types can be used from outside the project (assembly), but they act as completely independent and unrelated types. Sharing C++/CLI type templates between C++/CLI projects causes type identity issues, you should share only concrete types.
Other languages have zero support for metaprogramming.
There’s no relationship between templates and .NET generics, the first is a compile-time feature and the second is runtime. Two incompatible methods of approaching polymorphism (which isn’t to say you can’t use both at the same time, but the two don’t interact with each other)