Linked by Rüdiger Klaehn on Thu 5th Aug 2004 05:00 UTC
.NET (dotGNU too) One of the most awaited features of Microsoft .NET 2.0 is generics. Generics promise to increase type safety, improve performance, reduce code duplication and eliminate unnessecary casts. The most obvious application of generics in the framework class library are the generic collections in the new System.Collections.Generic namespace. Much has been written about those, but they are not the topic of this article.
Permalink for comment
To read all comments associated with this story, please click here.
Let me see if I get this right...
by Anonymous Coward on Thu 5th Aug 2004 16:37 UTC

You're complaining that you can't limit your template based on the availability of arithmetic operators.

So, did you try to compile your generic example above (Point<T>) using an object where the + operator would not apply?

All of the base primitives would work fine in your example.

However, if I read the spec correctly, as soon as you try create a struct/class that doesn't support + (we'll call it "Foo"), and try to declare it ("Point<Foo> f;") and use it ("f=f+f;"), you should get a compile-time error.