Partially instantiating templates?
Magnus Lie Hetland
magnus at hetland.org
Tue Feb 1 07:00:16 PST 2011
On 2011-02-01 12:37:05 +0100, Simen kjaeraas said:
> Magnus Lie Hetland <magnus at hetland.org> wrote:
>
>> Hm. Just to make sure this *is* a bug, and I'm not just being a dumbass
>> ... this is a tiny program that illustrates the problem (i.e., gives
>> the error above). Perhaps the use of a local function here really is
>> prohibited...?
>
> Maybe it is. It really shouldn't be, though. If this is not a bug, then
> Walter has a bug for not accepting this as a bug. :p
Hehe :)
Sort of related (though perhaps only remotely) is the following, which
won't compile (Error: static assert "Bad unary function: f(a) for type
int"):
import std.functional, std.stdio;
int f(int x) {return x;}
void main() {
alias unaryFun!("f(a)") g;
writeln(g(3));
}
It may not be related -- but I've been trying to use the string
representation instead of lambda in some places, and I thought maybe a
similar name lookup problem may be present in the unaryFun template?
(The detauls of the implementation are a bit beyond me at the moment...)
Maybe there's an unstated restriction against using functions in the
unaryFun string parameter (at least I couldn't find it in the docs) --
but ... there is the following example in the docs for std.algorithms:
sort!("hashFun(a) < hashFun(b)")(array);
So it would seem like this *should* work?
--
Magnus Lie Hetland
http://hetland.org
More information about the Digitalmars-d-learn
mailing list