Partially instantiating templates?

Magnus Lie Hetland magnus at hetland.org
Tue Feb 1 08:21:13 PST 2011


On 2011-02-01 16:41:33 +0100, Simen kjaeraas said:

>> That certainly makes sense. I just got thrown off by the example in 
>> std.algorithm:
>> 
>> uint hashFun(string) { ... expensive computation ... }
>> string[] array = ...;
>> // Sort strings by hash, slow
>> sort!("hashFun(a) < hashFun(b)")(array);
>> 
>> The only way this could work would be if hashFun was available to the 
>> sort template, I guess...?
> 
> Nope, still std.functional. That's where the string is mixin'ed.

Right. Given the example, there's no way to tell that sort is 
implemented using std.functional, so really meant whichever function is 
actually using the string ;) But, yeah, I understand how it works. 
Thanks.

> But thanks for noting that, I've filed it as issue #5513.

Good.

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list