John, On Wednesday 09 March 2005 11:11, Randall R Schulz wrote:
John,
...
I'm particularly interested in generics. For example, it seems to me, that you should can build up concepts as interfaces and specify template classes with templates that must implement particular interfaces. This would be better than C++ because I don't think you can specify that a template class must, for example, implement assignable and equality comparable, in C++. (I know Boost does this, but there is some runtime overhead.) The new java may be capable of it if you're willing to accept .equals() instead of operator=(), etc.
I'm sure it's debatable, but I think Java generics are a poor substitute for proper templates.
As to your point about constraints on acceptable parameter types being missing from C++, that's not really true. If the template uses a member function, then any attempt to use as a parameter a type that does not provide it will cause template instantiation to fail.
By the way, there's already considerable commentary on the Web comparing C++ Templates and Java Generics. A Google search for "C++ Templates Java Generics" produces quite a few relevant hits.
...
Randall Schulz