Concepts vs template constraints - the practical approach

Norbert Nemec Norbert at Nemec-online.de
Sun Nov 20 22:34:46 PST 2011


On 20.11.2011 21:03, Ali Çehreli wrote:
> On 11/20/2011 11:36 AM, Norbert Nemec wrote:
>> Collecting individual requirements as an AND expression of booleans does
>> not allow any helpful error message. If just one of the requirements is
>> not met, there is just one failure of the global assertion.
>
> dmd 2.056 with the code that I've tried, does provide which individual
> requirement is not met:
>
> deneme.d(54697): Error: no property 'len' for type 'YourClass'
> deneme.d(54709): Error: template instance
> deneme.hasNonNegativeLength!(YourClass) error instantiating
> deneme.d(54727): instantiated from here: matchesMyConcept!(YourClass)

True, there is some additional detail in some cases, but if you look 
closely: dmd does not complain about requirements that compute as 
"false", but about subexpressions that fail to compile at all.

In fact, such an error even means that the check is unusable as 
constraint: A template constraint should always compile without error 
and simply return true or false.


More information about the Digitalmars-d mailing list