why are types mismatch?
Maxim Fomin
maxim at maxim-fomin.ru
Tue Oct 1 11:55:41 PDT 2013
On Tuesday, 1 October 2013 at 18:10:05 UTC, deadalnix wrote:
> On Tuesday, 1 October 2013 at 18:07:31 UTC, Roman wrote:
>> alias int function(int) function_type;
>>
>>
>>
>> void main()
>> {
>> bar!foo(2);
>> bar!((int i)=> i*2)(2);
>> }
>>
>> int foo(int i)
>> {
>> return i;
>> }
>>
>> void bar(alias baz)(int i)
>> {
>> static if (!is(typeof(baz) == function_type))
>> {
>> pragma(msg, typeof(baz), " != ", function_type); //wtf?
>> }
>>
>> std.stdio.writeln(bar(i));
>> }
>>
>> Where am I wrong?
>
> bar!foo should work as you expect.
> bar!((int i)=> i*2) is different because (int i) => i*2 is
> probably a template. Can you paste the output of your code so
> we can help you more easily ?
???
foo is not a function pointer
auto x = &foo;
bar!(x)(2);
should work.
And (int i) => i*2 is of course not a template [(i) => i*2 would
be].
More information about the Digitalmars-d
mailing list