Rant after trying Rust a bit
Nicholas Wilson via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 25 19:16:44 PDT 2015
On Sunday, 26 July 2015 at 01:55:12 UTC, Enamex wrote:
> On Saturday, 25 July 2015 at 09:14:04 UTC, Jonathan M Davis
> wrote:
>> . . .
>> auto foo(alias pred, R)(R r)
>> if(testPred!pred && isInputRange!R && !isForwardRange!R)
>> {}
>>
>> auto foo(alias pred, R)(R r)
>> if(testPred!pred && isForwardRange!R)
>> {}
>>
>> and be turning it into something like
>>
>> template foo(alias pred)
>> if(testPred!pred)
>> {
>> auto foo(R)(R r)
>> if(isInputRange!R && !isForwardRange!R)
>> {}
>>
>> auto foo(R)(R r)
>> if(isForwardRange!R)
>> {}
>> }
>> . . .
>> - Jonathan M Davis
>
> The example(s) is confusing me. `foo!(first)(second);` isn't
> really an alternative to `foo(first, second);`_?_. Am I
> misreading something?
No. Yes. `first` is a compile time parameter and can be anything.
In this case it defines a type (in examples T is used for generic
type, and R for a range). but it can be anything, a type literal
i.e. foo!(size_t a)(Bar b); , it can be another symbol ( a
function, class or even another template (with is own set of
args)! it can be varaidic as well i.e. foo!(T...)(some_args)
Second is the set of runtime parameters, which can be of types
defined in the compile time args.
More information about the Digitalmars-d
mailing list