Template constraints in D

Bill Baxter dnewsgroup at billbaxter.com
Sat Jun 21 01:54:13 PDT 2008


Walter Bright wrote:
> 
> (Also comparing them with C++0x concepts.)
> 
> http://www.digitalmars.com/d/2.0/cpp0x.html#concepts
> 
> http://www.digitalmars.com/d/2.0/concepts.html
> 
> Essentially, I think we cover the necessary ground with an order of 
> magnitude simpler system.

Maybe you should provide an example somewhere of how to translate this 
basic C++0x example into D:

----
auto concept LessThanComparable<typename T> {
     bool operator<(T, T);
};

template<LessThanComparable T>
const T& min(const T& x, const T& y) {
     return x < y? x : y;
}
----

--bb



More information about the Digitalmars-d mailing list