Search code examples
c#.netc++-cli

What are the advantages of doing 100% managed development using C++/CLI?


What are the advantages (the list of possible disadvantages is lenghtly) of doing 100% managed development using C++/CLI (that is, compile with /clr:safe which "generates ... assemblies, like those written in ... C#")? Especially when compard to C# (note C++/CLI : Advantages over C# and Is there any advantage to using C++/CLI over either standard C++ or C#? are mostly about managed/unmanaged interop).

For example, here are a few off the top of my head:

  • C++-style references for managed types, not as elegant as full blown non-nullable references but better than nothing or using a work-around.

  • templates which are more powerful than generics

  • preprocessor (this may be a disadvantage!, but macros can be useful for code generation)

  • stack semantics for reference types--automatically calling IDisposable::Dispose()

  • easier implementation of Dispose() via C++ destructor

C# 3.0 added auto-implemented properties, so that is no longer a C++/CLI advantage.


Solution

  • In C++/CLI you can define functions outside of classes, you can't do that in C#. But I don't know if that is an advantage