why are types mismatch?

deadalnix deadalnix at gmail.com
Tue Oct 1 11:10:03 PDT 2013


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 ?


More information about the Digitalmars-d mailing list