of "Conditional Implementation" vs "Assertive Input Validation"

xenon325 1 at mail.net
Tue Jul 24 01:37:43 PDT 2012


On Monday, 23 July 2012 at 19:57:42 UTC, Jacob Carlborg wrote:
> constraint BidirectionalRange (Range) : ForwardRange!(Range)
> {
>     void popBack ();
>     @property E back ();
>     @property E front ();
> }
>
>  [snip]
>
> I know that others have had similar ideas.

I remember this was discussed recently and Don Clugston suggested 
something like this:

if there is no match for:

     void foo(T)(T t) if( !conditionA!T ){}
     void foo(T)(T t) if( conditionA!T && conditionB!T ){}

the error will be:

template foo does not match any function template, constraints 
values are:
     conditionA: true
     conditionB: false

(note that `conditionA` is listed only once)

And given who Don is, I'm pretty sure he have an idea how to 
implement this.




More information about the Digitalmars-d mailing list