?

Log in

No account? Create an account
Gavin Greig [userpic]

C++/CLI bug in VS2005

March 3rd, 2006 (02:56 pm)

Last week I found what appears to be a bug in the implementation of C++/CLI in Visual Studio 2005, and this week Mark Hall has responded to my bug report, saying it will be considered for a future release.

I have mixed feelings about the bug: I'm partly quite pleased that I seem to have found something that no-one else had come across yet, but also partly disappointed for the same reason. Although I don't suppose there are a lot of people desperate to have a managed class inherit from its own template template parameter, it's not quite as rare as all that since template metaprogramming in C++ has become more popular.

If I'm the first to come across it, after a long period in public beta, it does make me wonder slightly whether C++/CLI is being pushed in its capabilities by anyone, because I don't usually regard myself as a pioneer. I first came across it when exploring the possibility of porting some of Loki to C++/CLI (something I would have thought other people would already have tried, if only from curiosity), but only narrowed it down to the actual issue when I tried to use the same idiom in my own code.

I have worked around it in the situation where it arose, although it has resulted in less tidy code and some unnecessary duplication of template parameters, and I guess I know what to avoid in future.

Comments

Posted by: Scotty (scottymcleod)
Posted at: March 6th, 2006 12:43 pm (UTC)

I would guess from the non pro programmer perspective that C++ targeted at the CLI is uncommon. Almost all mention you see of MS themselves using a .NET language for the likes of WinFX, Expression series, SONAR etc. seem to be in C# and very occassional VB.NET.

While I can see many companies wishing to take advantage of C++ to C++ CLI I think the chances are they will take a different route when they see what will not work in terms of multiple inheritance and the like and decide to design from the ground up in C# especially as many taking those decision will be looking to enhance CV's.

Posted by: Gavin Greig (ggreig)
Posted at: March 6th, 2006 01:12 pm (UTC)
Caricature

On the whole, I think you're right. However, there are areas in which C++ still has a clear advantage over C#, and templates is one of those areas. There is no equivalent in C# (there's an overlap with generics, but each has its own advantages and C++/CLI implements both, so you can pick the right one for the job).

The absence of multiple inheritance is a bit of a nuisance in some cases - sometimes multiple inheritance is the right answer - but you can always implement multiple interfaces (effectively abstract classes with no data members), so it's only multiple base classes with data members that can't be accommodated. This avoids the diamond inheritance pattern that's usually put forward as the reason to avoid multiple inheritance. I'd rather it wasn't quite so prescriptive as that, but with "glass half full" specs on, you do have most of the power of multiple inheritance still available.

We're using C# for interacting with .NET APIs, where IntelliSense and all the other ease of use advantages of C# have a big effect, but C++ for developing more flexible business logic.

2 Read Comments