[ create a new paste ] login | about

Link: http://codepad.org/DBdCJYI2    [ raw code | fork ]

D, pasted on Feb 23:
import std.stdio;
import std.tarits;


@safe pure nothrow int f_param() 
{
    return 42; 
}

void f1(alias param)()
{
    writeln( typeid(typeof(param)) );
    // int() no pure/nothrow information
    writeln( functionAttributes!param & FunctionAttribute.pure_ );
    // 1
    writeln( param() );
    // 42
}

void f2( int function() param )
{
    writeln( typeid(typeof(param)) );
    // int()*
    writeln( functionAttributes!param & FunctionAttribute.pure_ );
    // 0 , because is actually pointer to function, not function itself, I suppose?
    writeln( param() );
    // 42
}

// just not possible :(
// void f3( pure int function() param )


void main()
{
    f1!( f_param );
    f2( &f_param );
}


Create a new paste based on this one


Comments: