I'm not seeing any real advantages, other than the fact that you have a C++ syntax, and with it, things like pointers and destructors.
I don't think comparing different flavors of C++ to each other is the same question as comparing C++ to C#. C# is a very different beast compared to the differences between different flavors of C++.
One extension I've found useful is the following construct, utilized by the D3DMATRIX
structure in DirectX's d3d9types.h
:
typedef struct _D3DMATRIX {
union {
struct {
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
float m[4][4];
};
} D3DMATRIX;
It uses an MSVC extension of an anonymous struct inside an anonymous union (I forget what the technical name for this is), allowing you to access the matrix members either through an explicit name myMatrix._12
or via indexing myMatrix.m[0][1]
.
Of course, this is just syntactic sugar, and it's much better to have standards-conforming C/C++ than some sugar.
I think you're referring to C++/CLI and comparing it to C#. C++/CLI isn't a 'flavor' of C++. It's an entirely new language with entirely different standard libraries and entirely different conventions.
At work we find that C++/CLI is valuable as a glue language between C++ and .NET, but we don't use it for anything besides interface glue - C# has enormous advantages over C++ in all other applications.
If you're referring to MS C++ extensions like what Adam describes, there's no reason not to use them if they make your job easier.
If you're talking about why you would use C++/CLI over C#, I think the main reasons are that:
- it might be more natural for C++ developers (though I think this is probably not true)
- C++/CLI has very nice capabilities for bridging the native and managed environments (using the 'IJW' - It Just Works - technology)
I think that Herb Sutter probably gives the best overview:
A Design Rationale for C++/CLI
If you want to know why you might want to use native C++ over C#/.NET, this boils down to why you would want a managed environment (safety, easier development) over native code (absolute control, possibly speed advantages). There are arguments for each, and the answer really depends on what you want to develop and what your market might be.