A Briefer Syntax for Using Concepts

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed May 7 13:12:40 PDT 2014


On Wed, May 07, 2014 at 08:09:34PM +0000, w0rp via Digitalmars-d wrote:
> On Wednesday, 7 May 2014 at 14:49:17 UTC, Orvid King via Digitalmars-d
> wrote:
> >On 5/7/14, w0rp via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> >>void foo(InputRange range);
> >
> >How to make it accept multiple types? Simple, we already have template
> >constraints, so this would be how to do it, where T is the element
> >type of the input range:
> >
> >void foo(T)(InputRange!T range);
> 
> I am confused. The proposed syntax would already accept many different
> types.

I believe the objection is that the proposed syntax can't tell the
difference between:

	void foo(R)(R range1, R range2) if (isInputRange!R)

and

	void foo(R,S)(R range1, S range2) if (isInputRange!R && isInputRange!S)

I.e. in the first case, the two ranges must be the same type, whereas in
the second case they can be different types as long as they are both
input ranges.


T

-- 
Не дорог подарок, дорога любовь.


More information about the Digitalmars-d mailing list