minElement on array of const objects

vit vit at vit.vit
Mon Nov 13 14:28:27 UTC 2017


On Monday, 13 November 2017 at 12:15:26 UTC, Nathan S. wrote:
>>Unqual!Element seed = r.front;
>
>>alias MapType = Unqual!(typeof(mapFun(CommonElement.init)));
>
> This looks like a job for std.typecons.Rebindable!(const A) 
> instead of Unqual!(const A) which is used currently. I am 
> surprised that this is the first time anyone has run into this.

Is Unqual necessary here?:
https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1284
https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1340

And here
https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1301
https://github.com/dlang/phobos/blob/master/std/algorithm/searching.d#L1355
is necessary something like RebindableOrUnqual instead of Unqual:

template RebindableOrUnqual(T){
	static if (is(T == class) || is(T == interface) || 
isDynamicArray!T || isAssociativeArray!T)alias RebindableOrUnqual 
= Rebindable!T;
	else alias RebindableOrUnqual = Unqual!T;
}


More information about the Digitalmars-d-learn mailing list