Understanding alias template parameters
Ali Çehreli
acehreli at yahoo.com
Fri Apr 22 15:15:38 UTC 2022
On 4/22/22 01:04, JG wrote:
> In response to the change to "alias", which has several upsides
> including faster code. I would note it also has some downsides including
> every lambda produces a new type so that (at the moment) the following
> assert
> holds:
I got confused a little bit there. To make sure: alias would cause
different template instantiation. That's why the following types are
different for 'map'.
> ```d
> auto r = iota(10).map!(x=>x+1);
> auto s = iota(10).map!(x=>x+1);
> assert(!is(typeof(r)==typeof(s)));
> ```
When you use your MyMap, the range types are the same.
Having an alias parameter, myMap() function will still cause multiple
instances but that's life.
Ali
More information about the Digitalmars-d-learn
mailing list