Template constraints in D

Walter Bright newshound1 at digitalmars.com
Sat Jun 21 02:34:43 PDT 2008


Bill Baxter wrote:
> 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;
> }
> ----


See the isAddable example.



More information about the Digitalmars-d mailing list