D almost has concepts (lite)

TommiT tommitissari at hotmail.com
Fri Mar 29 01:16:53 PDT 2013


On Friday, 29 March 2013 at 07:52:13 UTC, deadalnix wrote:
> That sound unimplementable, sorry.

Plus, to me it seems like the same thing they're proposing to 
implement in C++. This is a quote from the concepts-lite proposal 
paper http://isocpp.org/files/papers/n3580.pdf page 17:

For example, we define Totally_ordered like this:

template<typename T>
constexpr bool Totally_ordered()
{
     return Weakly_ordered<T>() && Equality_comparable<T>();
}

The relationship between the requirements of Totally_ordered and 
Equality_comparable can be pictured like this: [..]

Totally_ordered subsumes Equality_comparable because its 
requirements include those of the latter. This relation holds for 
any constraint predicate that explicitly includes another.
It is often the case the case that constraints overlap, with 
neither subsuming the other. For example, this is true of the 
Container and Range concepts described in the previous section. 
[..]

The subsumes relation is used to determine which of two templates 
is more constrained. In particular, a template T is more 
specialized than another, U iff they have the same generic type 
and the requirements of T subsume those of U. This relation is 
used to different templates with the same type when computing 
which is more specialized. Note that a constrained template is 
always more specialized than an unconstrained template.


More information about the Digitalmars-d mailing list